diff --git a/README.md b/README.md index 92acf6e..5b30af8 100644 --- a/README.md +++ b/README.md @@ -20,31 +20,12 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-requested web pages. Squid has extensive access controls and makes a great server accelerator. +## Special Thanks + +Thanks to **Fred** to write the instruction to configure Squid for YunoHost. French: + **Shipped version:** 4.13~ynh1 -## Disclaimers / important information - -## Instruction - -1. The app can not be **multi-instance**(can't be installed many times on same server). -2. **LDAP** is there(Registered users can use there login username and password to browser internet through the proxy) -3. **Port number** used by the proxy will be sent to the **admin mail** of the Yunohost server. -4. The username and password is **asked twice** first time you start the browser(I have no idea why this happens). - -## Configure Squid3 for Firefox - -1. Go to **Preferences -> General -> network proxy** -1. Select **Manual proxy configuration** -1. In **HTTP Proxy** enter your **domain name or server IP** and in **Port** enter the port sent to your **admin email**. -1. Check **Use this proxy server for all protocols**. -1. Under **No Proxy for** enter this **localhost, 127.0.0.1**. -1. **Save and restart** the Firefox. - -If you try Squid 3 in any other way please write the instruction in the issue so that I can add it to the readme - -## Special Thanks -Thanks to **Fred** to write the instruction to configure Squid for YunoHost. French: https://memo-linux.com/installer-squid3-sur-un-serveur-yunohost/ - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index abffcc2..74e7cd3 100644 --- a/README_fr.md +++ b/README_fr.md @@ -20,31 +20,12 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-requested web pages. Squid has extensive access controls and makes a great server accelerator. +## Special Thanks + +Thanks to **Fred** to write the instruction to configure Squid for YunoHost. French: + **Version incluse :** 4.13~ynh1 -## Avertissements / informations importantes - -## Instruction - -1. The app can not be **multi-instance**(can't be installed many times on same server). -2. **LDAP** is there(Registered users can use there login username and password to browser internet through the proxy) -3. **Port number** used by the proxy will be sent to the **admin mail** of the Yunohost server. -4. The username and password is **asked twice** first time you start the browser(I have no idea why this happens). - -## Configure Squid3 for Firefox - -1. Go to **Preferences -> General -> network proxy** -1. Select **Manual proxy configuration** -1. In **HTTP Proxy** enter your **domain name or server IP** and in **Port** enter the port sent to your **admin email**. -1. Check **Use this proxy server for all protocols**. -1. Under **No Proxy for** enter this **localhost, 127.0.0.1**. -1. **Save and restart** the Firefox. - -If you try Squid 3 in any other way please write the instruction in the issue so that I can add it to the readme - -## Special Thanks -Thanks to **Fred** to write the instruction to configure Squid for YunoHost. French: https://memo-linux.com/installer-squid3-sur-un-serveur-yunohost/ - ## Documentations et ressources * Site officiel de l’app : diff --git a/check_process b/check_process deleted file mode 100644 index 261f176..0000000 --- a/check_process +++ /dev/null @@ -1,20 +0,0 @@ -;; Test complet - ; Manifest - port="8095" - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=0 - setup_nourl=1 - setup_private=0 - setup_public=0 - upgrade=1 - # 1.0~ynh2 - upgrade=1 from_commit=e1920eb3c212ae8d09a6e2fd8188b2f93aed0707 - backup_restore=1 - multi_instance=0 - port_already_use=0 - change_url=0 -;;; Options -Email= -Notification=none diff --git a/conf/squid.conf b/conf/squid.conf index f25381d..6c46586 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__/basic_ldap_auth -b dc=yunohost,dc=org -h 127.0.0.1 -f "uid=%s" +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 children 50 auth_param basic realm Web-Proxy @@ -42,11 +42,11 @@ http_access deny all ##cache DNS en local dns_nameservers 127.0.0.1 ##Port d'écoute du Proxy -http_port __SQUID_PORT__ +http_port __PORT__ forwarded_for off ### mode transparant, la vrai IP est cachée -cache_dir aufs /var/spool/__SQUID__ 10000 16 256 +cache_dir aufs /var/spool/__SQUID_NAME__ 10000 16 256 hierarchy_stoplist cgi-bin ? -access_log /var/log/__SQUID__/access.log squid +access_log /var/log/__SQUID_NAME__/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/doc/ADMIN.md b/doc/ADMIN.md new file mode 100644 index 0000000..54915b7 --- /dev/null +++ b/doc/ADMIN.md @@ -0,0 +1,10 @@ +## Configure Squid3 for Firefox + +1. Go to **Preferences -> General -> network proxy** +1. Select **Manual proxy configuration** +1. In **HTTP Proxy** enter your **domain name or server IP** and in **Port** enter the port sent to your **admin email**. +1. Check **Use this proxy server for all protocols**. +1. Under **No Proxy for** enter this **localhost, 127.0.0.1**. +1. **Save and restart** the Firefox. + +If you try Squid 3 in any other way please write the instruction in the issue so that I can add it to the readme diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index c58434f..67d6cbb 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -1,3 +1,7 @@ ## Squid: Proxy with Optimising Web Delivery Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-requested web pages. Squid has extensive access controls and makes a great server accelerator. + +## Special Thanks + +Thanks to **Fred** to write the instruction to configure Squid for YunoHost. French: diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index 7d1669a..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1,20 +0,0 @@ -## Instruction - -1. The app can not be **multi-instance**(can't be installed many times on same server). -2. **LDAP** is there(Registered users can use there login username and password to browser internet through the proxy) -3. **Port number** used by the proxy will be sent to the **admin mail** of the Yunohost server. -4. The username and password is **asked twice** first time you start the browser(I have no idea why this happens). - -## Configure Squid3 for Firefox - -1. Go to **Preferences -> General -> network proxy** -1. Select **Manual proxy configuration** -1. In **HTTP Proxy** enter your **domain name or server IP** and in **Port** enter the port sent to your **admin email**. -1. Check **Use this proxy server for all protocols**. -1. Under **No Proxy for** enter this **localhost, 127.0.0.1**. -1. **Save and restart** the Firefox. - -If you try Squid 3 in any other way please write the instruction in the issue so that I can add it to the readme - -## Special Thanks -Thanks to **Fred** to write the instruction to configure Squid for YunoHost. French: https://memo-linux.com/installer-squid3-sur-un-serveur-yunohost/ diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md new file mode 100644 index 0000000..e3c7493 --- /dev/null +++ b/doc/POST_INSTALL.md @@ -0,0 +1,15 @@ +You can find a config file at `/etc/__SQUID_FOLDER__/squid.conf`. +Squid 3 will work with your registered users through LDAP. Just put the username and password when asked. + +To configure on Firefox go to preferences->general->network proxy->manual proxy configuration. + +Enter these value in the below fields: + +* Http proxy: Your any registered domain name or ip, eg `domain.tld` +* port: `__PORT__` +* Tick mark use this proxy server for all protocols +* No proxy for: `localhost, 127.0.0.1` + +Save and restart browser. + +If you are facing any issues or want to improve this app, please open a new issue in this project: diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 76100e8..0000000 --- a/manifest.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "squid3", - "id": "squid3", - "packaging_format": 1, - "description": { - "en": "Caching proxy for the Web supporting HTTP, HTTPS, FTP and more.", - "fr": "Proxy cache pour le web, compatible HTTP, HTTPS, FTP et plus encore." - }, - "version": "4.13~ynh1", - "url": "http://www.squid-cache.org/", - "upstream": { - "license": "GPL-2.0-only", - "website": "http://www.squid-cache.org" - }, - "license": "GPL-2.0-only", - "maintainer": { - "name": "Anmol Sharma", - "email": "anmol@datamol.org" - }, - "requirements": { - "yunohost": ">= 11.0.9" - }, - "multi_instance": false, - "services": [], - "arguments": { - "install" : [ - { - "name": "squid_port", - "type": "string", - "ask": { - "en": "Choose a port for your Squid 3.", - "fr": "Entrez un port pour votre Squid 3." - }, - "example": "8095", - "default": "8095" - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..f5fc596 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,43 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "squid3" +name = "squid3" +description.en = "Caching proxy for the Web supporting HTTP, HTTPS, FTP and more." +description.fr = "Proxy cache pour le web, compatible HTTP, HTTPS, FTP et plus encore." + +version = "4.13~ynh1" + +maintainers = ["Anmol Sharma"] + +[upstream] +license = "GPL-2.0-only" +website = "http://www.squid-cache.org" +cpe = "cpe:2.3:a:squid-cache:squid" + +[integration] +yunohost = ">= 11.0.9" +architectures = "all" +multi_instance = false +ldap = true +sso = false +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" + +[install] + +[resources] + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + + [resources.ports] + main.default = 8095 + main.exposed = "TCP" + + [resources.apt] + packages = ["squid3", "mailutils"] diff --git a/scripts/_common.sh b/scripts/_common.sh index 169efef..dca1276 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,13 +4,27 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -pkg_dependencies="squid3 mailutils" - #================================================= # 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 #================================================= @@ -18,138 +32,3 @@ pkg_dependencies="squid3 mailutils" #================================================= # FUTURE OFFICIAL HELPERS #================================================= - -# Send an email to inform the administrator -# -# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type] -# | arg: -m --app_message= - The file with the content to send to the administrator. -# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root -# example: "root admin@domain" -# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you -# example: "root admin@domain user1 user2" -# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade' -ynh_send_readme_to_admin() { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= ) - local app_message - local recipients - local type - # Manage arguments with getopts - - ynh_handle_getopts_args "$@" - app_message="${app_message:-}" - recipients="${recipients:-root}" - type="${type:-install}" - - # Get the value of admin_mail_html - admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) - admin_mail_html="${admin_mail_html:-0}" - - # Retrieve the email of users - find_mails () { - local list_mails="$1" - local mail - local recipients=" " - # Read each mail in argument - for mail in $list_mails - do - # Keep root or a real email address as it is - if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" - then - recipients="$recipients $mail" - else - # But replace an user name without a domain after by its email - if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) - then - recipients="$recipients $mail" - fi - fi - done - echo "$recipients" - } - recipients=$(find_mails "$recipients") - - # Subject base - local mail_subject="☁️🆈🅽🅷☁️: \`$app\`" - - # Adapt the subject according to the type of mail required. - if [ "$type" = "backup" ]; then - mail_subject="$mail_subject has just been backup." - elif [ "$type" = "change_url" ]; then - mail_subject="$mail_subject has just been moved to a new URL!" - elif [ "$type" = "remove" ]; then - mail_subject="$mail_subject has just been removed!" - elif [ "$type" = "restore" ]; then - mail_subject="$mail_subject has just been restored!" - elif [ "$type" = "upgrade" ]; then - mail_subject="$mail_subject has just been upgraded!" - else # install - mail_subject="$mail_subject has just been installed!" - fi - - local mail_message="This is an automated message from your beloved YunoHost server. -Specific information for the application $app. -$(if [ -n "$app_message" ] -then - cat "$app_message" -else - echo "...No specific information..." -fi) ---- -Automatic diagnosis data from YunoHost -__PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')__PRE_TAG2__" - - # Store the message into a file for further modifications. - echo "$mail_message" > mail_to_send - - # If a html email is required. Apply html tags to the message. - if [ "$admin_mail_html" -eq 1 ] - then - # Insert 'br' tags at each ending of lines. - ynh_replace_string "$" "
" mail_to_send - - # Insert starting HTML tags - sed --in-place '1s@^@\n\n\n\n@' mail_to_send - - # Keep tabulations - ynh_replace_string " " "\ \ " mail_to_send - ynh_replace_string "\t" "\ \ " mail_to_send - - # Insert url links tags - ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "\1" mail_to_send - - # Insert pre tags - ynh_replace_string "__PRE_TAG1__" "
" mail_to_send
-		ynh_replace_string "__PRE_TAG2__" "<\pre>" mail_to_send
-
-		# Insert finishing HTML tags
-		echo -e "\n\n" >> mail_to_send
-
-	# Otherwise, remove tags to keep a plain text.
-	else
-		# Remove URL tags
-		ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send
-		ynh_replace_string "__URL_TAG2__" ": " mail_to_send
-
-		# Remove PRE tags
-		ynh_replace_string "__PRE_TAG[1-2]__" "" mail_to_send
-	fi
-
-	# Define binary to use for mail command
-	if [ -e /usr/bin/bsd-mailx ]
-	then
-		local mail_bin=/usr/bin/bsd-mailx
-	else
-		local mail_bin=/usr/bin/mail.mailutils
-	fi
-
-	if [ "$admin_mail_html" -eq 1 ]
-	then
-		content_type="text/html"
-	else
-		content_type="text/plain"
-	fi
-
-	# Send the email to the recipients
-	cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients"
-}
diff --git a/scripts/backup b/scripts/backup
index 048c0bc..0ea571a 100755
--- a/scripts/backup
+++ b/scripts/backup
@@ -10,30 +10,13 @@
 source ../settings/scripts/_common.sh
 source /usr/share/yunohost/helpers
 
