1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/squid3_ynh.git synced 2024-09-03 20:26:11 +02:00
squid3_ynh/scripts/upgrade
2022-03-13 16:50:54 +01:00

130 lines
4.6 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
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)
#=================================================
# 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
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
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
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
# 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"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description "Squid3 a web proxy service" --log="/var/log/$squid/access.log" --needs_exposed_ports $squid_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"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed"