mirror of
https://github.com/YunoHost-Apps/squid3_ynh.git
synced 2024-09-03 20:26:11 +02:00
first commit
This commit is contained in:
parent
dc7bb343be
commit
3c7bc5b4fe
8 changed files with 472 additions and 0 deletions
37
check_process
Normal file
37
check_process
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# See here for more information
|
||||||
|
# https://github.com/YunoHost/package_check#syntax-check_process-file
|
||||||
|
|
||||||
|
# Move this file from check_process.default to check_process when you have filled it.
|
||||||
|
|
||||||
|
;; Test complet
|
||||||
|
; Manifest
|
||||||
|
password="pass"
|
||||||
|
; Checks
|
||||||
|
pkg_linter=1
|
||||||
|
setup_sub_dir=0
|
||||||
|
setup_root=0
|
||||||
|
setup_nourl=0
|
||||||
|
setup_private=0
|
||||||
|
setup_public=0
|
||||||
|
upgrade=0
|
||||||
|
backup_restore=1
|
||||||
|
multi_instance=0
|
||||||
|
incorrect_path=0
|
||||||
|
port_already_use=1
|
||||||
|
change_url=0
|
||||||
|
;;; Levels
|
||||||
|
Level 1=auto
|
||||||
|
Level 2=auto
|
||||||
|
Level 3=auto
|
||||||
|
# Level 4: If the app supports LDAP and SSOwat, turn level 4 to '1' and add a link to an issue or a part of your code to show it.
|
||||||
|
# If the app does not use LDAP nor SSOwat, and can't use them, turn level 4 to 'na' and explain as well.
|
||||||
|
Level 4=na
|
||||||
|
Level 5=auto
|
||||||
|
Level 6=auto
|
||||||
|
Level 7=auto
|
||||||
|
Level 8=0
|
||||||
|
Level 9=0
|
||||||
|
Level 10=0
|
||||||
|
;;; Options
|
||||||
|
Email=anmol@datamol.org
|
||||||
|
Notification=yes
|
54
conf/squid.conf
Normal file
54
conf/squid.conf
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
|
||||||
|
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
|
||||||
|
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
|
||||||
|
acl SSL_ports port 443 # https
|
||||||
|
acl SSL_ports port 563 # snews
|
||||||
|
acl SSL_ports port 873 # rsync
|
||||||
|
acl Safe_ports port 80 # http
|
||||||
|
acl Safe_ports port 21 # ftp
|
||||||
|
acl Safe_ports port 443 # https
|
||||||
|
acl Safe_ports port 70 # gopher
|
||||||
|
acl Safe_ports port 210 # wais
|
||||||
|
acl Safe_ports port 1025-65535 # unregistered ports
|
||||||
|
acl Safe_ports port 280 # http-mgmt
|
||||||
|
acl Safe_ports port 488 # gss-http
|
||||||
|
acl Safe_ports port 591 # filemaker
|
||||||
|
acl Safe_ports port 777 # multiling http
|
||||||
|
acl Safe_ports port 631 # cups
|
||||||
|
acl Safe_ports port 873 # rsync
|
||||||
|
acl Safe_ports port 901 # SWAT
|
||||||
|
acl purge method PURGE
|
||||||
|
acl CONNECT method CONNECT
|
||||||
|
|
||||||
|
###Directive pour n’autoriser que les comptes enregistrés dans le LDAP de Yunohost
|
||||||
|
auth_param basic program /usr/lib/squid/basic_ldap_auth -b dc=yunohost,dc=org -h 127.0.0.1 -D cn=admin,dc=yunohost,dc=org -w __ADMIN_PASS__ -f "uid=%s"
|
||||||
|
|
||||||
|
auth_param basic children 50
|
||||||
|
auth_param basic realm Web-Proxy
|
||||||
|
auth_param basic credentialsttl 1 minute
|
||||||
|
acl ldap_auth proxy_auth REQUIRED
|
||||||
|
|
||||||
|
visible_hostname web-proxy
|
||||||
|
http_access allow ldap_auth
|
||||||
|
http_access allow manager localhost
|
||||||
|
http_access deny manager
|
||||||
|
http_access allow purge localhost
|
||||||
|
http_access deny purge
|
||||||
|
http_access deny !Safe_ports
|
||||||
|
http_access deny CONNECT !SSL_ports
|
||||||
|
http_access allow localhost
|
||||||
|
http_access deny all
|
||||||
|
|
||||||
|
##cache DNS en local
|
||||||
|
dns_nameservers 127.0.0.1
|
||||||
|
##Port d'écoute du Proxy
|
||||||
|
http_port __PORT__
|
||||||
|
forwarded_for off ### mode transparant, la vrai IP est cachée
|
||||||
|
cache_dir aufs /var/spool/squid 10000 16 256
|
||||||
|
hierarchy_stoplist cgi-bin ?
|
||||||
|
access_log /var/log/squid/access.log squid
|
||||||
|
refresh_pattern ^ftp: 1440 20% 10080
|
||||||
|
refresh_pattern ^gopher: 1440 0% 1440
|
||||||
|
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
|
||||||
|
refresh_pattern (Release|Packages(.gz)*)$ 0 20% 2880
|
||||||
|
refresh_pattern . 0 20% 4320
|
35
manifest.json
Normal file
35
manifest.json
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
"name": "squid3",
|
||||||
|
"id": "squid",
|
||||||
|
"packaging_format": 1,
|
||||||
|
"description": {
|
||||||
|
"en": "Squid 3 package for Yunohost"
|
||||||
|
},
|
||||||
|
"version": "1.0~ynh1",
|
||||||
|
"url": "http://www.squid-cache.org/",
|
||||||
|
"license": "free",
|
||||||
|
"maintainer": {
|
||||||
|
"name": "Anmol Sharma",
|
||||||
|
"email": "anmol@datamol.org"
|
||||||
|
},
|
||||||
|
"requirements": {
|
||||||
|
"yunohost": ">= 2.7.14"
|
||||||
|
},
|
||||||
|
"multi_instance": false,
|
||||||
|
"services": [],
|
||||||
|
"arguments": {
|
||||||
|
"install" : [
|
||||||
|
{
|
||||||
|
"name": "password",
|
||||||
|
"type": "password",
|
||||||
|
"ask": {
|
||||||
|
"en": "Your Yunohost admin password (The password you use for the web-admin for Yunohost) "
|
||||||
|
},
|
||||||
|
"help": {
|
||||||
|
"en": "The admin password is required to give all registered user access to Squid"
|
||||||
|
},
|
||||||
|
"example": "Choose a password"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
33
scripts/_common.sh
Normal file
33
scripts/_common.sh
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# ============= FUTURE YUNOHOST HELPER =============
|
||||||
|
# Delete a file checksum from the app settings
|
||||||
|
#
|
||||||
|
# $app should be defined when calling this helper
|
||||||
|
#
|
||||||
|
# usage: ynh_remove_file_checksum file
|
||||||
|
# | arg: file - The file for which the checksum will be deleted
|
||||||
|
ynh_delete_file_checksum () {
|
||||||
|
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
||||||
|
ynh_app_setting_delete $app $checksum_setting_name
|
||||||
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Send an email to inform the administrator
|
||||||
|
#
|
||||||
|
# usage: ynh_send_readme_to_admin app_message [recipients]
|
||||||
|
# | arg: -m --app_message= - The message to send to the administrator.
|
||||||
|
# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root
|
||||||
|
# example: "root admin@domain"
|
||||||
|
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
|
||||||
|
# example: "root admin@domain user1 user2"
|
||||||
|
ynh_send_readme_to_admin() {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
declare -Ar args_array=( [m]=app_message= [r]=recipients= )
|
||||||
|
local app_message
|
||||||
|
local recipients
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
local app_message="${app_message:-...No specific information...}"
|
||||||
|
local recipients="${recipients:-root}"
|
34
scripts/backup
Executable file
34
scripts/backup
Executable file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source ../settings/scripts/_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
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP OF THE CONFIG OF SQUID3
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup "/etc/squid/squid.conf"
|
147
scripts/install
Executable file
147
scripts/install
Executable file
|
@ -0,0 +1,147 @@
|
||||||
|
#!/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
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
admin_pass_yuno=$YNH_APP_ARG_PASSWORD
|
||||||
|
|
||||||
|
|
||||||
|
### If it's a multi-instance app, meaning it can be installed several times independently
|
||||||
|
### The id of the app as stated in the manifest is available as $YNH_APP_ID
|
||||||
|
### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
||||||
|
### The app instance name is available as $YNH_APP_INSTANCE_NAME
|
||||||
|
### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
||||||
|
### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
||||||
|
### - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
||||||
|
### The app instance name is probably what interests you most, since this is
|
||||||
|
### guaranteed to be unique. This is a good unique identifier to define installation path,
|
||||||
|
### db names, ...
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STORE SETTINGS FROM MANIFEST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# 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
|
||||||
|
|
||||||
|
ynh_install_app_dependencies squid3
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# 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"
|
||||||
|
cp -f "../conf/squid.conf" "/etc/squid/squid.conf"
|
||||||
|
#=================================================
|
||||||
|
# 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
|
||||||
|
ynh_store_file_checksum "/etc/squid/squid.conf"
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# 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
|
||||||
|
|
||||||
|
yunohost service add squid --log "/var/log/squid/access.log"
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTART SQUID'S SERVICE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_system_reload --service_name=squid --action=restart
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SEND A README FOR THE ADMIN
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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"
|
47
scripts/remove
Executable file
47
scripts/remove
Executable file
|
@ -0,0 +1,47 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
port=$(ynh_app_setting_get $app port)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Remove a service from the admin panel, added by `yunohost service add`
|
||||||
|
if yunohost service status | grep -q $app
|
||||||
|
then
|
||||||
|
echo "Remove $app service"
|
||||||
|
yunohost service remove $app
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Remove metapackage and its dependencies
|
||||||
|
apt-get -y purge squid3
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CLOSE A PORT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if yunohost firewall list | grep -q "\- $port$"
|
||||||
|
then
|
||||||
|
echo "Close port $port" >&2
|
||||||
|
yunohost firewall disallow TCP $port 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
85
scripts/restore
Executable file
85
scripts/restore
Executable file
|
@ -0,0 +1,85 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source ../settings/scripts/_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
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
port=$(ynh_app_setting_get $app port)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC RESTORATION
|
||||||
|
#=================================================
|
||||||
|
# REINSTALL DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_install_app_dependencies squid3
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC RESTORE
|
||||||
|
#=================================================
|
||||||
|
# OPEN PORTS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
yunohost firewall allow --no-upnp TCP $port
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE INOTIFY'S CONFIG
|
||||||
|
#=================================================
|
||||||
|
ynh_secure_remove "/etc/squid/squid.conf"
|
||||||
|
ynh_restore_file "/etc/squid/squid.conf"
|
||||||
|
ynh_system_reload --service_name=squid --action=restart
|
||||||
|
#=================================================
|
||||||
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
yunohost service add squid --log "/var/log/squid/access.log"
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SEND A README FOR THE ADMIN
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue