1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/squid3_ynh.git synced 2024-09-03 20:26:11 +02:00

Check correct squid folder in /etc

This commit is contained in:
anmol26s 2018-09-28 16:08:03 +05:30
parent f3b787e662
commit 7d561eaeb8
5 changed files with 79 additions and 21 deletions

View file

@ -25,10 +25,10 @@ ynh_abort_if_errors
#=================================================
app=$YNH_APP_INSTANCE_NAME
squid=$(ynh_app_setting_get $app squid_folder)
#=================================================
# BACKUP OF THE CONFIG OF SQUID3
#=================================================
ynh_backup "/etc/squid3/squid.conf"
ynh_backup "/etc/$squid/squid.conf"

View file

@ -62,8 +62,27 @@ ynh_install_app_dependencies squid3 mailutils
### `ynh_replace_string` is used to replace a string in a file.
### (It's compatible with sed regular expressions syntax)
ynh_replace_string "__PORT__" "$port" "../conf/squid.conf"
cp -f "../conf/squid.conf" "/etc/squid3/."
# See is squid3 folder is there
if [ -d "/etc/squid3" ]; then
squid="squid3"
ynh_replace_string "__PORT__" "$port" "../conf/squid.conf"
cp -f "../conf/squid.conf" "/etc/squid3/."
# If squid3 folder is not found look for squid folder
elif [ -d "/etc/squid" ]; then
squid="squid"
ynh_replace_string "__PORT__" "$port" "../conf/squid.conf"
cp -f "../conf/squid.conf" "/etc/squid/."
# If both folders are not found then call ynh_die
else
ynh_die "No squid folder found in /etc. Looks like squid 3 package is not installed. Try installing it manually by apt-get install squid3"
fi
# Save squid folder
ynh_app_setting_set $app squid_folder $squid
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
@ -73,7 +92,7 @@ cp -f "../conf/squid.conf" "/etc/squid3/."
### 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
ynh_store_file_checksum "/etc/squid3/squid.conf"
ynh_store_file_checksum "/etc/$squid/squid.conf"
#=================================================
@ -88,21 +107,21 @@ ynh_store_file_checksum "/etc/squid3/squid.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
yunohost service add squid3 --log "/var/log/squid3/access.log"
yunohost service add squid3 --log "/var/log/$squid/access.log"
#=================================================
# RESTART SQUID'S SERVICE and SSOWATCONF
#=================================================
service squid3 restart
service $squid restart
yunohost app ssowatconf
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
message="You can find a config file at /etc/squid3/squid.conf
message="You can find a config file at /etc/$squid/squid.conf
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.

View file

@ -15,14 +15,14 @@ source /usr/share/yunohost/helpers
app=$YNH_APP_INSTANCE_NAME
port=$(ynh_app_setting_get $app port)
squid=$(ynh_app_setting_get $app squid_folder)
# Remove a service from the admin panel, added by `yunohost service add`
if yunohost service status | grep -q $app
then
echo "Remove $app service"
echo "Remove $squid service"
yunohost service remove $app
fi

View file

@ -44,25 +44,47 @@ ynh_install_app_dependencies squid3 mailutils
yunohost firewall allow --no-upnp TCP $port
#=================================================
# 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
if [ -d "/etc/squid3" ]; then
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
ynh_die "No squid folder found in /etc. Looks like squid 3 package is not installed. Try installing it manually by apt-get install squid3"
fi
# Save squid folder
ynh_app_setting_set $app squid_folder $squid
#=================================================
# RESTORE INOTIFY'S CONFIG
#=================================================
ynh_secure_remove "/etc/squid3/squid.conf"
ynh_restore_file "/etc/squid3/squid.conf"
service squid3 restart
ynh_secure_remove "/etc/$squid/squid.conf"
ynh_restore_file "/etc/$squid/squid.conf"
service $squid restart
yunohost app ssowatconf
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add squid3 --log "/var/log/squid3/access.log"
yunohost service add squid3 --log "/var/log/$squid/access.log"
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
message="You can find a config file at /etc/squid3/squid.conf
message="You can find a config file at /etc/$squid/squid.conf
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.

View file

@ -53,8 +53,25 @@ yunohost firewall allow --no-upnp TCP $port
### `ynh_replace_string` is used to replace a string in a file.
### (It's compatible with sed regular expressions syntax)
ynh_replace_string "__PORT__" "$port" "../conf/squid.conf"
cp -f "../conf/squid.conf" "/etc/squid3/squid.conf"
# See is squid3 folder is there
if [ -d "/etc/squid3" ]; then
squid="squid3"
ynh_replace_string "__PORT__" "$port" "../conf/squid.conf"
cp -f "../conf/squid.conf" "/etc/squid3/."
# If squid3 folder is not found look for squid folder
elif [ -d "/etc/squid" ]; then
squid="squid"
ynh_replace_string "__PORT__" "$port" "../conf/squid.conf"
cp -f "../conf/squid.conf" "/etc/squid/."
# If both folders are not found then call ynh_die
else
ynh_die "No squid folder found in /etc. Looks like squid 3 package is not installed. Try installing it manually by apt-get install squid3"
fi
# Save squid folder
ynh_app_setting_set $app squid_folder $squid
#=================================================
@ -63,9 +80,9 @@ cp -f "../conf/squid.conf" "/etc/squid3/squid.conf"
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
ynh_backup_if_checksum_is_different "/etc/squid3/squid.conf"
ynh_backup_if_checksum_is_different "/etc/$squid/squid.conf"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum "/etc/squid3/squid.conf"
ynh_store_file_checksum "/etc/$squid/squid.conf"
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
@ -79,12 +96,12 @@ ynh_store_file_checksum "/etc/squid3/squid.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
yunohost service add squid3 --log "/var/log/squid3/access.log"
yunohost service add squid3 --log "/var/log/$squid/access.log"
#=================================================
# RESTART SQUID'S SERVICE and SSOWATCONF
#=================================================
service squid3 restart
service $squid restart
yunohost app ssowatconf