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
2020-10-17 13:00:27 +02:00
new_port=""
2018-10-04 17:22:43 +02:00
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 13:00:27 +02:00
ynh_app_setting_set --app=$app --key=new_port --value=$new_port
2020-10-17 11:19:50 +02:00
# Open the port
2020-10-17 13:52:59 +02:00
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
#=================================================
# MODIFY A CONFIG FILE
#=================================================
2020-10-17 11:19:50 +02:00
# See if squid3 folder exits
if [ -d "/etc/squid3" ]; then
2018-09-28 12:38:03 +02: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
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
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
2020-10-17 13:52:59 +02:00
ynh_replace_string --match_string="__PORT__" --replace_string="$squid_port" --target_file="../conf/squid.conf"
2020-10-17 11:19:50 +02:00
ynh_replace_string --match_string="__SQUID__" --replace_string="$squid" --target_file="../conf/squid.conf"
2018-09-28 12:52:49 +02:00
cp -f "../conf/squid.conf" "/etc/$squid/."
2020-10-17 11:19:50 +02:00
# Save squid folder in app settings
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
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
# Calculate and store the config file checksum into the app settings
2020-10-17 11:19:50 +02:00
ynh_store_file_checksum --file="/etc/$squid/squid.conf"
2018-09-14 05:20:02 +02:00
2020-10-17 11:19:50 +02:00
#=================================================
# 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"
#=================================================
# 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
2018-09-14 07:02:29 +02:00
yunohost app ssowatconf
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"