refactor: address MickLesk review feedback
Use literal 'Squid' in msg_* labels, add missing msg_ok and spacing in update_script. Replace install_packages_with_retry/enable_and_start_service/ safe_service_restart helpers with plain apt and systemctl commands. Merge auth setup and config validation into a single msg block. Drop the custom /etc/profile.d MOTD heredoc and trailing htpasswd echo.
This commit is contained in:
@@ -27,17 +27,18 @@ function update_script() {
|
||||
msg_error "No ${APP} Installation Found!"
|
||||
exit
|
||||
fi
|
||||
msg_info "Updating ${APP}"
|
||||
msg_info "Updating Squid"
|
||||
$STD apt update
|
||||
$STD apt upgrade -y
|
||||
msg_ok "Updated Squid"
|
||||
|
||||
msg_info "Validating Squid Configuration"
|
||||
$STD squid -k parse
|
||||
msg_ok "Validated Squid Configuration"
|
||||
|
||||
msg_info "Restarting Squid"
|
||||
safe_service_restart "squid"
|
||||
systemctl restart squid
|
||||
msg_ok "Restarted Squid"
|
||||
msg_ok "Updated ${APP}"
|
||||
msg_ok "Updated successfully!"
|
||||
exit
|
||||
}
|
||||
|
||||
|
||||
@@ -67,36 +67,22 @@ EOF
|
||||
msg_ok "Configured Squid"
|
||||
|
||||
msg_info "Installing Dependencies"
|
||||
install_packages_with_retry squid apache2-utils
|
||||
$STD apt install -y \
|
||||
squid \
|
||||
apache2-utils
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
msg_info "Preparing Authentication"
|
||||
msg_info "Configuring Squid Authentication"
|
||||
touch /etc/squid/passwords
|
||||
chown proxy:proxy /etc/squid/passwords
|
||||
chmod 640 /etc/squid/passwords
|
||||
msg_ok "Initialized Password File"
|
||||
|
||||
msg_info "Validating Squid Configuration"
|
||||
$STD squid -k parse
|
||||
msg_ok "Validated Squid Configuration"
|
||||
msg_ok "Configured Squid Authentication"
|
||||
|
||||
msg_info "Starting Service"
|
||||
enable_and_start_service "squid"
|
||||
systemctl enable -q --now squid
|
||||
msg_ok "Started Service"
|
||||
|
||||
motd_ssh
|
||||
cat <<EOF >>/etc/profile.d/00_lxc-details.sh
|
||||
echo ""
|
||||
echo -e "${BOLD} Squid Proxy${CL}"
|
||||
echo -e " Type: ${GN}HTTP Forward Proxy${CL}"
|
||||
echo -e " Port: ${GN}3128${CL}"
|
||||
echo ""
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user