-#=================================================
-# MANAGE SCRIPT FAILURE
-#=================================================
-
-ynh_clean_setup () {
-	true
-}
-# Exit if an error occurs during the execution of the script
-ynh_abort_if_errors
-
-#=================================================
-# LOAD SETTINGS
-#=================================================
-ynh_print_info --message="Loading installation settings..."
-
-app=$YNH_APP_INSTANCE_NAME
-
-squid=$(ynh_app_setting_get --app=$app --key=squid_folder)
-
 #=================================================
 # BACKUP VARIOUS FILES
 #=================================================
 
-ynh_backup --src_path="/etc/$squid/squid.conf"
+ynh_backup --src_path="/etc/$squid_name/squid.conf"
+
+ynh_backup --src_path="/var/log/$squid_name"
 
 #=================================================
 # END OF SCRIPT
diff --git a/scripts/install b/scripts/install
index 033b7e5..6d1be0d 100755
--- a/scripts/install
+++ b/scripts/install
@@ -10,74 +10,26 @@ source _common.sh
 source /usr/share/yunohost/helpers
 
 #=================================================
-# MANAGE SCRIPT FAILURE
+# INITIALIZE AND STORE SETTINGS
 #=================================================
 
-# Exit if an error occurs during the execution of the script
-ynh_abort_if_errors
+find_squid_version
 
 #=================================================
