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

Merge pull request #7 from YunoHost-Apps/example

Apply last example_ynh
This commit is contained in:
yalh76 2022-03-16 19:43:09 +01:00 committed by GitHub
commit 1e7790b600
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 265 additions and 152 deletions

View file

@ -6,11 +6,11 @@ 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. *Determine if 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.* - *When in doubt, post 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 the italic comments as you write over them below, and remove this guide.*
--- ---
### Describe the bug ### Describe the bug
@ -22,7 +22,7 @@ about: When creating a bug report, please use the following template to provide
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* - Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
- YunoHost version: x.x.x - YunoHost version: x.x.x
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* - I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?: *no / yes* - Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes*
- If yes, please explain: - If yes, please explain:
- Using, or trying to install package version/branch: - Using, or trying to install package version/branch:
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* - If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
@ -31,13 +31,13 @@ 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 squid3 sudo yunohost app install the_app
``` ```
- *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:*
1. *Go to '...'* 1. *Go to '...'*
2. *Click on '....'* 2. *Click on '...'*
3. *Scroll down to '....'* 3. *Scroll down to '...'*
4. *See error* 4. *See error*
### Expected behavior ### Expected behavior

16
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,16 @@
## Problem
- *Description of why you made this PR*
## Solution
- *And how do you fix that problem*
## PR Status
- [ ] Code finished and ready to be reviewed/tested
- [ ] The fix/enhancement were manually tested (if applicable)
## Automatic tests
Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization)

View file

@ -1,12 +1,31 @@
# Squid3 Proxy for Yunohost with LDAP <!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
-->
# squid3 for YunoHost
[![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.svg)](https://install-app.yunohost.org/?app=squid3)
*[Lire ce readme en français.](./README_fr.md)*
> *This package allows you to install squid3 quickly and simply on a YunoHost server.
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview
## 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.
**Shipped version:** 1.0~ynh3
## Disclaimers / important information
## Instruction ## Instruction
1. The app can not be **multi-instance**(can't be installed many times on same server). 1. The app can not be **multi-instance**(can't be installed many times on same server).
@ -28,13 +47,21 @@ If you try Squid 3 in any other way please write the instruction in the issue so
## 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 ## Documentation and resources
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/squid3%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/squid3/) * Official app website: http://www.squid-cache.org
* 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/) * YunoHost documentation for this app: https://yunohost.org/app_squid3
* Report a bug: https://github.com/YunoHost-Apps/squid3_ynh/issues
## Links ## Developer info
* Report a bug: https://github.com/YunoHost-Apps/squid3_ynh/issues Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/squid3_ynh/tree/testing).
* App website: http://www.squid-cache.org/
* YunoHost website: https://yunohost.org/ To try the testing branch, please proceed like that.
```
sudo yunohost app install https://github.com/YunoHost-Apps/squid3_ynh/tree/testing --debug
or
sudo yunohost app upgrade squid3 -u https://github.com/YunoHost-Apps/squid3_ynh/tree/testing --debug
```
**More info regarding app packaging:** https://yunohost.org/packaging_apps

63
README_fr.md Normal file
View file

