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
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
|
|
|
# FIND AND OPEN A PORT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
### Use these lines if you have to open a port for the application
|
|
|
|
### `ynh_find_port` will find the first available port starting from the given port.
|
|
|
|
### If you're not using these lines:
|
|
|
|
### - Remove the section "CLOSE A PORT" in the remove script
|
|
|
|
|
|
|
|
# Find a free port
|
|
|
|
port=$(ynh_find_port 3128)
|
|
|
|
# Open this port
|
|
|
|
yunohost firewall allow --no-upnp TCP $port 2>&1
|
|
|
|
ynh_app_setting_set $app port $port
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
|
|
|
|
### Those deb packages will be installed as dependencies of this package.
|
|
|
|
### If you're not using this helper:
|
|
|
|
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
|
|
|
|
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
|
|
|
|
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
|
|
|
|
2018-09-14 07:02:29 +02:00
|
|
|
ynh_install_app_dependencies squid3 mailutils
|
2018-09-14 05:20:02 +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)
|
|
|
|
|
|
|
|
ynh_replace_string "__ADMIN_PASS__" "$admin_pass_yuno" "../conf/squid.conf"
|
|
|
|
ynh_replace_string "__PORT__" "$port" "../conf/squid.conf"
|
2018-09-14 05:35:17 +02:00
|
|
|
cp -f "../conf/squid.conf" "/etc/squid3/."
|
2018-09-14 05:20:02 +02:00
|
|
|
#=================================================
|
|
|
|
# STORE THE CONFIG FILE CHECKSUM
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
### `ynh_store_file_checksum` is used to store the checksum of a file.
|
|
|
|
### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`,
|
|
|
|
### you can make a backup of this file before modifying it again if the admin had modified it.
|
|
|
|
|
|
|
|
# Calculate and store the config file checksum into the app settings
|
2018-09-14 05:35:17 +02:00
|
|
|
ynh_store_file_checksum "/etc/squid3/squid.conf"
|
2018-09-14 05:20:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
### `yunohost service add` is a CLI yunohost command to add a service in the admin panel.
|
|
|
|
### You'll find the service in the 'services' section of YunoHost admin panel.
|
|
|
|
### This CLI command would be useless if the app does not have any services (systemd or sysvinit)
|
|
|
|
### If you're not using these lines:
|
|
|
|
### - You can remove these files in conf/.
|
|
|
|
### - Remove the section "REMOVE SERVICE FROM ADMIN PANEL" in the remove script
|
|
|
|
### - As well as the section ADVERTISE SERVICE IN ADMIN PANEL" in the restore script
|
|
|
|
|
2018-09-14 07:02:29 +02:00
|
|
|
yunohost service add squid3 --log "/var/log/squid3/access.log"
|
2018-09-14 05:20:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
2018-09-14 07:02:29 +02:00
|
|
|
# RESTART SQUID'S SERVICE and SSOWATCONF
|
2018-09-14 05:20:02 +02:00
|
|
|
#=================================================
|
|
|
|
|
2018-09-14 05:39:57 +02:00
|
|
|
service squid3 restart
|
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
|
|
|
|
#=================================================
|
|
|
|
|
2018-09-14 05:35:17 +02:00
|
|
|
message="You can find a config file at /etc/squid3/squid.conf
|
2018-09-14 05:20:02 +02:00
|
|
|
Squid 3 will work with your registered users. 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
|
|
|
|
|
|
|
|
port: $port
|
|
|
|
|
|
|
|
Tick mark use this proxy server for all protocols
|
|
|
|
|
|
|
|
No proxy for: localhost, 127.0.0.1
|
|
|
|
|
|
|
|
Save and restart borwser.
|
|
|
|
|
|
|
|
If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/squid3_ynh/issues"
|
|
|
|
|
|
|
|
ynh_send_readme_to_admin --app_message="$message" --recipients="root"
|