-# RETRIEVE ARGUMENTS FROM THE MANIFEST
-#=================================================
-
-squid_port=$YNH_APP_ARG_SQUID_PORT
-
-app=$YNH_APP_INSTANCE_NAME
-
-#=================================================
-# STANDARD MODIFICATIONS
-#=================================================
-# FIND AND OPEN A PORT
-#=================================================
-ynh_script_progression --message="Configuring firewall..."
-
-# Find an available port
-squid_port=$(ynh_find_port --port=$squid_port)
-ynh_app_setting_set --app=$app --key=squid_port --value=$squid_port
-
-# Open the port
-ynh_script_progression --message="Configuring firewall..."
-ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $squid_port
-
-#=================================================
-# INSTALL DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Installing dependencies..."
-
-ynh_install_app_dependencies $pkg_dependencies
-
-#=================================================
-# SPECIFIC SETUP
+# APP INITIAL CONFIGURATION
 #=================================================
 # ADD A CONFIGURATION
 #=================================================
-ynh_script_progression --message="Adding a configuration file..."
+ynh_script_progression --message="Adding a configuration file..." --weight=1
 
-# See if squid3 folder exits
-if [ -d "/etc/squid3" ]; then
-	squid="squid3"
-
-# If squid3 folder is not found look for squid folder
-elif [ -d "/etc/squid" ]; then
-	squid="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_folder --value=$squid
-
-ynh_add_config --template="../conf/squid.conf" --destination="/etc/$squid/squid.conf"
+ynh_add_config --template="squid.conf" --destination="/etc/$squid_name/squid.conf"
 
 #=================================================
