From 9177cb5f23ee0876ac973df00eccd9cb34328105 Mon Sep 17 00:00:00 2001 From: 007hacky007 <007hacky007@users.noreply.github.com> Date: Tue, 14 Apr 2026 14:32:50 +0200 Subject: [PATCH] fix: simplify squid auth onboarding --- ct/squid.sh | 21 ++++----------------- install/squid-install.sh | 29 +++++++++-------------------- json/squid.json | 8 ++------ 3 files changed, 15 insertions(+), 43 deletions(-) diff --git a/ct/squid.sh b/ct/squid.sh index f5286be9..8ab803ec 100644 --- a/ct/squid.sh +++ b/ct/squid.sh @@ -28,8 +28,8 @@ function update_script() { exit fi msg_info "Updating ${APP}" - $STD apt-get update - $STD apt-get -y upgrade + $STD apt update + $STD apt upgrade -y msg_info "Validating Squid Configuration" $STD squid -k parse msg_ok "Validated Squid Configuration" @@ -45,22 +45,9 @@ start build_container 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" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Proxy endpoint:${CL}" echo -e "${TAB}${GATEWAY}${BGN}${IP}:3128${CL}" -if [[ -n "$SQUID_USER" && -n "$SQUID_PASS" ]]; then - echo -e "${INFO}${YW} Credentials:${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}" +echo -e "${INFO}${YW} Add a proxy user inside the container with:${CL}" +echo -e "${TAB}${BGN}htpasswd /etc/squid/passwords ${CL}" diff --git a/install/squid-install.sh b/install/squid-install.sh index 7ada90fd..69780f13 100644 --- a/install/squid-install.sh +++ b/install/squid-install.sh @@ -70,20 +70,10 @@ request_header_access X-Forwarded-For deny all EOF msg_ok "Configured Squid" -msg_info "Generating Proxy Credentials" -SQUID_USER="proxy" -SQUID_PASS="$(dd if=/dev/urandom bs=32 count=1 status=none | base64 | tr -dc 'A-Za-z0-9' | cut -c1-16)" -$STD htpasswd -cb /etc/squid/passwords "$SQUID_USER" "$SQUID_PASS" -cat </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 "Preparing Authentication" +touch /etc/squid/passwords +chmod 600 /etc/squid/passwords +msg_ok "Initialized Password File" msg_info "Validating Squid Configuration" $STD squid -k parse @@ -100,14 +90,13 @@ echo "" echo -e "${BOLD} Squid Proxy${CL}" echo -e " Type: ${GN}HTTP Forward Proxy${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 -e "${BOLD} Manage users:${CL}" -echo -e " Reset password: ${GN}htpasswd /etc/squid/passwords proxy${CL}" -echo -e " Add user: ${GN}htpasswd /etc/squid/passwords ${CL}" -echo -e " Remove user: ${GN}htpasswd -D /etc/squid/passwords ${CL}" +echo -e "${BOLD} Configure Authentication:${CL}" +echo -e " Add user: ${GN}htpasswd /etc/squid/passwords ${CL}" EOF +msg_info "Configure Proxy Authentication" +echo -e "${TAB}${BGN}Run inside the container: htpasswd /etc/squid/passwords ${CL}" + customize cleanup_lxc diff --git a/json/squid.json b/json/squid.json index e3d1199c..88a3aa82 100644 --- a/json/squid.json +++ b/json/squid.json @@ -28,17 +28,13 @@ } ], "default_credentials": { - "username": "proxy", + "username": null, "password": null }, "notes": [ { "type": "info", - "text": "Initial generated credentials are shown in the completion output, written to `/root/squid.creds`, and displayed in the container MOTD." - }, - { - "type": "info", - "text": "Manage proxy users with `htpasswd /etc/squid/passwords ` and remove users with `htpasswd -D /etc/squid/passwords `." + "text": "Create a proxy user after installation with `htpasswd /etc/squid/passwords `." } ] }