fix: simplify squid auth onboarding

This commit is contained in:
007hacky007
2026-04-14 14:32:50 +02:00
parent 713d1bd113
commit 9177cb5f23
3 changed files with 15 additions and 43 deletions

View File

@@ -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 <username>${CL}"

View File

@@ -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 <<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 "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 <username>${CL}"
echo -e " Remove user: ${GN}htpasswd -D /etc/squid/passwords <username>${CL}"
echo -e "${BOLD} Configure Authentication:${CL}"
echo -e " Add user: ${GN}htpasswd /etc/squid/passwords <username>${CL}"
EOF
msg_info "Configure Proxy Authentication"
echo -e "${TAB}${BGN}Run inside the container: htpasswd /etc/squid/passwords <username>${CL}"
customize
cleanup_lxc

View File

@@ -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 <username>` and remove users with `htpasswd -D /etc/squid/passwords <username>`."
"text": "Create a proxy user after installation with `htpasswd /etc/squid/passwords <username>`."
}
]
}