-# GENERIC FINALIZATION
+# SYSTEM CONFIGURATION
 #=================================================
-# INTEGRATE SERVICE IN YUNOHOST
-#=================================================
-ynh_script_progression --message="Integrating service in YunoHost..."
+ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
 
-yunohost service add $squid --description "Squid3 a web proxy service" --log="/var/log/$squid/access.log" --needs_exposed_ports $squid_port
+yunohost service add "$squid_name" --description "Squid3 a web proxy service" --log="/var/log/$squid_name/access.log" --needs_exposed_ports "$port"
 
 #=================================================
 # START SYSTEMD SERVICE
@@ -85,32 +37,7 @@ yunohost service add $squid --description "Squid3 a web proxy service" --log="/v
 ynh_script_progression --message="Starting a systemd service..."
 
 # Start a systemd service
-ynh_systemd_action --service_name=$squid --action="restart" --log_path="/var/log/$squid/cache.log"
-
-#=================================================
-# SEND A README FOR THE ADMIN
-#=================================================
-
-echo "You can find a config file at /etc/$squid/squid.conf
-Squid 3 will work with your registered users through LDAP. Just put the username and password when asked.
-
-To configure on Firefox go to preferences->general->network proxy->manual proxy configuration.
-
-Enter these value in the below feilds.
----------------------------------------------------------------------
-| Http proxy: Your any registered domain name or ip eg domain.tld
-|
-|port: $squid_port
-|
-|Tick mark use this proxy server for all protocols
-|
-|No proxy for: localhost, 127.0.0.1
-|
-|Save and restart borwser.
----------------------------------------------------------------------
-If you are facing any issues or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/squid3_ynh/issues" > mail_to_send
-
-ynh_send_readme_to_admin --app_message="mail_to_send" --type="install"
+ynh_systemd_action --service_name="$squid_name" --action="restart" --log_path="/var/log/$squid_name/cache.log"
 
 #=================================================
 # END OF SCRIPT
