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/restore

121 lines
4.2 KiB
Text
Raw Normal View History

2018-09-14 05:20:02 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2022-03-13 16:50:54 +01:00
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
2020-11-08 11:26:35 +01:00
source ../settings/scripts/_common.sh
2018-09-14 05:20:02 +02:00
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
2022-03-13 16:50:54 +01:00
ynh_clean_setup () {
ynh_clean_check_starting
}
2018-09-14 05:20:02 +02:00
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
2022-03-13 16:50:54 +01:00
ynh_script_progression --message="Loading installation settings..."
2018-09-14 05:20:02 +02:00
app=$YNH_APP_INSTANCE_NAME
2018-09-14 05:20:02 +02:00
2022-03-13 16:50:54 +01:00
squid_port=$(ynh_app_setting_get --app=$app --key=squid_port)
2018-09-14 05:20:02 +02:00
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
2022-03-13 16:50:54 +01:00
ynh_script_progression --message="Reinstalling dependencies..."
2018-09-14 05:20:02 +02:00
2022-03-13 16:50:54 +01:00
# Define and install dependencies
2020-10-17 11:19:50 +02:00
ynh_install_app_dependencies $pkg_dependencies
2018-09-14 05:20:02 +02:00
#=================================================
# SPECIFIC RESTORE
#=================================================
# OPEN PORTS
#=================================================
2020-11-08 11:26:35 +01:00
# 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
2018-09-14 05:20:02 +02:00
2018-09-28 12:38:03 +02:00
#=================================================
2022-03-13 16:50:54 +01:00
# ADD A CONFIGURATION
2018-09-28 12:38:03 +02:00
#=================================================
2022-03-13 16:50:54 +01:00
ynh_script_progression --message="Adding a configuration file..."
2018-09-28 12:38:03 +02:00
2022-03-13 16:50:54 +01:00
# See if squid3 folder exits
2020-10-17 11:19:50 +02:00
if [ -d "/etc/squid3" ]; then
2022-03-13 16:50:54 +01:00
squid="squid3"
# If squid3 folder is not found look for squid folder
2018-09-28 12:38:03 +02:00
elif [ -d "/etc/squid" ]; then
2022-03-13 16:50:54 +01:00
squid="squid"
2018-09-28 12:38:03 +02:00
# If both folders are not found then call ynh_die
else
2022-03-13 16:50:54 +01:00
ynh_die --message="No squid folder found in /etc. Looks like squid3 package is not installed. Try installing it manually."
2020-10-17 11:19:50 +02:00
2018-09-28 12:38:03 +02:00
fi
2020-10-17 13:52:59 +02:00
ynh_app_setting_set --app=$app --key=squid_folder --value=$squid
2018-09-28 12:38:03 +02:00
2022-03-14 22:07:18 +01:00
ynh_secure_remove --file="/etc/$squid/squid.conf"
2022-03-13 16:50:54 +01:00
ynh_add_config --template="../conf/squid.conf" --destination="/etc/$squid/squid.conf"
2018-09-14 05:20:02 +02:00
#=================================================
2022-03-13 16:50:54 +01:00
# INTEGRATE SERVICE IN YUNOHOST
2018-09-14 05:20:02 +02:00
#=================================================
2022-03-13 16:50:54 +01:00
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $squid --description "Squid3 a web proxy service" --log="/var/log/$squid/access.log" --needs_exposed_ports $squid_port
2022-03-13 16:50:54 +01:00
2018-09-14 05:20:02 +02:00
#=================================================
2022-03-13 16:50:54 +01:00
# START SYSTEMD SERVICE
2018-09-14 05:20:02 +02:00
#=================================================
2022-03-13 16:50:54 +01:00
ynh_script_progression --message="Starting a systemd service..."
2018-09-14 05:20:02 +02:00
2022-03-13 16:50:54 +01:00
# Start a systemd service
ynh_systemd_action --service_name=$squid --action="restart" --log_path="/var/log/$squid/cache.log"
2018-09-14 05:20:02 +02:00
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
2020-10-17 11:50:38 +02:00
echo "You can find a config file at /etc/$squid/squid.conf
2020-10-17 11:19:50 +02:00
Squid 3 will work with your registered users through LDAP. Just put the username and password when asked.
2018-09-14 05:20:02 +02:00
To configure on Firefox go to preferences->general->network proxy->manual proxy configuration.
Enter these value in the below feilds.
2020-10-17 11:19:50 +02:00
---------------------------------------------------------------------
| Http proxy: Your any registered domain name or ip eg domain.tld
|
2020-10-17 13:52:59 +02:00
|port: $squid_port
|
2020-10-17 11:19:50 +02:00
|Tick mark use this proxy server for all protocols
|
2020-10-17 11:19:50 +02:00
|No proxy for: localhost, 127.0.0.1
|
2020-10-17 11:19:50 +02:00
|Save and restart borwser.
---------------------------------------------------------------------
2020-10-17 11:50:38 +02:00
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
2018-09-14 05:20:02 +02:00
2020-10-17 11:50:38 +02:00
ynh_send_readme_to_admin --app_message="mail_to_send" --type="install"
#=================================================
# END OF SCRIPT
#=================================================
2020-11-08 11:26:35 +01:00
ynh_script_progression --message="Restoration completed for $app"