fix: simplify squid auth onboarding
This commit is contained in:
21
ct/squid.sh
21
ct/squid.sh
@@ -28,8 +28,8 @@ function update_script() {
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
msg_info "Updating ${APP}"
|
msg_info "Updating ${APP}"
|
||||||
$STD apt-get update
|
$STD apt update
|
||||||
$STD apt-get -y upgrade
|
$STD apt upgrade -y
|
||||||
msg_info "Validating Squid Configuration"
|
msg_info "Validating Squid Configuration"
|
||||||
$STD squid -k parse
|
$STD squid -k parse
|
||||||
msg_ok "Validated Squid Configuration"
|
msg_ok "Validated Squid Configuration"
|
||||||
@@ -45,22 +45,9 @@ start
|
|||||||
build_container
|
build_container
|
||||||
description
|
description
|
||||||
|
|
||||||
SQUID_USER=""
|
|
||||||
SQUID_PASS=""
|
|
||||||
if pct exec "$CTID" -- test -f /root/squid.creds 2>/dev/null; then
|
|
||||||
SQUID_USER=$(pct exec "$CTID" -- awk -F': ' '/^Username:/ {print $2}' /root/squid.creds 2>/dev/null | tr -d '\r')
|
|
||||||
SQUID_PASS=$(pct exec "$CTID" -- awk -F': ' '/^Password:/ {print $2}' /root/squid.creds 2>/dev/null | tr -d '\r')
|
|
||||||
fi
|
|
||||||
|
|
||||||
msg_ok "Completed successfully!\n"
|
msg_ok "Completed successfully!\n"
|
||||||
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
||||||
echo -e "${INFO}${YW} Proxy endpoint:${CL}"
|
echo -e "${INFO}${YW} Proxy endpoint:${CL}"
|
||||||
echo -e "${TAB}${GATEWAY}${BGN}${IP}:3128${CL}"
|
echo -e "${TAB}${GATEWAY}${BGN}${IP}:3128${CL}"
|
||||||
if [[ -n "$SQUID_USER" && -n "$SQUID_PASS" ]]; then
|
echo -e "${INFO}${YW} Add a proxy user inside the container with:${CL}"
|
||||||
echo -e "${INFO}${YW} Credentials:${CL}"
|
echo -e "${TAB}${BGN}htpasswd /etc/squid/passwords <username>${CL}"
|
||||||
echo -e "${TAB}${BGN}Username: ${SQUID_USER}${CL}"
|
|
||||||
echo -e "${TAB}${BGN}Password: ${SQUID_PASS}${CL}"
|
|
||||||
else
|
|
||||||
echo -e "${INFO}${YW} Credentials are stored in the container at /root/squid.creds.${CL}"
|
|
||||||
fi
|
|
||||||
echo -e "${INFO}${YW} These details are also available in the container MOTD.${CL}"
|
|
||||||
|
|||||||
@@ -70,20 +70,10 @@ request_header_access X-Forwarded-For deny all
|
|||||||
EOF
|
EOF
|
||||||
msg_ok "Configured Squid"
|
msg_ok "Configured Squid"
|
||||||
|
|
||||||
msg_info "Generating Proxy Credentials"
|
msg_info "Preparing Authentication"
|
||||||
SQUID_USER="proxy"
|
touch /etc/squid/passwords
|
||||||
SQUID_PASS="$(dd if=/dev/urandom bs=32 count=1 status=none | base64 | tr -dc 'A-Za-z0-9' | cut -c1-16)"
|
chmod 600 /etc/squid/passwords
|
||||||
$STD htpasswd -cb /etc/squid/passwords "$SQUID_USER" "$SQUID_PASS"
|
msg_ok "Initialized Password File"
|
||||||
cat <<EOF >/root/squid.creds
|
|
||||||
Proxy endpoint: $(hostname -I | awk '{print $1}'):3128
|
|
||||||
Proxy type: HTTP Forward Proxy
|
|
||||||
Username: ${SQUID_USER}
|
|
||||||
Password: ${SQUID_PASS}
|
|
||||||
EOF
|
|
||||||
chmod 600 /root/squid.creds
|
|
||||||
msg_ok "Generated Proxy Credentials"
|
|
||||||
msg_ok "Username: ${SQUID_USER}"
|
|
||||||
msg_ok "Password: ${SQUID_PASS}"
|
|
||||||
|
|
||||||
msg_info "Validating Squid Configuration"
|
msg_info "Validating Squid Configuration"
|
||||||
$STD squid -k parse
|
$STD squid -k parse
|
||||||
@@ -100,14 +90,13 @@ echo ""
|
|||||||
echo -e "${BOLD} Squid Proxy${CL}"
|
echo -e "${BOLD} Squid Proxy${CL}"
|
||||||
echo -e " Type: ${GN}HTTP Forward Proxy${CL}"
|
echo -e " Type: ${GN}HTTP Forward Proxy${CL}"
|
||||||
echo -e " Port: ${GN}3128${CL}"
|
echo -e " Port: ${GN}3128${CL}"
|
||||||
echo -e " Default user: ${GN}${SQUID_USER}${CL}"
|
|
||||||
echo -e " Initial password: ${GN}${SQUID_PASS}${CL}"
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${BOLD} Manage users:${CL}"
|
echo -e "${BOLD} Configure Authentication:${CL}"
|
||||||
echo -e " Reset password: ${GN}htpasswd /etc/squid/passwords proxy${CL}"
|
|
||||||
echo -e " Add user: ${GN}htpasswd /etc/squid/passwords <username>${CL}"
|
echo -e " Add user: ${GN}htpasswd /etc/squid/passwords <username>${CL}"
|
||||||
echo -e " Remove user: ${GN}htpasswd -D /etc/squid/passwords <username>${CL}"
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
msg_info "Configure Proxy Authentication"
|
||||||
|
echo -e "${TAB}${BGN}Run inside the container: htpasswd /etc/squid/passwords <username>${CL}"
|
||||||
|
|
||||||
customize
|
customize
|
||||||
cleanup_lxc
|
cleanup_lxc
|
||||||
|
|||||||
@@ -28,17 +28,13 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"default_credentials": {
|
"default_credentials": {
|
||||||
"username": "proxy",
|
"username": null,
|
||||||
"password": null
|
"password": null
|
||||||
},
|
},
|
||||||
"notes": [
|
"notes": [
|
||||||
{
|
{
|
||||||
"type": "info",
|
"type": "info",
|
||||||
"text": "Initial generated credentials are shown in the completion output, written to `/root/squid.creds`, and displayed in the container MOTD."
|
"text": "Create a proxy user after installation with `htpasswd /etc/squid/passwords <username>`."
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "info",
|
|
||||||
"text": "Manage proxy users with `htpasswd /etc/squid/passwords <username>` and remove users with `htpasswd -D /etc/squid/passwords <username>`."
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user