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

118 lines
3.9 KiB
Text
Raw Normal View History

2018-09-14 05:20:02 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2020-11-02 19:27:34 +01:00
source _common.sh
2018-09-14 05:20:02 +02:00
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
2018-09-14 05:20:02 +02:00
2020-10-17 13:52:59 +02:00
squid_port=$(ynh_app_setting_get $app squid_port)
2018-09-14 05:20:02 +02:00
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL 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
#=================================================
# Optional: Expose this port publicly
# (N.B. : you only need to do this if the app actually needs to expose the port publicly.
# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !)
2018-09-14 05:20:02 +02:00
# Find an available port
2020-10-17 13:52:59 +02:00
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
#=================================================
# MODIFY A CONFIG FILE
#=================================================
### `ynh_replace_string` is used to replace a string in a file.
### (It's compatible with sed regular expressions syntax)
# See is squid3 folder is there
2020-10-17 11:19:50 +02:00
if [ -d "/etc/squid3" ]; then
2018-09-28 12:38:03 +02:00
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
2020-11-02 19:27:34 +01:00
ynh_die "No squid folder found in /etc. Looks like squid 3 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
# Save squid folder
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
2018-09-14 05:20:02 +02:00
#=================================================
# RESTORE INOTIFY'S CONFIG
#=================================================
2020-10-17 11:19:50 +02:00
ynh_secure_remove "/etc/$squid/squid.conf"
2018-09-28 12:38:03 +02:00
ynh_restore_file "/etc/$squid/squid.conf"
service $squid restart
yunohost app ssowatconf
2018-09-14 05:20:02 +02:00
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
2020-10-17 13:52:59 +02:00
yunohost service add squid3 --log "/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
#=================================================
ynh_script_progression --message="Restoration completed for $app"