diff --git a/scripts/remove b/scripts/remove
index 5ac91f9..b39b21d 100755
--- a/scripts/remove
+++ b/scripts/remove
@@ -10,55 +10,24 @@ source _common.sh
 source /usr/share/yunohost/helpers
 
 #=================================================
-# LOAD SETTINGS
-#=================================================
-ynh_script_progression --message="Loading installation settings..."
-
-app=$YNH_APP_INSTANCE_NAME
-
-squid_port=$(ynh_app_setting_get --app=$app --key=squid_port)
-squid=$(ynh_app_setting_get --app=$app --key=squid_folder)
-
-#=================================================
-# STANDARD REMOVE
-#=================================================
-# REMOVE SERVICE INTEGRATION IN YUNOHOST
+# REMOVE SYSTEM CONFIGURATIONS
 #=================================================
+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 >/dev/null
-then
-	ynh_script_progression --message="Removing $app service integration..."
-	yunohost service remove $squid
+if ynh_exec_warn_less yunohost service status "$squid_name" >/dev/null; then
+    yunohost service remove "$squid_name"
 fi
 
-#=================================================
-# REMOVE DEPENDENCIES
-#=================================================
-
-# Remove metapackage and its dependencies
-ynh_remove_app_dependencies
-#=================================================
-# CLOSE A PORT
-#=================================================
-
-if yunohost firewall list | grep -q "\- $squid_port$"
-then
-	ynh_script_progression --message="Closing port $squid_port..."
-	ynh_exec_warn_less yunohost firewall disallow TCP $squid_port
-fi
-
-#=================================================
-# SPECIFIC REMOVE
 #=================================================
 # REMOVE VARIOUS FILES
 #=================================================
 
 # Remove a directory securely
-ynh_secure_remove --file="/etc/$squid/"
+ynh_secure_remove --file="/etc/$squid_name/"
 
 # Remove the log files
-ynh_secure_remove --file="/var/log/$squid"
+ynh_secure_remove --file="/var/log/$squid_name"
 
 #=================================================
 # END OF SCRIPT
diff --git a/scripts/restore b/scripts/restore
index 9b78599..a84b9b3 100755
--- a/scripts/restore
+++ b/scripts/restore
@@ -10,75 +10,22 @@
 source ../settings/scripts/_common.sh
 source /usr/share/yunohost/helpers
 
