From c3262679ab6f8b396b7bd9a60c7f7a42876e4f2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Thu, 1 Feb 2024 11:54:07 +0100 Subject: [PATCH] Remove support for squid3 --- conf/squid.conf | 6 +++--- scripts/_common.sh | 17 ----------------- scripts/backup | 4 ++-- scripts/install | 12 +++--------- scripts/remove | 8 ++++---- scripts/restore | 10 ++++------ scripts/upgrade | 15 ++++++--------- 7 files changed, 22 insertions(+), 50 deletions(-) diff --git a/conf/squid.conf b/conf/squid.conf index 6c46586..f4be7d4 100644 --- a/conf/squid.conf +++ b/conf/squid.conf @@ -21,7 +21,7 @@ acl purge method PURGE acl CONNECT method CONNECT ###Directive pour n’autoriser que les comptes enregistrés dans le LDAP de Yunohost -auth_param basic program /usr/lib/__SQUID_NAME__/basic_ldap_auth -b dc=yunohost,dc=org -h 127.0.0.1 -f "uid=%s" +auth_param basic program /usr/lib/squid/basic_ldap_auth -b dc=yunohost,dc=org -h 127.0.0.1 -f "uid=%s" auth_param basic children 50 auth_param basic realm Web-Proxy @@ -44,9 +44,9 @@ dns_nameservers 127.0.0.1 ##Port d'écoute du Proxy http_port __PORT__ forwarded_for off ### mode transparant, la vrai IP est cachée -cache_dir aufs /var/spool/__SQUID_NAME__ 10000 16 256 +cache_dir aufs /var/spool/squid 10000 16 256 hierarchy_stoplist cgi-bin ? -access_log /var/log/__SQUID_NAME__/access.log squid +access_log /var/log/squid/access.log squid refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 diff --git a/scripts/_common.sh b/scripts/_common.sh index dca1276..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,23 +8,6 @@ # PERSONAL HELPERS #================================================= -find_squid_version() { - # See if squid3 folder exits - if [ -d "/etc/squid3" ]; then - squid_name="squid3" - - # If squid3 folder is not found look for squid folder - elif [ -d "/etc/squid" ]; then - squid_name="squid" - - # If both folders are not found then call ynh_die - else - ynh_die --message="No squid folder found in /etc. Looks like squid3 package is not installed. Try installing it manually." - fi - - ynh_app_setting_set --app="$app" --key="squid_name" --value="$squid_name" -} - #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 0ea571a..67eb21c 100755 --- a/scripts/backup +++ b/scripts/backup @@ -14,9 +14,9 @@ source /usr/share/yunohost/helpers # BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/$squid_name/squid.conf" +ynh_backup --src_path="/etc/squid/squid.conf" -ynh_backup --src_path="/var/log/$squid_name" +ynh_backup --src_path="/var/log/squid" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 6d1be0d..7fe5059 100755 --- a/scripts/install +++ b/scripts/install @@ -9,12 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# INITIALIZE AND STORE SETTINGS -#================================================= - -find_squid_version - #================================================= # APP INITIAL CONFIGURATION #================================================= @@ -22,14 +16,14 @@ find_squid_version #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -ynh_add_config --template="squid.conf" --destination="/etc/$squid_name/squid.conf" +ynh_add_config --template="squid.conf" --destination="/etc/squid/squid.conf" #================================================= # SYSTEM CONFIGURATION #================================================= ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 -yunohost service add "$squid_name" --description "Squid3 a web proxy service" --log="/var/log/$squid_name/access.log" --needs_exposed_ports "$port" +yunohost service add "squid" --description "Squid3 a web proxy service" --log="/var/log/squid/access.log" --needs_exposed_ports "$port" #================================================= # START SYSTEMD SERVICE @@ -37,7 +31,7 @@ yunohost service add "$squid_name" --description "Squid3 a web proxy service" -- ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name="$squid_name" --action="restart" --log_path="/var/log/$squid_name/cache.log" +ynh_systemd_action --service_name="squid" --action="restart" --log_path="/var/log/squid/cache.log" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index b39b21d..4e7078f 100755 --- a/scripts/remove +++ b/scripts/remove @@ -15,8 +15,8 @@ source /usr/share/yunohost/helpers ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status "$squid_name" >/dev/null; then - yunohost service remove "$squid_name" +if ynh_exec_warn_less yunohost service status "squid" >/dev/null; then + yunohost service remove "squid" fi #================================================= @@ -24,10 +24,10 @@ fi #================================================= # Remove a directory securely -ynh_secure_remove --file="/etc/$squid_name/" +ynh_secure_remove --file="/etc/squid/" # Remove the log files -ynh_secure_remove --file="/var/log/$squid_name" +ynh_secure_remove --file="/var/log/squid" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index a84b9b3..a0907fa 100755 --- a/scripts/restore +++ b/scripts/restore @@ -15,17 +15,15 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Adding a configuration file..." -find_squid_version - -ynh_secure_remove --file="/etc/$squid_name/squid.conf" -ynh_add_config --template="squid.conf" --destination="/etc/$squid_name/squid.conf" +ynh_secure_remove --file="/etc/squid/squid.conf" +ynh_add_config --template="squid.conf" --destination="/etc/squid/squid.conf" #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 -yunohost service add "$squid_name" --description "Squid3 a web proxy service" --log="/var/log/$squid_name/access.log" --needs_exposed_ports "$port" +yunohost service add "squid" --description "Squid3 a web proxy service" --log="/var/log/squid/access.log" --needs_exposed_ports "$port" #================================================= # START SYSTEMD SERVICE @@ -33,7 +31,7 @@ yunohost service add "$squid_name" --description "Squid3 a web proxy service" -- ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name="$squid_name" --action="restart" --log_path="/var/log/$squid_name/cache.log" +ynh_systemd_action --service_name="squid" --action="restart" --log_path="/var/log/squid/cache.log" #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index ddd91fa..94e9444 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -15,13 +15,10 @@ source /usr/share/yunohost/helpers ynh_script_progression --message="Ensuring downward compatibility..." if [[ -n "${squid:-}" ]]; then - squid_name="$squid" - ynh_app_setting_set --app="$app" --key="squid_name" --value="$squid_name" ynh_app_setting_delete --app="$app" --key="squid" fi - -if [[ -z "${squid_name:-}" ]]; then - find_squid_version +if [[ -n "${squid_name:-}" ]]; then + ynh_app_setting_delete --app="$app" --key="squid_name" fi #================================================= @@ -31,7 +28,7 @@ fi #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name="$squid_name" --action="stop" --log_path="/var/log/$squid_name/cache.log" +ynh_systemd_action --service_name="squid" --action="stop" --log_path="/var/log/squid/cache.log" #================================================= # UPDATE A CONFIG FILE @@ -40,21 +37,21 @@ ynh_script_progression --message="Updating a configuration file..." find_squid_version -ynh_add_config --template="squid.conf" --destination="/etc/$squid_name/squid.conf" +ynh_add_config --template="squid.conf" --destination="/etc/squid/squid.conf" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 -yunohost service add "$squid_name" --description "Squid3 a web proxy service" --log="/var/log/$squid_name/access.log" --needs_exposed_ports "$port" +yunohost service add "squid" --description "Squid3 a web proxy service" --log="/var/log/squid/access.log" --needs_exposed_ports "$port" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name="$squid_name" --action="restart" --log_path="/var/log/$squid_name/cache.log" +ynh_systemd_action --service_name="squid" --action="restart" --log_path="/var/log/squid/cache.log" #================================================= # END OF SCRIPT