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

Fix restore + cleaning up

This commit is contained in:
ericgaspar 2020-11-08 11:26:35 +01:00
parent 61e7bd93da
commit 5cb8b26e96
No known key found for this signature in database
GPG key ID: 574F281483054D44
10 changed files with 27 additions and 137 deletions

View file

@ -1,14 +1,8 @@
# Squid3 Proxy for Yunohost with LDAP # Squid3 Proxy for Yunohost with LDAP
[![Integration level](https://dash.yunohost.org/integration/squid3.svg)](https://dash.yunohost.org/appci/app/squid3) ![](https://ci-apps.yunohost.org/ci/badges/squid3.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/squid3.maintain.svg) [![Integration level](https://dash.yunohost.org/integration/squid3.svg)](https://dash.yunohost.org/appci/app/squid3) ![](https://ci-apps.yunohost.org/ci/badges/squid3.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/squid3.maintain.svg)
[![Install Squid3 with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=squid3) [![Install Squid3 with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=squid3)
## Interesting links
- [YunoHost project](https://yunohost.org)
- [Squid website](http://www.squid-cache.org/)
## Squid: Proxy with Optimising Web Delivery ## Squid: Proxy with Optimising Web Delivery
Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-requested web pages. Squid has extensive access controls and makes a great server accelerator. Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-requested web pages. Squid has extensive access controls and makes a great server accelerator.
@ -32,9 +26,15 @@ Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It r
If you try Squid 3 in any other way please write the instruction in the issue so that I can add it to the readme If you try Squid 3 in any other way please write the instruction in the issue so that I can add it to the readme
## Special Thanks ## Special Thanks
Thanks to **Fred** to write the instruction to configure Squid for Yunohost. French: https://memo-linux.com/installer-squid3-sur-un-serveur-yunohost/ Thanks to **Fred** to write the instruction to configure Squid for YunoHost. French: https://memo-linux.com/installer-squid3-sur-un-serveur-yunohost/
#### Supported architectures #### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/squid3%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/squid3/) * x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/squid3%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/squid3/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/squid3%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/squid3/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/squid3%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/squid3/)
## Links
* Report a bug: https://github.com/YunoHost-Apps/squid3_ynh/issues
* App website: http://www.squid-cache.org/
* YunoHost website: https://yunohost.org/

View file

@ -7,7 +7,7 @@ about: When creating a bug report, please use the following template to provide
**How to post a meaningful bug report** **How to post a meaningful bug report**
1. *Read this whole template first.* 1. *Read this whole template first.*
2. *Make sure you are on the right place:* 2. *Make sure you are on the right place:*
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!* - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
- *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.* - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
- *In doubt, ask here and we will figure it out together.* - *In doubt, ask here and we will figure it out together.*
3. *Delete these italic comments as you write over them below, and remove this guide.* 3. *Delete these italic comments as you write over them below, and remove this guide.*
@ -31,7 +31,7 @@ about: When creating a bug report, please use the following template to provide
- *If you performed a command from the CLI, the command itself is enough. For example:* - *If you performed a command from the CLI, the command itself is enough. For example:*
```sh ```sh
sudo yunohost app install REPLACEBYYOURAPP sudo yunohost app install squid3
``` ```
- *If you used the webadmin, please perform the equivalent command from the CLI first.* - *If you used the webadmin, please perform the equivalent command from the CLI first.*
- *If the error occurs in your browser, explain what you did:* - *If the error occurs in your browser, explain what you did:*

View file

@ -8,13 +8,13 @@
}, },
"version": "1.0~ynh2", "version": "1.0~ynh2",
"url": "http://www.squid-cache.org/", "url": "http://www.squid-cache.org/",
"license": "GPL v2", "license": "GPL-2.0-only",
"maintainer": { "maintainer": {
"name": "Anmol Sharma", "name": "Anmol Sharma",
"email": "anmol@datamol.org" "email": "anmol@datamol.org"
}, },
"requirements": { "requirements": {
"yunohost": ">= 3.5.0" "yunohost": ">= 3.8.1"
}, },
"multi_instance": false, "multi_instance": false,
"services": [], "services": [],

View file

@ -15,4 +15,4 @@
--- ---
*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* *If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results*
[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/REPLACEBYYOURAPP_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/REPLACEBYYOURAPP_ynh%20PR-NUM-%20(USERNAME)/) [![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/squid3_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/squid3_ynh%20PR-NUM-%20(USERNAME)/)

View file

@ -7,19 +7,9 @@
# dependencies used by the app # dependencies used by the app
pkg_dependencies="squid3 mailutils" pkg_dependencies="squid3 mailutils"
# ============= FUTURE YUNOHOST HELPER ============= #=================================================
# Delete a file checksum from the app settings # FUTURE OFFICIAL HELPERS
# #=================================================
# $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
}
#!/bin/bash
# Send an email to inform the administrator # Send an email to inform the administrator
# #

View file

@ -6,23 +6,20 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source _common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # 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 # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
squid=$(ynh_app_setting_get $app squid_folder) squid=$(ynh_app_setting_get $app squid_folder)

View file

@ -13,10 +13,6 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # 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 # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -27,16 +23,6 @@ ynh_abort_if_errors
squid_port=$YNH_APP_ARG_SQUID_PORT squid_port=$YNH_APP_ARG_SQUID_PORT
new_port="" new_port=""
### 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 app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
@ -46,20 +32,11 @@ app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
ynh_script_progression --message="Configuring firewall..." ynh_script_progression --message="Configuring firewall..."
### 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 an available port # Find an available port
squid_port=$(ynh_find_port --port=$squid_port) squid_port=$(ynh_find_port --port=$squid_port)
ynh_app_setting_set --app=$app --key=squid_port --value=$squid_port ynh_app_setting_set --app=$app --key=squid_port --value=$squid_port
ynh_app_setting_set --app=$app --key=new_port --value=$new_port ynh_app_setting_set --app=$app --key=new_port --value=$new_port
# Optional: Expose this port publicly
# (N.B. : you only need to do this if the app actually needs to expose the port publicly.
# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !)
# Open the port # Open the port
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $squid_port ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $squid_port
@ -68,23 +45,12 @@ ynh_app_setting_set --app=$app --key=new_port --value=$new_port
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." ynh_script_progression --message="Installing 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
### - Remove the variable "pkg_dependencies" in _common.sh
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# MODIFY A CONFIG FILE # 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 if squid3 folder exits # See if squid3 folder exits
if [ -d "/etc/squid3" ]; then if [ -d "/etc/squid3" ]; then
squid="squid3" squid="squid3"
@ -105,66 +71,24 @@ cp -f "../conf/squid.conf" "/etc/$squid/."
ynh_app_setting_set --app=$app --key=squid_folder --value=$squid ynh_app_setting_set --app=$app --key=squid_folder --value=$squid
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # 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 # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="/etc/$squid/squid.conf" ynh_store_file_checksum --file="/etc/$squid/squid.conf"
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
### `yunohost service add` integrates a service in YunoHost. It then gets
### displayed in the admin interface and through the others `yunohost service` commands.
### (N.B. : this line only makes sense if the app adds a service to the system!)
### If you're not using these lines:
### - You can remove these files in conf/.
### - Remove the section "REMOVE SERVICE INTEGRATION IN YUNOHOST" in the remove script
### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script
### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script
yunohost service add $app --description "Squid3 a web proxy service" --log "/var/log/$squid/access.log" yunohost service add $app --description "Squid3 a web proxy service" --log "/var/log/$squid/access.log"
### Additional options starting with 3.8:
###
### --needs_exposed_ports "$port" a list of ports that needs to be publicly exposed
### which will then be checked by YunoHost's diagnosis system
### (N.B. DO NOT USE THIS is the port is only internal !!!)
###
### --test_status "some command" a custom command to check the status of the service
### (only relevant if 'systemctl status' doesn't do a good job)
###
### --test_conf "some command" some command similar to "nginx -t" that validates the conf of the service
###
### Re-calling 'yunohost service add' during the upgrade script is the right way
### to proceed if you later realize that you need to enable some flags that
### weren't enabled on old installs (be careful it'll override the existing
### service though so you should re-provide all relevant flags when doing so)
###
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression --message="Starting a systemd service..."
### `ynh_systemd_action` is used to start a systemd service for an app.
### Only needed if you have configure a systemd service
### If you're not using these lines:
### - Remove the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the backup script
### - As well as the section "START SYSTEMD SERVICE" in the restore script
### - As well as the section"STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the upgrade script
### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$squid --action="restart" --log_path="/var/log/$squid/cache.log" ynh_systemd_action --service_name=$squid --action="restart" --log_path="/var/log/$squid/cache.log"

View file

@ -13,7 +13,9 @@ source /usr/share/yunohost/helpers
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
squid_port=$(ynh_app_setting_get $app squid_port) squid_port=$(ynh_app_setting_get $app squid_port)
squid=$(ynh_app_setting_get $app squid_folder) squid=$(ynh_app_setting_get $app squid_folder)

View file

@ -6,17 +6,13 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source _common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # 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 # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -41,9 +37,6 @@ ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# OPEN PORTS # OPEN PORTS
#================================================= #=================================================
# Optional: Expose this port publicly
# (N.B. : you only need to do this if the app actually needs to expose the port publicly.
# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !)
# Find an available port # Find an available port
squid_port=$(ynh_find_port --port=$squid_port) squid_port=$(ynh_find_port --port=$squid_port)
@ -54,9 +47,6 @@ ynh_install_app_dependencies $pkg_dependencies
# MODIFY A CONFIG FILE # 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 # See is squid3 folder is there
if [ -d "/etc/squid3" ]; then if [ -d "/etc/squid3" ]; then
squid="squid3" squid="squid3"
@ -85,7 +75,6 @@ yunohost app ssowatconf
yunohost service add squid3 --log "/var/log/$squid/cache.log" yunohost service add squid3 --log "/var/log/$squid/cache.log"
#================================================= #=================================================
# SEND A README FOR THE ADMIN # SEND A README FOR THE ADMIN
#================================================= #=================================================

View file

@ -31,7 +31,6 @@ ynh_clean_setup () {
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================
@ -65,7 +64,6 @@ else
ynh_app_setting_set --app=$app --key=new_port --value="" ynh_app_setting_set --app=$app --key=new_port --value=""
fi fi
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
@ -96,8 +94,6 @@ cp -f "../conf/squid.conf" "/etc/$squid/."
# Save squid folder # Save squid folder
ynh_app_setting_set --app=$app --key=squid_folder --value=$squid ynh_app_setting_set --app=$app --key=squid_folder --value=$squid
# 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 --file="/etc/$squid/squid.conf" ynh_store_file_checksum --file="/etc/$squid/squid.conf"
@ -105,14 +101,6 @@ ynh_store_file_checksum --file="/etc/$squid/squid.conf"
# ADVERTISE SERVICE IN ADMIN PANEL # 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 squid3 --log "/var/log/$squid/cache.log" yunohost service add squid3 --log "/var/log/$squid/cache.log"
#================================================= #=================================================