2018-09-14 05:20:02 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
2018-10-04 17:22:43 +02:00
squid_port=$YNH_APP_ARG_SQUID_PORT
2018-09-14 05:20:02 +02:00
app=$YNH_APP_INSTANCE_NAME
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
2020-10-17 11:19:50 +02:00
ynh_script_progression --message="Configuring firewall..."
2018-09-14 05:20:02 +02:00
2020-10-17 11:19:50 +02:00
# Find an available port
2020-10-17 13:52:59 +02:00
squid_port=$(ynh_find_port --port=$squid_port)
ynh_app_setting_set --app=$app --key=squid_port --value=$squid_port
2020-10-17 11:19:50 +02:00
# Open the port
2022-03-13 16:50:54 +01:00
ynh_script_progression --message="Configuring firewall..."
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $squid_port
2018-09-14 05:20:02 +02:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
2020-10-17 11:19:50 +02:00
ynh_script_progression --message="Installing dependencies..."
2018-09-14 05:20:02 +02:00
2020-10-17 11:19:50 +02:00
ynh_install_app_dependencies $pkg_dependencies
2018-09-14 05:20:02 +02:00
#=================================================
2022-03-13 16:50:54 +01:00
# SPECIFIC SETUP
#=================================================
# ADD A CONFIGURATION
2018-09-14 05:20:02 +02:00
#=================================================
2022-03-13 16:50:54 +01:00
ynh_script_progression --message="Adding a configuration file..."
2018-09-14 05:20:02 +02:00
2020-10-17 11:19:50 +02:00
# See if squid3 folder exits
if [ -d "/etc/squid3" ]; then
2022-03-13 16:50:54 +01:00
squid="squid3"
2018-09-28 12:52:49 +02:00
2018-09-28 12:38:03 +02:00
# If squid3 folder is not found look for squid folder
elif [ -d "/etc/squid" ]; then
2022-03-13 16:50:54 +01:00
squid="squid"
2020-10-17 11:19:50 +02:00
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 11:19:50 +02:00
ynh_app_setting_set --app=$app --key=squid_folder --value=$squid
2018-09-28 12:38:03 +02:00
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
#=================================================
# GENERIC FINALIZATION
2020-10-17 11:19:50 +02:00
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
2022-08-15 19:09:51 +02:00
yunohost service add $squid --description "Squid3 a web proxy service" --log="/var/log/$squid/access.log" --needs_exposed_ports $squid_port
2020-10-17 11:19:50 +02:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
2018-09-14 05:20:02 +02:00
2020-10-17 11:19:50 +02:00
# Start a systemd service
2020-10-17 13:52:59 +02:00
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 12:08:40 +02:00
|
2020-10-17 13:52:59 +02:00
|port: $squid_port
2020-10-17 12:08:40 +02:00
|
2020-10-17 11:19:50 +02:00
|Tick mark use this proxy server for all protocols
2020-10-17 12:08:40 +02:00
|
2020-10-17 11:19:50 +02:00
|No proxy for: localhost, 127.0.0.1
2020-10-17 12:08:40 +02:00
|
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"
2018-09-14 05:20:02 +02:00
2020-10-17 11:19:50 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2018-09-14 05:20:02 +02:00
2020-10-17 11:19:50 +02:00
ynh_script_progression --message="Installation of $app completed"