1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lstu_ynh.git synced 2024-09-03 19:36:12 +02:00

Merge pull request #70 from YunoHost-Apps/testing

Upgrade to 0.26.0~ynh1
This commit is contained in:
yalh76 2022-06-22 18:09:56 +02:00 committed by GitHub
commit cecbb81af1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 258 additions and 237 deletions

View file

@ -5,7 +5,7 @@ It shall NOT be edited by hand.
# Lstu for YunoHost # Lstu for YunoHost
[![Integration level](https://dash.yunohost.org/integration/lstu.svg)](https://dash.yunohost.org/appci/app/lstu) ![](https://ci-apps.yunohost.org/ci/badges/lstu.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/lstu.maintain.svg) [![Integration level](https://dash.yunohost.org/integration/lstu.svg)](https://dash.yunohost.org/appci/app/lstu) ![Working status](https://ci-apps.yunohost.org/ci/badges/lstu.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/lstu.maintain.svg)
[![Install Lstu with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=lstu) [![Install Lstu with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=lstu)
*[Lire ce readme en français.](./README_fr.md)* *[Lire ce readme en français.](./README_fr.md)*
@ -17,13 +17,13 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
URL Shortener URL Shortener
**Shipped version:** 0.25.0~ynh1 **Shipped version:** 0.26.0~ynh1
**Demo:** https://lstu.fr **Demo:** https://lstu.fr
## Screenshots ## Screenshots
![](./doc/screenshots/LSTU_screenshot.png) ![Screenshot of Lstu](./doc/screenshots/LSTU_screenshot.png)
## Disclaimers / important information ## Disclaimers / important information
@ -33,21 +33,22 @@ How to configure this app: a plain file at `/var/www/lstu/lstu.conf` with SSH.
## Documentation and resources ## Documentation and resources
* Official app website: https://lstu.fr * Official app website: <https://lstu.fr>
* Official admin documentation: https://framagit.org/fiat-tux/hat-softwares/lstu/wikis/home * Official admin documentation: <https://framagit.org/fiat-tux/hat-softwares/lstu/wikis/home>
* Upstream app code repository: https://framagit.org/fiat-tux/hat-softwares/lstu * Upstream app code repository: <https://framagit.org/fiat-tux/hat-softwares/lstu>
* YunoHost documentation for this app: https://yunohost.org/app_lstu * YunoHost documentation for this app: <https://yunohost.org/app_lstu>
* Report a bug: https://github.com/YunoHost-Apps/lstu_ynh/issues * Report a bug: <https://github.com/YunoHost-Apps/lstu_ynh/issues>
## Developer info ## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/lstu_ynh/tree/testing). Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/lstu_ynh/tree/testing).
To try the testing branch, please proceed like that. To try the testing branch, please proceed like that.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/lstu_ynh/tree/testing --debug sudo yunohost app install https://github.com/YunoHost-Apps/lstu_ynh/tree/testing --debug
or or
sudo yunohost app upgrade lstu -u https://github.com/YunoHost-Apps/lstu_ynh/tree/testing --debug sudo yunohost app upgrade lstu -u https://github.com/YunoHost-Apps/lstu_ynh/tree/testing --debug
``` ```
**More info regarding app packaging:** https://yunohost.org/packaging_apps **More info regarding app packaging:** <https://yunohost.org/packaging_apps>

View file

@ -1,10 +1,14 @@
<!--
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.
-->
# Lstu pour YunoHost # Lstu pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/lstu.svg)](https://dash.yunohost.org/appci/app/lstu) ![](https://ci-apps.yunohost.org/ci/badges/lstu.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/lstu.maintain.svg) [![Niveau d'intégration](https://dash.yunohost.org/integration/lstu.svg)](https://dash.yunohost.org/appci/app/lstu) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/lstu.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/lstu.maintain.svg)
[![Installer Lstu avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=lstu) [![Installer Lstu avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=lstu)
*[Read this readme in english.](./README.md)* *[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer Lstu rapidement et simplement sur un serveur YunoHost. > *Ce package vous permet d'installer Lstu 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.* Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
@ -13,13 +17,13 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
Raccourcisseur d'URL Raccourcisseur d'URL
**Version incluse :** 0.25.0~ynh1 **Version incluse :** 0.26.0~ynh1
**Démo :** https://lstu.fr **Démo :** https://lstu.fr
## Captures d'écran ## Captures d'écran
![](./doc/screenshots/LSTU_screenshot.png) ![Capture d'écran de Lstu](./doc/screenshots/LSTU_screenshot.png)
## Avertissements / informations importantes ## Avertissements / informations importantes
@ -29,21 +33,22 @@ Comment configurer cette application : un fichier simple à `/var/www/lstu/lstu.
## Documentations et ressources ## Documentations et ressources
* Site officiel de l'app : https://lstu.fr * Site officiel de l'app : <https://lstu.fr>
* Documentation officielle de l'admin : https://framagit.org/fiat-tux/hat-softwares/lstu/wikis/home * Documentation officielle de l'admin : <https://framagit.org/fiat-tux/hat-softwares/lstu/wikis/home>
* Dépôt de code officiel de l'app : https://framagit.org/fiat-tux/hat-softwares/lstu * Dépôt de code officiel de l'app : <https://framagit.org/fiat-tux/hat-softwares/lstu>
* Documentation YunoHost pour cette app : https://yunohost.org/app_lstu * Documentation YunoHost pour cette app : <https://yunohost.org/app_lstu>
* Signaler un bug : https://github.com/YunoHost-Apps/lstu_ynh/issues * Signaler un bug : <https://github.com/YunoHost-Apps/lstu_ynh/issues>
## Informations pour les développeurs ## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/lstu_ynh/tree/testing). Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/lstu_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit. Pour essayer la branche testing, procédez comme suit.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/lstu_ynh/tree/testing --debug sudo yunohost app install https://github.com/YunoHost-Apps/lstu_ynh/tree/testing --debug
ou ou
sudo yunohost app upgrade lstu -u https://github.com/YunoHost-Apps/lstu_ynh/tree/testing --debug sudo yunohost app upgrade lstu -u https://github.com/YunoHost-Apps/lstu_ynh/tree/testing --debug
``` ```
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps **Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>

View file

@ -1,11 +1,10 @@
;; Nom du test ;; Test complet
auto_remove=1
; Manifest ; Manifest
domain="domain.tld" domain="domain.tld"
path="/path" path="/path"
is_public=1 is_public=1
theme="milligram" theme="milligram"
password="verysecretpassword" password="1Strong-Password"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1
@ -15,10 +14,14 @@
setup_public=1 setup_public=1
upgrade=1 upgrade=1
#Merge pull request #52 #Merge pull request #52
upgrade=1 from_commit=469fb267ebc496d2c63b10de35aaf3493ce8124f upgrade=1 from_commit=469fb267ebc496d2c63b10de35aaf3493ce8124f
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
port_already_use=0
change_url=1 change_url=1
;;; Options
Email=
Notification=none
;;; Upgrade options ;;; Upgrade options
; commit=469fb267ebc496d2c63b10de35aaf3493ce8124f ; commit=469fb267ebc496d2c63b10de35aaf3493ce8124f
name=Merge pull request #52 name=Merge pull request #52

View file

@ -1,5 +1,7 @@
SOURCE_URL=https://framagit.org/fiat-tux/hat-softwares/lstu/-/archive/0.25-0/lstu-0.25-0.tar.gz SOURCE_URL=https://framagit.org/fiat-tux/hat-softwares/lstu/-/archive/0.26-0/lstu-0.26-0.tar.gz
SOURCE_SUM=eae4bc13ef761996a13c8133647dce14e040a67173b099b630ef35dba3b19209 SOURCE_SUM=323c81b4cb04a97eda7cb37b2a63d16e808591fd46eb4326f6619200ce742960
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -14,11 +14,11 @@
# put a way to contact you here and uncomment it # put a way to contact you here and uncomment it
# MANDATORY # MANDATORY
contact => 'webmaster@__DOMAIN__', contact => 'webmaster@__DOMAIN__',
# array of random strings used to encrypt cookies # array of random strings used to encrypt cookies
# optional, default is ['fdjsofjoihrei'], PLEASE, CHANGE IT # optional, default is ['fdjsofjoihrei'], PLEASE, CHANGE IT
secrets => ['__SECRET__'], secrets => ['__SECRET__'],
# secret passphrase to access some admin features # secret passphrase to access some admin features
# If you don't want to have a plain text password in configuration, # If you don't want to have a plain text password in configuration,
@ -31,6 +31,11 @@
# optional, but you won't have access to admin /stats if not set and if adminpwd is not set either # optional, but you won't have access to admin /stats if not set and if adminpwd is not set either
hashed_adminpwd => '__HASHED_PASSWORD__', hashed_adminpwd => '__HASHED_PASSWORD__',
# indicates if you want to really delete URLs from admin page (/stats)
# or just want to deactivate the shorten URL (wont redirect anymore, cant be used anymore)
# optional, default to 0 (false)
#really_delete_urls => 0,
# choose a theme. See the available themes in `themes` directory # choose a theme. See the available themes in `themes` directory
# optional, default is 'default' # optional, default is 'default'
theme => '__THEME__', # default or milligram theme => '__THEME__', # default or milligram
@ -66,6 +71,10 @@
# optional # optional
#fixed_domain => 'example.org', #fixed_domain => 'example.org',
# if set to 1, Lstu will try to prevent its use without using the web interface
# optional, default is 0
#disable_api => 0,
# choose what database you want to use # choose what database you want to use
# valid choices are sqlite, postgresql and mysql (all lowercase) # valid choices are sqlite, postgresql and mysql (all lowercase)
# optional, default is sqlite # optional, default is sqlite
@ -264,5 +273,9 @@
# Set to 1 if you want to register the IP addresses of URL creators # Set to 1 if you want to register the IP addresses of URL creators
# optional, default is 0 # optional, default is 0
#log_creator_ip => 0, #log_creator_ip => 0,
};
# Positive integer which specifies how many pixels one "module" (one block of the QR code) occupies.
# You can't use fractional values. An arbitrary upper limit of 100 is imposed by Image::PNG::QRCode module.
# optional, default is 3
#qrcode_size => 3,
};

View file

@ -14,11 +14,11 @@
# put a way to contact you here and uncomment it # put a way to contact you here and uncomment it
# MANDATORY # MANDATORY
contact => 'webmaster@__DOMAIN__', contact => 'webmaster@__DOMAIN__',
# array of random strings used to encrypt cookies # array of random strings used to encrypt cookies
# optional, default is ['fdjsofjoihrei'], PLEASE, CHANGE IT # optional, default is ['fdjsofjoihrei'], PLEASE, CHANGE IT
secrets => ['__SECRET__'], secrets => ['__SECRET__'],
# secret passphrase to access some admin features # secret passphrase to access some admin features
# If you don't want to have a plain text password in configuration, # If you don't want to have a plain text password in configuration,
@ -273,5 +273,9 @@
# Set to 1 if you want to register the IP addresses of URL creators # Set to 1 if you want to register the IP addresses of URL creators
# optional, default is 0 # optional, default is 0
#log_creator_ip => 0, #log_creator_ip => 0,
};
# Positive integer which specifies how many pixels one "module" (one block of the QR code) occupies.
# You can't use fractional values. An arbitrary upper limit of 100 is imposed by Image::PNG::QRCode module.
# optional, default is 3
#qrcode_size => 3,
};

View file

@ -1,20 +1,20 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ { location __PATH__/ {
access_log /var/log/nginx/lstu.access.log; access_log /var/log/nginx/lstu.access.log;
error_log /var/log/nginx/lstu.error.log; error_log /var/log/nginx/lstu.error.log;
proxy_pass http://127.0.0.1:__PORT__; proxy_pass http://127.0.0.1:__PORT__;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Remote-Port $remote_port; proxy_set_header X-Remote-Port $remote_port;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
# We expect the downsteam servers to redirect to the right hostname, so don't do any rewrite$ # We expect the downsteam servers to redirect to the right hostname, so don't do any rewrite$
proxy_redirect off; proxy_redirect off;
# Include SSOWAT user panel. # Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;
} }

View file

@ -1,63 +1,63 @@
{ {
"name": "Lstu", "name": "Lstu",
"id": "lstu", "id": "lstu",
"packaging_format": 1, "packaging_format": 1,
"description": { "description": {
"en": "URL Shortener", "en": "URL Shortener",
"fr": "Raccourcisseur d'URL" "fr": "Raccourcisseur d'URL"
}, },
"version": "0.25.0~ynh1", "version": "0.26.0~ynh1",
"url": "https://lstu.fr", "url": "https://lstu.fr",
"upstream": { "upstream": {
"license": "WTFPL", "license": "WTFPL",
"website": "https://lstu.fr", "website": "https://lstu.fr",
"demo": "https://lstu.fr", "demo": "https://lstu.fr",
"admindoc": "https://framagit.org/fiat-tux/hat-softwares/lstu/wikis/home", "admindoc": "https://framagit.org/fiat-tux/hat-softwares/lstu/wikis/home",
"code": "https://framagit.org/fiat-tux/hat-softwares/lstu" "code": "https://framagit.org/fiat-tux/hat-softwares/lstu"
}, },
"license": "WTFPL", "license": "WTFPL",
"maintainer": { "maintainer": {
"name": "frju365", "name": "frju365",
"email": "abld@abld.info" "email": "abld@abld.info"
}, },
"requirements": { "requirements": {
"yunohost": ">= 4.3.0" "yunohost": ">= 4.3.0"
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [
"nginx" "nginx"
], ],
"arguments": { "arguments": {
"install": [ "install": [
{ {
"name": "domain", "name": "domain",
"type": "domain" "type": "domain"
}, },
{ {
"name": "path", "name": "path",
"type": "path", "type": "path",
"example": "/lstu", "example": "/lstu",
"default": "/lstu" "default": "/lstu"
}, },
{ {
"name": "is_public", "name": "is_public",
"type": "boolean", "type": "boolean",
"default": false "default": false
}, },
{ {
"name": "theme", "name": "theme",
"type": "string", "type": "string",
"ask": { "ask": {
"en": "Choose a theme", "en": "Choose a theme",
"fr": "Choisissez un theme" "fr": "Choisissez un theme"
}, },
"choices": ["default", "milligram"], "choices": ["default", "milligram"],
"default": "milligram" "default": "milligram"
}, },
{ {
"name": "password", "name": "password",
"type": "password" "type": "password"
} }
] ]
} }
} }

View file

@ -149,3 +149,7 @@ __PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/service
# Send the email to the recipients # Send the email to the recipients
cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients" cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients"
} }
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -67,8 +67,8 @@ if [ $is_public -eq 0 ]
then then
# If the app is private, only the shortened URLs are publics. # If the app is private, only the shortened URLs are publics.
if [ "$path_url" == "/" ]; then if [ "$path_url" == "/" ]; then
# If the path is /, clear it to prevent any error with the regex. # If the path is /, clear it to prevent any error with the regex.
path_url="" path_url=""
fi fi
# Modify the domain to be used in a regex # Modify the domain to be used in a regex
domain_regex=$(echo "$domain" | sed 's@-@.@g') domain_regex=$(echo "$domain" | sed 's@-@.@g')

View file

@ -6,7 +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 # 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
@ -34,7 +34,6 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
ynh_print_info --message="Declaring files to be backed up..." ynh_print_info --message="Declaring files to be backed up..."
#================================================= #=================================================

View file

@ -40,17 +40,18 @@ theme=$(ynh_app_setting_get --app=$app --key=theme)
hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password) hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
# 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 () {
ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# restore it if the upgrade fails # 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
@ -88,19 +89,19 @@ ynh_script_progression --message="Updating NGINX web server configuration..."
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the nginx config file # Change the path in the NGINX config file
if [ $change_path -eq 1 ] if [ $change_path -eq 1 ]
then then
# Make a backup of the original nginx config file if modified # Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path" ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for nginx helper # Set global variables for NGINX helper
domain="$old_domain" domain="$old_domain"
path_url="$new_path" path_url="$new_path"
# Create a dedicated nginx config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
fi fi
# Change the domain for nginx # Change the domain for NGINX
if [ $change_domain -eq 1 ] if [ $change_domain -eq 1 ]
then then
# Delete file checksum for the old conf file location # Delete file checksum for the old conf file location
@ -113,32 +114,19 @@ fi
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
#================================================= #=================================================
# CONFIGURE LSTU # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Configuring lstu..." ynh_script_progression --message="Updating a configuration file..."
domain="$new_domain" domain="$new_domain"
path_url="$new_path" path_url="$new_path"
config="${final_path}/lstu.conf"
ynh_backup_if_checksum_is_different --file="$config"
cp ../conf/lstu.conf.template "$config"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config"
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config"
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config"
ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config"
ynh_replace_string --match_string="__SELECTED_THEME__" --replace_string="$theme" --target_file="$config"
ynh_replace_string --match_string="__PASSWORD_HASHED__" --replace_string="$hashed_password" --target_file="$config"
ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config"
if [ $is_public -eq 0 ]; if [ $is_public -eq 0 ];
then then
ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="" --target_file="$config" ynh_add_config --template="../conf/lstu.conf.ldap" --destination="$final_path/lstu.conf"
else else
ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="#" --target_file="$config" ynh_add_config --template="../conf/lstu.conf.template" --destination="$final_path/lstu.conf"
fi fi
ynh_store_file_checksum --file="$config"
#================================================= #=================================================
# UPDATE SSOWAT # UPDATE SSOWAT
@ -149,8 +137,8 @@ if [ $is_public -eq 0 ]
then then
# If the app is private, only the shortened URLs are publics. # If the app is private, only the shortened URLs are publics.
if [ "$path_url" == "/" ]; then if [ "$path_url" == "/" ]; then
# If the path is /, clear it to prevent any error with the regex. # If the path is /, clear it to prevent any error with the regex.
path_url="" path_url=""
fi fi
# Modify the domain to be used in a regex # Modify the domain to be used in a regex
domain_regex=$(echo "$domain" | sed 's@-@.@g') domain_regex=$(echo "$domain" | sed 's@-@.@g')

View file

@ -28,11 +28,12 @@ path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
theme=$YNH_APP_ARG_THEME theme=$YNH_APP_ARG_THEME
password=$YNH_APP_ARG_PASSWORD password=$YNH_APP_ARG_PASSWORD
secret=$(ynh_string_random --length=24)
hashed_password=$(echo -n $password | sha256sum | cut -d' ' -f1)
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
secret=$(ynh_string_random --length=24)
hashed_password=$(echo -n $password | sha256sum | cut -d' ' -f1)
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
@ -74,6 +75,14 @@ ynh_script_progression --message="Installing dependencies..."
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# CREATE A POSTGRESQL DATABASE # CREATE A POSTGRESQL DATABASE
#================================================= #=================================================
@ -86,14 +95,6 @@ db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -118,9 +119,9 @@ ynh_add_nginx_config
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#================================================= #=================================================
# CONFIGURE LSTU # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring Lstu..." ynh_script_progression --message="Adding a configuration file..."
if [ $is_public -eq 0 ]; if [ $is_public -eq 0 ];
then then
@ -174,14 +175,16 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." ynh_script_progression --message="Configuring permissions..."
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors" ynh_permission_update --permission="main" --add="visitors"
if [ $is_public -eq 0 ] if [ $is_public -eq 0 ]
then then
# If the app is private, only the shortened URLs are publics. # If the app is private, only the shortened URLs are publics.
if [ "$path_url" == "/" ]; then if [ "$path_url" == "/" ]; then
# If the path is /, clear it to prevent any error with the regex. # If the path is /, clear it to prevent any error with the regex.
path_url="" path_url=""
fi fi
# Modify the domain to be used in a regex # Modify the domain to be used in a regex
domain_regex=$(echo "$domain" | sed 's@-@.@g') domain_regex=$(echo "$domain" | sed 's@-@.@g')

View file

@ -28,10 +28,10 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# 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="Removing $app service..." ynh_script_progression --message="Removing $app service integration..."
yunohost service remove $app yunohost service remove $app
fi fi
@ -43,21 +43,21 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
#================================================= #=================================================
# REMOVE THE POSTGRESQL DATABASE # REMOVE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Removing the PostgreSQL database..." ynh_script_progression --message="Removing the PostgreSQL database..."
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name" ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
@ -72,23 +72,23 @@ ynh_secure_remove --file="$final_path"
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." ynh_script_progression --message="Removing NGINX web server configuration..."
# Remove the dedicated nginx config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE LOGROTATE CONFIGURATION # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing logrotate configuration..." ynh_script_progression --message="Removing dependencies..."
# Remove the app-specific logrotate config # Remove metapackage and its dependencies
ynh_remove_logrotate ynh_remove_app_dependencies
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
#================================================= #=================================================
# REMOVE LOG FILES # REMOVE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Removing log files..." ynh_script_progression --message="Removing various files..."
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app.log" ynh_secure_remove --file="/var/log/$app.log"

View file

@ -6,7 +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 # 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
@ -23,7 +23,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -44,13 +44,6 @@ test ! -d $final_path \
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
@ -80,6 +73,13 @@ ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies # Define and install dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
@ -87,7 +87,7 @@ ynh_script_progression --message="Restoring the PostregSQL database..."
ynh_psql_test_if_first_run ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
@ -97,6 +97,13 @@ ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet systemctl enable $app.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
@ -111,13 +118,6 @@ ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at" ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -35,6 +35,30 @@ ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
@ -88,37 +112,6 @@ then
ynh_exec_warn_less yunohost firewall disallow TCP $port ynh_exec_warn_less yunohost firewall disallow TCP $port
fi fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
@ -143,14 +136,6 @@ chmod 750 "$final_path"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated nginx config
ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
@ -159,9 +144,19 @@ ynh_script_progression --message="Upgrading dependencies..."
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# CONFIGURE LSTU # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring Lstu..." ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
if [ $is_public -eq 0 ]; if [ $is_public -eq 0 ];
then then
@ -179,14 +174,6 @@ pushd $final_path
carton install --deployment --without=sqlite --without=mysql carton install --deployment --without=sqlite --without=mysql
popd popd
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..."
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
@ -195,6 +182,16 @@ ynh_script_progression --message="Upgrading systemd configuration..."
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..."
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
@ -202,32 +199,34 @@ ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="/var/log/$app.log" --log="/var/www/$app/log/production.log" yunohost service add $app --log="/var/log/$app.log" --log="/var/www/$app/log/production.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action=reload --line_match="Reloaded Shortened URLs service." --log_path="systemd"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Upgrading SSOwat configuration..." ynh_script_progression --message="Configuring permissions..."
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors" ynh_permission_update --permission="main" --add="visitors"
if [ $is_public -eq 0 ] if [ $is_public -eq 0 ]
then then
# If the app is private, only the shortened URLs are publics. # If the app is private, only the shortened URLs are publics.
if [ "$path_url" == "/" ]; then if [ "$path_url" == "/" ]; then
# If the path is /, clear it to prevent any error with the regex. # If the path is /, clear it to prevent any error with the regex.
path_url="" path_url=""
fi fi
# Modify the domain to be used in a regex # Modify the domain to be used in a regex
domain_regex=$(echo "$domain" | sed 's@-@.@g') domain_regex=$(echo "$domain" | sed 's@-@.@g')
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$" ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$"
fi fi
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action=reload --line_match="Reloaded Shortened URLs service." --log_path="systemd"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================