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

Merge branch 'only_squid'

This commit is contained in:
anmol26s 2018-10-02 13:15:05 +05:30
commit 4bec853736
6 changed files with 83 additions and 24 deletions

View file

@ -21,7 +21,7 @@ acl purge method PURGE
acl CONNECT method CONNECT acl CONNECT method CONNECT
###Directive pour nautoriser que les comptes enregistrés dans le LDAP de Yunohost ###Directive pour nautoriser que les comptes enregistrés dans le LDAP de Yunohost
auth_param basic program /usr/lib/squid3/basic_ldap_auth -b dc=yunohost,dc=org -h 127.0.0.1 -f "uid=%s" auth_param basic program /usr/lib/__SQUID__/basic_ldap_auth -b dc=yunohost,dc=org -h 127.0.0.1 -f "uid=%s"
auth_param basic children 50 auth_param basic children 50
auth_param basic realm Web-Proxy auth_param basic realm Web-Proxy
@ -44,9 +44,9 @@ dns_nameservers 127.0.0.1
##Port d'écoute du Proxy ##Port d'écoute du Proxy
http_port __PORT__ http_port __PORT__
forwarded_for off ### mode transparant, la vrai IP est cachée forwarded_for off ### mode transparant, la vrai IP est cachée
cache_dir aufs /var/spool/squid3 10000 16 256 cache_dir aufs /var/spool/__SQUID__ 10000 16 256
hierarchy_stoplist cgi-bin ? hierarchy_stoplist cgi-bin ?
access_log /var/log/squid3/access.log squid access_log /var/log/__SQUID__/access.log squid
refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0

View file

@ -25,10 +25,10 @@ ynh_abort_if_errors
#================================================= #=================================================
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
squid=$(ynh_app_setting_get $app squid_folder)
#================================================= #=================================================
# BACKUP OF THE CONFIG OF SQUID3 # 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. ### `ynh_replace_string` is used to replace a string in a file.
### (It's compatible with sed regular expressions syntax) ### (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"
# 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
ynh_replace_string "__PORT__" "$port" "../conf/squid.conf"
ynh_replace_string "__SQUID__" "$squid" "../conf/squid.conf"
cp -f "../conf/squid.conf" "/etc/$squid/."
# Save squid folder
ynh_app_setting_set $app squid_folder $squid
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # 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. ### 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 # 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 ### - 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 ### - 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 # RESTART SQUID'S SERVICE and SSOWATCONF
#================================================= #=================================================
service squid3 restart service $squid restart
yunohost app ssowatconf yunohost app ssowatconf
#================================================= #=================================================
# SEND A README FOR THE ADMIN # 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. 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. 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 app=$YNH_APP_INSTANCE_NAME
port=$(ynh_app_setting_get $app port) 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` # Remove a service from the admin panel, added by `yunohost service add`
if yunohost service status | grep -q $app if yunohost service status | grep -q $app
then then
echo "Remove $app service" echo "Remove $squid service"
yunohost service remove $app yunohost service remove $app
fi fi

View file

@ -44,25 +44,47 @@ ynh_install_app_dependencies squid3 mailutils
yunohost firewall allow --no-upnp TCP $port 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 # RESTORE INOTIFY'S CONFIG
#================================================= #=================================================
ynh_secure_remove "/etc/squid3/squid.conf" ynh_secure_remove "/etc/$squid/squid.conf"
ynh_restore_file "/etc/squid3/squid.conf" ynh_restore_file "/etc/$squid/squid.conf"
service squid3 restart service $squid restart
yunohost app ssowatconf yunohost app ssowatconf
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # 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 # 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. 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. To configure on Firefox go to preferences->general->network proxy->manual proxy configuration.

View file

@ -53,8 +53,26 @@ yunohost firewall allow --no-upnp TCP $port
### `ynh_replace_string` is used to replace a string in a file. ### `ynh_replace_string` is used to replace a string in a file.
### (It's compatible with sed regular expressions syntax) ### (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"
# 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
ynh_replace_string "__PORT__" "$port" "../conf/squid.conf"
ynh_replace_string "__SQUID__" "$squid" "../conf/squid.conf"
cp -f "../conf/squid.conf" "/etc/$squid/."
# Save squid folder
ynh_app_setting_set $app squid_folder $squid
#================================================= #=================================================
@ -63,9 +81,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. ### 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. ### 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. # 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 # ADVERTISE SERVICE IN ADMIN PANEL
@ -79,12 +97,12 @@ ynh_store_file_checksum "/etc/squid3/squid.conf"
### - Remove the section "REMOVE SERVICE FROM ADMIN PANEL" in the remove script ### - 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 ### - 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 # RESTART SQUID'S SERVICE and SSOWATCONF
#================================================= #=================================================
service squid3 restart service $squid restart
yunohost app ssowatconf yunohost app ssowatconf