-#=================================================
-# MANAGE SCRIPT FAILURE
-#=================================================
-
-ynh_clean_setup () {
-	ynh_clean_check_starting
-}
-# Exit if an error occurs during the execution of the script
-ynh_abort_if_errors
-
-#=================================================
-# LOAD SETTINGS
-#=================================================
-ynh_script_progression --message="Loading installation settings..."
-
-app=$YNH_APP_INSTANCE_NAME
-
-squid_port=$(ynh_app_setting_get --app=$app --key=squid_port)
-
-#=================================================
-# SPECIFIC RESTORATION
-#=================================================
-# REINSTALL DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Reinstalling dependencies..."
-
-# Define and install dependencies
-ynh_install_app_dependencies $pkg_dependencies
-
-#=================================================
-# SPECIFIC RESTORE
-#=================================================
-# OPEN PORTS
-#=================================================
-
-# Find an available port
-squid_port=$(ynh_find_port --port=$squid_port)
-ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $squid_port
-ynh_app_setting_set --app=$app --key=squid_port --value=$squid_port
-
 #=================================================
 # ADD A CONFIGURATION
 #=================================================
 ynh_script_progression --message="Adding a configuration file..."
 
-# See if squid3 folder exits
-if [ -d "/etc/squid3" ]; then
-	squid="squid3"
+find_squid_version
 
-# If squid3 folder is not found look for squid folder
-elif [ -d "/etc/squid" ]; then
-	squid="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_folder --value=$squid
-
-ynh_secure_remove --file="/etc/$squid/squid.conf"
-ynh_add_config --template="../conf/squid.conf" --destination="/etc/$squid/squid.conf"
+ynh_secure_remove --file="/etc/$squid_name/squid.conf"
+ynh_add_config --template="squid.conf" --destination="/etc/$squid_name/squid.conf"
 
 #=================================================
-# INTEGRATE SERVICE IN YUNOHOST
+# RESTORE SYSTEM CONFIGURATIONS
 #=================================================
-ynh_script_progression --message="Integrating service in YunoHost..."
+ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
 
-yunohost service add $squid --description "Squid3 a web proxy service" --log="/var/log/$squid/access.log" --needs_exposed_ports $squid_port
+yunohost service add "$squid_name" --description "Squid3 a web proxy service" --log="/var/log/$squid_name/access.log" --needs_exposed_ports "$port"
 
 #=================================================
 # START SYSTEMD SERVICE
@@ -86,32 +33,7 @@ yunohost service add $squid --description "Squid3 a web proxy service" --log="/v
 ynh_script_progression --message="Starting a systemd service..."
 
 # Start a systemd service
-ynh_systemd_action --service_name=$squid --action="restart" --log_path="/var/log/$squid/cache.log"
-
-#=================================================
-# SEND A README FOR THE ADMIN
-#=================================================
-
-echo "You can find a config file at /etc/$squid/squid.conf
-Squid 3 will work with your registered users through LDAP. Just put the username and password when asked.
-
-To configure on Firefox go to preferences->general->network proxy->manual proxy configuration.
-
-Enter these value in the below feilds.
----------------------------------------------------------------------
-| Http proxy: Your any registered domain name or ip eg domain.tld
-|
-|port: $squid_port
-|
-|Tick mark use this proxy server for all protocols
-|
-|No proxy for: localhost, 127.0.0.1
-|
-|Save and restart borwser.
----------------------------------------------------------------------
-If you are facing any issues or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/squid3_ynh/issues" > mail_to_send
-
-ynh_send_readme_to_admin --app_message="mail_to_send" --type="install"
+ynh_systemd_action --service_name="$squid_name" --action="restart" --log_path="/var/log/$squid_name/cache.log"
 
 #=================================================
 # END OF SCRIPT
diff --git a/scripts/upgrade b/scripts/upgrade
index 8f7b654..ddd91fa 100755
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -10,36 +10,19 @@ source _common.sh
 source /usr/share/yunohost/helpers
 
 #=================================================
-# LOAD SETTINGS
+# ENSURE DOWNWARD COMPATIBILITY
 #=================================================
-ynh_script_progression --message="Loading installation settings..."
+ynh_script_progression --message="Ensuring downward compatibility..."
 
-app=$YNH_APP_INSTANCE_NAME
+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
 