@ -0,0 +1,63 @@
# squid3 pour YunoHost
[![Niveau d'intégration](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)
[![Installer squid3 avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=squid3)
*[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer squid3 rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
## Vue d'ensemble
## 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.
**Version incluse :** 1.0~ynh3
## Avertissements / informations importantes
## Instruction
1. The app can not be **multi-instance**(can't be installed many times on same server).
2. **LDAP** is there(Registered users can use there login username and password to browser internet through the proxy)
3. **Port number** used by the proxy will be sent to the **admin mail** of the Yunohost server.
4. The username and password is **asked twice** first time you start the browser(I have no idea why this happens).
## Configure Squid3 for Firefox
1. Go to **Preferences -> General -> network proxy**
1. Select **Manual proxy configuration**
1. In **HTTP Proxy** enter your **domain name or server IP** and in **Port** enter the port sent to your **admin email**.
1. Check **Use this proxy server for all protocols**.
1. Under **No Proxy for** enter this **localhost, 127.0.0.1**.
1. **Save and restart** the Firefox.
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
Thanks to **Fred** to write the instruction to configure Squid for YunoHost. French: https://memo-linux.com/installer-squid3-sur-un-serveur-yunohost/
## Documentations et ressources
* Site officiel de l'app : http://www.squid-cache.org
* Documentation YunoHost pour cette app : https://yunohost.org/app_squid3
* Signaler un bug : https://github.com/YunoHost-Apps/squid3_ynh/issues
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/squid3_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
```
sudo yunohost app install https://github.com/YunoHost-Apps/squid3_ynh/tree/testing --debug
ou
sudo yunohost app upgrade squid3 -u https://github.com/YunoHost-Apps/squid3_ynh/tree/testing --debug
```
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps

View file

@ -1,8 +1,3 @@
# 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 ;; Test complet
; Manifest ; Manifest
port="8095" (PORT) port="8095" (PORT)
@ -10,20 +5,16 @@
pkg_linter=1 pkg_linter=1
setup_sub_dir=0 setup_sub_dir=0
setup_root=0 setup_root=0
setup_nourl=0 setup_nourl=1
setup_private=0 setup_private=0
setup_public=0 setup_public=0
upgrade=1 upgrade=1
#upgrade=1 from_commit=CommitHash # 1.0~ynh2
upgrade=1 from_commit=e1920eb3c212ae8d09a6e2fd8188b2f93aed0707
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
# incorrect_path=1
port_already_use=0 port_already_use=0
change_url=0 change_url=0
;;; Levels
# If the level 5 (Package linter) is forced to 1. Please add justifications here.
Level 5=auto
;;; Options ;;; Options
Email=anmol@datamol.org Email=
Notification=yes Notification=none

View file

@ -42,7 +42,7 @@ http_access deny all
##cache DNS en local ##cache DNS en local
dns_nameservers 127.0.0.1 dns_nameservers 127.0.0.1
##Port d'écoute du Proxy ##Port d'écoute du Proxy
http_port __PORT__ http_port __SQUID_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/__SQUID__ 10000 16 256 cache_dir aufs /var/spool/__SQUID__ 10000 16 256
hierarchy_stoplist cgi-bin ? hierarchy_stoplist cgi-bin ?

0
doc/.gitkeep Normal file
View file

3
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1,3 @@
## 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.

20
doc/DISCLAIMER.md Normal file
View file

@ -0,0 +1,20 @@
## Instruction
1. The app can not be **multi-instance**(can't be installed many times on same server).
2. **LDAP** is there(Registered users can use there login username and password to browser internet through the proxy)
3. **Port number** used by the proxy will be sent to the **admin mail** of the Yunohost server.
4. The username and password is **asked twice** first time you start the browser(I have no idea why this happens).
## Configure Squid3 for Firefox
1. Go to **Preferences -> General -> network proxy**
1. Select **Manual proxy configuration**
1. In **HTTP Proxy** enter your **domain name or server IP** and in **Port** enter the port sent to your **admin email**.
1. Check **Use this proxy server for all protocols**.
1. Under **No Proxy for** enter this **localhost, 127.0.0.1**.
1. **Save and restart** the Firefox.
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
Thanks to **Fred** to write the instruction to configure Squid for YunoHost. French: https://memo-linux.com/installer-squid3-sur-un-serveur-yunohost/

0
doc/screenshots/.gitkeep Normal file
View file

View file

@ -3,18 +3,22 @@
"id": "squid3", "id": "squid3",
"packaging_format": 1, "packaging_format": 1,
"description": { "description": {
"en": "Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more.", "en": "Caching proxy for the Web supporting HTTP, HTTPS, FTP and more.",
"fr": "Squid est un proxy cache pour le web, compatible HTTP, HTTPS, FTP, et plus encore." "fr": "Proxy cache pour le web, compatible HTTP, HTTPS, FTP et plus encore."
}, },
"version": "1.0~ynh2", "version": "1.0~ynh3",
"url": "http://www.squid-cache.org/", "url": "http://www.squid-cache.org/",
"upstream": {
"license": "GPL-2.0-only",
"website": "http://www.squid-cache.org"
},
"license": "GPL-2.0-only", "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.8.1" "yunohost": ">= 4.3.0"
}, },
"multi_instance": false, "multi_instance": false,
"services": [], "services": [],
@ -22,6 +26,7 @@
"install" : [ "install" : [
{ {
"name": "squid_port", "name": "squid_port",
"type": "string",
"ask": { "ask": {
"en": "Choose a port for your Squid 3.", "en": "Choose a port for your Squid 3.",
"fr": "Entrez un port pour votre Squid 3." "fr": "Entrez un port pour votre Squid 3."

View file

@ -1,18 +0,0 @@
## Problem
- *Description of why you made this PR*
## Solution
- *And how do you fix that problem*
## PR Status
- [ ] Code finished.
- [ ] Tested with Package_check.
- [ ] Fix or enhancement tested.
- [ ] Upgrade from last version tested.
- [ ] Can be reviewed and tested.
## Package_check 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/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,6 +7,14 @@
# dependencies used by the app # dependencies used by the app
pkg_dependencies="squid3 mailutils" pkg_dependencies="squid3 mailutils"
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#================================================= #=================================================
# FUTURE OFFICIAL HELPERS # FUTURE OFFICIAL HELPERS
#================================================= #=================================================

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -13,6 +14,9 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
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
@ -22,10 +26,11 @@ ynh_abort_if_errors
ynh_print_info --message="Loading installation 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=$app --key=squid_folder)
#================================================= #=================================================
# BACKUP OF THE CONFIG OF SQUID3 # BACKUP VARIOUS FILES
#================================================= #=================================================
ynh_backup --src_path="/etc/$squid/squid.conf" ynh_backup --src_path="/etc/$squid/squid.conf"

View file

@ -21,7 +21,6 @@ ynh_abort_if_errors
#================================================= #=================================================
squid_port=$YNH_APP_ARG_SQUID_PORT squid_port=$YNH_APP_ARG_SQUID_PORT
new_port=""
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -35,10 +34,10 @@ ynh_script_progression --message="Configuring firewall..."
# 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
# Open the port # Open the port
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $squid_port ynh_script_progression --message="Configuring firewall..."
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $squid_port
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
@ -48,42 +47,37 @@ ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# MODIFY A CONFIG FILE # SPECIFIC SETUP
#================================================= #=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
# See if squid3 folder exits # See if squid3 folder exits
if [ -d "/etc/squid3" ]; then if [ -d "/etc/squid3" ]; then
squid="squid3" squid="squid3"
# If squid3 folder is not found look for squid folder # If squid3 folder is not found look for squid folder
elif [ -d "/etc/squid" ]; then elif [ -d "/etc/squid" ]; then
squid="squid" squid="squid"
# If both folders are not found then call ynh_die # If both folders are not found then call ynh_die
else else
ynh_die "No squid folder found in /etc. Looks like squid 3 package is not installed. Try installing it manually." ynh_die --message="No squid folder found in /etc. Looks like squid3 package is not installed. Try installing it manually."
fi fi
ynh_replace_string --match_string="__PORT__" --replace_string="$squid_port" --target_file="../conf/squid.conf"
ynh_replace_string --match_string="__SQUID__" --replace_string="$squid" --target_file="../conf/squid.conf"
cp -f "../conf/squid.conf" "/etc/$squid/."
# Save squid folder in app settings
ynh_app_setting_set --app=$app --key=squid_folder --value=$squid ynh_app_setting_set --app=$app --key=squid_folder --value=$squid
#================================================= ynh_add_config --template="../conf/squid.conf" --destination="/etc/$squid/squid.conf"
# STORE THE CONFIG FILE CHECKSUM
#=================================================
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="/etc/$squid/squid.conf"
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# 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 $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" --needs_exposed_ports $squid_port
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -93,8 +87,6 @@ ynh_script_progression --message="Starting a systemd service..."
# 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"
yunohost app ssowatconf
#================================================= #=================================================
# SEND A README FOR THE ADMIN # SEND A README FOR THE ADMIN
#================================================= #=================================================

View file

@ -16,8 +16,8 @@ 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=$app --key=squid_port)
squid=$(ynh_app_setting_get $app squid_folder) squid=$(ynh_app_setting_get --app=$app --key=squid_folder)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -25,10 +25,10 @@ squid=$(ynh_app_setting_get $app squid_folder)
# REMOVE SERVICE INTEGRATION IN YUNOHOST # REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null if ynh_exec_warn_less yunohost service status $app >/dev/null
then then
ynh_script_progression --message="Remove $squid service" ynh_script_progression --message="Removing $app service integration..."
yunohost service remove $app yunohost service remove $app
fi fi
@ -58,7 +58,7 @@ fi
ynh_secure_remove --file="/etc/$squid/" ynh_secure_remove --file="/etc/$squid/"
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$squid/access.log" ynh_secure_remove --file="/var/log/$squid"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -13,23 +14,29 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# 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_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=$app --key=squid_port)
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
@ -44,36 +51,42 @@ ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $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
#================================================= #=================================================
# MODIFY A CONFIG FILE # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..."
# See is squid3 folder is there # See if squid3 folder exits
if [ -d "/etc/squid3" ]; then if [ -d "/etc/squid3" ]; then
squid="squid3" squid="squid3"
# If squid3 folder is not found look for squid folder
# If squid3 folder is not found look for squid folder
elif [ -d "/etc/squid" ]; then elif [ -d "/etc/squid" ]; then
squid="squid" squid="squid"
# If both folders are not found then call ynh_die # If both folders are not found then call ynh_die
else else
ynh_die "No squid folder found in /etc. Looks like squid 3 package is not installed. Try installing it manually." ynh_die --message="No squid folder found in /etc. Looks like squid3 package is not installed. Try installing it manually."
fi fi
# 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
#================================================= ynh_secure_remove --file="/etc/$squid/squid.conf"
# RESTORE INOTIFY'S CONFIG ynh_add_config --template="../conf/squid.conf" --destination="/etc/$squid/squid.conf"
#=================================================
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/$squid/cache.log" #=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description "Squid3 a web proxy service" --log="/var/log/$squid/access.log" --needs_exposed_ports $squid_port
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$squid --action="restart" --log_path="/var/log/$squid/cache.log"
#================================================= #=================================================
# SEND A README FOR THE ADMIN # SEND A README FOR THE ADMIN

View file

@ -12,10 +12,19 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD 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)
new_port=$(ynh_app_setting_get $app new_port) squid_port=$(ynh_app_setting_get --app=$app --key=squid_port)
squid=$(ynh_app_setting_get --app=$app --key=squid_folder)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
@ -25,14 +34,27 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
# restore it if the upgrade fails ynh_clean_check_starting
# Restore it if the upgrade fails
ynh_restore_upgradebackup ynh_restore_upgradebackup
} }
# 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 # STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$squid --action="stop" --log_path="/var/log/$squid/cache.log"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
@ -41,74 +63,40 @@ ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# CLOSE A PORT # UPDATE A CONFIG FILE
#================================================= #=================================================
# If #new_port is not defined test the $port and keep it open ynh_script_progression --message="Updating a configuration file..."
if [ -z $new_port ]; then
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $squid_port
ynh_app_setting_set --app=$app --key=port --value=$squid_port
# If $new_port is define close the $port and open the $new_port
else
#Close $port
if yunohost firewall list | grep -q "\- $squid_port$"
then
ynh_script_progression --message="Closing port $squid_port..."
ynh_exec_warn_less yunohost firewall disallow TCP $squid_port
fi
# Open $new_port # See if squid3 folder exits
port=$(ynh_find_port --port=$squid_new_port)
#Add the value of $new_port to $port
ynh_app_setting_set --app=$app --key=squid_port --value=$squid_port
#Remove the value of $new_port
ynh_app_setting_set --app=$app --key=new_port --value=""
fi
#=================================================
# 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 if [ -d "/etc/squid3" ]; then
squid="squid3" squid="squid3"
# If squid3 folder is not found look for squid folder # If squid3 folder is not found look for squid folder
elif [ -d "/etc/squid" ]; then elif [ -d "/etc/squid" ]; then
squid="squid" squid="squid"
# If both folders are not found then call ynh_die # If both folders are not found then call ynh_die
else 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" ynh_die --message="No squid folder found in /etc. Looks like squid3 package is not installed. Try installing it manually."
fi fi
### 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 --file="/etc/$squid/squid.conf"
ynh_replace_string --match_string="__PORT__" --replace_string="$squid_port" --target_file="../conf/squid.conf"
ynh_replace_string --match_string="__SQUID__" --replace_string="$squid" --target_file="../conf/squid.conf"
cp -f "../conf/squid.conf" "/etc/$squid/."
# 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. ynh_add_config --template="../conf/squid.conf" --destination="/etc/$squid/squid.conf"
ynh_store_file_checksum --file="/etc/$squid/squid.conf"
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add squid3 --log "/var/log/$squid/cache.log" yunohost service add $app --description "Squid3 a web proxy service" --log="/var/log/$squid/access.log" --needs_exposed_ports $squid_port
#================================================= #=================================================
# RESTART SQUID'S SERVICE and SSOWATCONF # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..."
service $squid restart ynh_systemd_action --service_name=$squid --action="restart" --log_path="/var/log/$squid/cache.log"
yunohost app ssowatconf
#================================================= #=================================================
# SEND A README FOR THE ADMIN # SEND A README FOR THE ADMIN