-squid_port=$(ynh_app_setting_get --app=$app --key=squid_port)
-squid=$(ynh_app_setting_get --app=$app --key=squid_folder)
-
-#=================================================
-# CHECK VERSION
-#=================================================
-ynh_script_progression --message="Checking version..."
-
-upgrade_type=$(ynh_check_app_version_changed)
-
-#=================================================
-# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
-#=================================================
-ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
-
-# Backup the current version of the app
-ynh_backup_before_upgrade
-ynh_clean_setup () {
-	ynh_clean_check_starting
-	# Restore it if the upgrade fails
-	ynh_restore_upgradebackup
-}
-# Exit if an error occurs during the execution of the script
-ynh_abort_if_errors
+if [[ -z "${squid_name:-}" ]]; then
+    find_squid_version
+fi
 
 #=================================================
 # STANDARD UPGRADE STEPS
@@ -48,80 +31,30 @@ ynh_abort_if_errors
 #=================================================
 ynh_script_progression --message="Stopping a systemd service..."
 
-ynh_systemd_action --service_name=$squid --action="stop" --log_path="/var/log/$squid/cache.log"
-
-#=================================================
-# ENSURE DOWNWARD COMPATIBILITY
-#=================================================
-ynh_script_progression --message="Ensuring downward compatibility..."
-
-#=================================================
-# UPGRADE DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Upgrading dependencies..."
-
-ynh_install_app_dependencies $pkg_dependencies
+ynh_systemd_action --service_name="$squid_name" --action="stop" --log_path="/var/log/$squid_name/cache.log"
 
 #=================================================
 # UPDATE A CONFIG FILE
 #=================================================
 ynh_script_progression --message="Updating a configuration file..."
 
-# See if squid3 folder exits
-if [ -d "/etc/squid3" ]; then
-	squid="squid3"
+find_squid_version
 
-# If squid3 folder is not found look for squid folder
-elif [ -d "/etc/squid" ]; then
-	squid="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_folder --value=$squid
-
-ynh_add_config --template="../conf/squid.conf" --destination="/etc/$squid/squid.conf"
+ynh_add_config --template="squid.conf" --destination="/etc/$squid_name/squid.conf"
 
 #=================================================
-# INTEGRATE SERVICE IN YUNOHOST
+# REAPPLY SYSTEM CONFIGURATIONS
 #=================================================
-ynh_script_progression --message="Integrating service in YunoHost..."
+ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
 
-yunohost service add $squid --description "Squid3 a web proxy service" --log="/var/log/$squid/access.log" --needs_exposed_ports $squid_port
+yunohost service add "$squid_name" --description "Squid3 a web proxy service" --log="/var/log/$squid_name/access.log" --needs_exposed_ports "$port"
 
 #=================================================
 # START SYSTEMD SERVICE
 #=================================================
 ynh_script_progression --message="Starting a systemd service..."
 
-ynh_systemd_action --service_name=$squid --action="restart" --log_path="/var/log/$squid/cache.log"
-
-#=================================================
-# SEND A README FOR THE ADMIN
-#=================================================
-
-echo "You can find a config file at /etc/$squid/squid.conf
-Squid 3 will work with your registered users through LDAP. Just put the username and password when asked.
-
-To configure on Firefox go to preferences->general->network proxy->manual proxy configuration.
-
-Enter these value in the below feilds.
----------------------------------------------------------------------
-| Http proxy: Your any registered domain name or ip eg domain.tld
-|
-|port: $squid_port
-|
-|Tick mark use this proxy server for all protocols
-|
-|No proxy for: localhost, 127.0.0.1
-|
-|Save and restart borwser.
----------------------------------------------------------------------
-If you are facing any issues or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/squid3_ynh/issues" > mail_to_send
-
-ynh_send_readme_to_admin --app_message="mail_to_send" --type="install"
+ynh_systemd_action --service_name="$squid_name" --action="restart" --log_path="/var/log/$squid_name/cache.log"
 
 #=================================================
 # END OF SCRIPT
diff --git a/tests.toml b/tests.toml
new file mode 100644
index 0000000..30d19e0
--- /dev/null
+++ b/tests.toml
@@ -0,0 +1,7 @@
+#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
+
+test_format = 1.0
+
+[default]
+
+    test_upgrade_from.e1920eb3c212ae8d09a6e2fd8188b2f93aed0707.name = "1.0~ynh2"