From 6dad66c3cef83c611ebb87e9e4ccc473b4da7b2e Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 2 Jun 2020 18:14:52 +0200 Subject: [PATCH 01/23] try update version include read-only mode if public app --- conf/app.src | 2 +- scripts/install | 6 +++++- scripts/upgrade | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/conf/app.src b/conf/app.src index bfc90a7..b42c487 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,4 +1,4 @@ -SOURCE_URL=https://github.com/duniter/cesium/releases/download/v1.6.3/cesium-v1.6.3-web.zip +SOURCE_URL=https://github.com/duniter/cesium/releases/download/v1.6.7/cesium-v1.6.7-web.zip SOURCE_SUM=e6bb12bb56453781d01fe0f74afd28990d693010652b542eae0d3348f51d911e SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=zip diff --git a/scripts/install b/scripts/install index 1702adf..fc527ab 100755 --- a/scripts/install +++ b/scripts/install @@ -23,7 +23,7 @@ yunohost app checkurl "${domain}${path}" -a "$app" \ src_path=/var/www/$app mkdir -p $src_path # Download, check integrity, uncompress and patch the source from app.src - ynh_script_progression --message="Setting up source files..." --time --weight=1 + ynh_script_progression --message="Setting up source files..." --time --weight=1 ynh_setup_source --dest_dir=$src_path chown -R www-data: $src_path @@ -33,10 +33,14 @@ sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf + + # If app is public, add url to SSOWat conf as skipped_uris if [[ $is_public -eq 1 ]]; then # unprotected_uris allows SSO credentials to be passed anyway. ynh_app_setting_set "$app" unprotected_uris "/" +# activate read-only +ynh_replace_string --match_string='"readonly": false,' --replace_string='"readonly": true,' --target_file="$src_path/config.js" fi # Reload nginx service diff --git a/scripts/upgrade b/scripts/upgrade index 79820c9..08c1a9c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -46,6 +46,8 @@ cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf # If app is public, add url to SSOWat conf as skipped_uris if [[ $is_public -eq 1 ]]; then ynh_app_setting_set "$app" unprotected_uris "/" +# activate read-only +ynh_replace_string --match_string='"readonly": false,' --replace_string='"readonly": true,' --target_file="$src_path/config.js" fi # Reload nginx service From 54c541e2da9c032d1c59276cadb57c21fcfbb579 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 3 Jun 2020 18:32:54 +0200 Subject: [PATCH 02/23] add the correct sha256sum and the correct version --- conf/app.src | 2 +- manifest.json | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index b42c487..8831ae2 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ SOURCE_URL=https://github.com/duniter/cesium/releases/download/v1.6.7/cesium-v1.6.7-web.zip -SOURCE_SUM=e6bb12bb56453781d01fe0f74afd28990d693010652b542eae0d3348f51d911e +SOURCE_SUM=99157da53e42096c51ebf845c40c155cb1ed6d66678983c9947b528869b6284f SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=zip SOURCE_IN_SUBDIR=false diff --git a/manifest.json b/manifest.json index d8f1a9c..76345fa 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Duniter client to manage wallets, certifications in a libre money.", "fr": "Client Duniter pour gérer ses portes-monnaie, les certifications au sein d’une monnaie libre." }, - "version": "v1.6.3~ynh1", + "version": "v1.6.7~ynh1", "url": "https://github.com/duniter/cesium", "license": "AGPL-3.0-or-later", "maintainer": { diff --git a/scripts/upgrade b/scripts/upgrade index 08c1a9c..ad2f6ee 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -47,7 +47,7 @@ cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf if [[ $is_public -eq 1 ]]; then ynh_app_setting_set "$app" unprotected_uris "/" # activate read-only -ynh_replace_string --match_string='"readonly": false,' --replace_string='"readonly": true,' --target_file="$src_path/config.js" + ynh_replace_string --match_string='"readonly": false,' --replace_string='"readonly": true,' --target_file="$src_path/config.js" fi # Reload nginx service From 640fa2770a7f3b4250798a9e02769b50cf77df9d Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 3 Jun 2020 19:42:02 +0200 Subject: [PATCH 03/23] commnet helper-update-version --- README.md | 6 +++--- helper-update-version.sh | 22 +++++++++++----------- scripts/install | 4 +--- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index c804b08..425c4e8 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Cesium package for YunoHost -[![Integration level](https://dash.yunohost.org/integration/cesium.svg)](https://dash.yunohost.org/appci/app/cesium) ![](https://ci-apps.yunohost.org/ci/badges/cesium.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/cesium.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/cesium.svg)](https://dash.yunohost.org/appci/app/cesium) ![](https://ci-apps.yunohost.org/ci/badges/cesium.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/cesium.maintain.svg) [![Install Custom Webapp with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=cesium) -> *This package allow you to install Cesium quickly and simply on a YunoHost server. +> *This package allow you to install Cesium quickly and simply on a YunoHost server. If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* ## Overview @@ -12,7 +12,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to [Cesium](https://cesium.app) is an [Unhosted webapp](https://unhosted.org) client for any [Duniter](https://duniter.org) crypto-currency. It allows you to manage your wallet, certify your friends, and more ! -**Shipped version:** v1.6.3 +**Shipped version:** v1.6.7 ## Links diff --git a/helper-update-version.sh b/helper-update-version.sh index 070a7cc..11c1c0d 100755 --- a/helper-update-version.sh +++ b/helper-update-version.sh @@ -1,16 +1,16 @@ #!/bin/bash # Retrieve sources, get sha256sum, parse package version and update these strings in manifest, README and /conf/app.src - -URL=$(curl -s https://api.github.com/repos/duniter/cesium/releases/latest | grep "browser_" | grep "web" | head -1 | cut -d\" -f4) -wget -nc --quiet $URL -P ./tmp -CHECKSUM=$(sha256sum ./tmp/cesium-*-web.zip | head -c 64) -sed -i "s/SOURCE_SUM=.*/SOURCE_SUM=${CHECKSUM}/" ./conf/app.src -sed -i "s#SOURCE_URL=.*#SOURCE_URL=$URL#" ./conf/app.src -VERSION=$(echo $URL | sed "s#https://github.com/duniter/cesium/releases/download/\(.*\)/cesium.*#\1#") -sed -i "s#\*\*Shipped version:\*\*.*#\*\*Shipped version:\*\* ${VERSION}#" ./README.md -sed -i "s# \"version\": \".*# \"version\": \"${VERSION}\~ynh1\",#" ./manifest.json +# URL=$(curl -s https://api.github.com/repos/duniter/cesium/releases/ | grep "browser_" | grep "web" | head -1 | cut -d\" -f4) +# wget -nc --quiet $URL -P ./tmp +# CHECKSUM=$(sha256sum ./tmp/cesium-*-web.zip | head -c 64) +# sed -i "s/SOURCE_SUM=.*/SOURCE_SUM=${CHECKSUM}/" ./conf/app.src +# sed -i "s#SOURCE_URL=.*#SOURCE_URL=$URL#" ./conf/app.src -rm -f -R ./tmp +# VERSION=$(echo $URL | sed "s#https://github.com/duniter/cesium/releases/download/\(.*\)/cesium.*#\1#") +# sed -i "s#\*\*Shipped version:\*\*.*#\*\*Shipped version:\*\* ${VERSION}#" ./README.md +# sed -i "s# \"version\": \".*# \"version\": \"${VERSION}\~ynh1\",#" ./manifest.json -git commit README.md manifest.json conf/app.src -m "$VERSION" +# rm -f -R ./tmp + +# git commit README.md manifest.json conf/app.src -m "$VERSION" diff --git a/scripts/install b/scripts/install index fc527ab..2f223f6 100755 --- a/scripts/install +++ b/scripts/install @@ -33,14 +33,12 @@ sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf - - # If app is public, add url to SSOWat conf as skipped_uris if [[ $is_public -eq 1 ]]; then # unprotected_uris allows SSO credentials to be passed anyway. ynh_app_setting_set "$app" unprotected_uris "/" # activate read-only -ynh_replace_string --match_string='"readonly": false,' --replace_string='"readonly": true,' --target_file="$src_path/config.js" + ynh_replace_string --match_string='"readonly": false,' --replace_string='"readonly": true,' --target_file="$src_path/config.js" fi # Reload nginx service From 60e61f955bb45894eab485f16d87ed9041a396b9 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 3 Jun 2020 23:41:51 +0200 Subject: [PATCH 04/23] refactoring with the new example_ynh --- helper-update-version.sh | 2 +- manifest.json | 2 +- scripts/backup | 64 +++++++++++++--- scripts/change_url | 118 ++++++++++++++++++++++++++++ scripts/install | 125 +++++++++++++++++++++++------- scripts/remove | 64 +++++++++++++--- scripts/restore | 102 +++++++++++++++++++------ scripts/upgrade | 161 +++++++++++++++++++++++++++++++++------ 8 files changed, 539 insertions(+), 99 deletions(-) create mode 100644 scripts/change_url diff --git a/helper-update-version.sh b/helper-update-version.sh index 11c1c0d..089c11f 100755 --- a/helper-update-version.sh +++ b/helper-update-version.sh @@ -1,7 +1,7 @@ #!/bin/bash # Retrieve sources, get sha256sum, parse package version and update these strings in manifest, README and /conf/app.src -# URL=$(curl -s https://api.github.com/repos/duniter/cesium/releases/ | grep "browser_" | grep "web" | head -1 | cut -d\" -f4) +# URL=$(curl -s https://api.github.com/repos/duniter/cesium/releases/latest | grep "browser_" | grep "web" | head -1 | cut -d\" -f4) # wget -nc --quiet $URL -P ./tmp # CHECKSUM=$(sha256sum ./tmp/cesium-*-web.zip | head -c 64) # sed -i "s/SOURCE_SUM=.*/SOURCE_SUM=${CHECKSUM}/" ./conf/app.src diff --git a/manifest.json b/manifest.json index 76345fa..afc5e46 100644 --- a/manifest.json +++ b/manifest.json @@ -15,7 +15,7 @@ "url": "https://moul.re" }, "requirements": { - "yunohost": ">> 2.4.0" + "yunohost": ">> 3.5.0" }, "multi_instance": false, "services": [ diff --git a/scripts/backup b/scripts/backup index f944306..86f8952 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,18 +1,58 @@ #!/bin/bash -# Exit on command errors and treat unset variables as an error -set -eu +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# See comments in install script -app=$YNH_APP_INSTANCE_NAME - -# Source YunoHost helpers source /usr/share/yunohost/helpers -# Backup sources & data -# Note: the last argument is where to save this path, see the restore script. -ynh_backup "/var/www/${app}" "sources" +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info --message="Loading installation settings..." + +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) + +#================================================= +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + +### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs +### to be backuped and not an actual copy of any file. The actual backup that +### creates and fill the archive with the files happens in the core after this +### script is called. Hence ynh_backups calls takes basically 0 seconds to run. + +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= + +ynh_backup --src_path="$final_path" + +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= + +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." + -# Copy NGINX configuration -domain=$(ynh_app_setting_get "$app" domain) -ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..8e3e9b0 --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,118 @@ +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +old_domain=$YNH_APP_OLD_DOMAIN +old_path=$YNH_APP_OLD_PATH + +new_domain=$YNH_APP_NEW_DOMAIN +new_path=$YNH_APP_NEW_PATH + +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # 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" + + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# CHECK WHICH PARTS SHOULD BE CHANGED +#================================================= + +change_domain=0 +if [ "$old_domain" != "$new_domain" ] +then + change_domain=1 +fi + +change_path=0 +if [ "$old_path" != "$new_path" ] +then + change_path=1 +fi + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1 + +nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf + +## Move from sub path to root +#if [ "$new_path" == "/" ] +#then +# ynh_replace_string "\(^.*rewrite.*\^$old_path.* permanent;\)" "#sub_path_only\1" "$nginx_conf_path" +# ynh_replace_string "\(rewrite *\^\)$old_path\$ $old_path/*" "\1$new_path$ $new_path" "$nginx_conf_path" + +# Move to a sub path +#else +# ynh_replace_string "^#sub_path_only" "" "$nginx_conf_path" +# ynh_replace_string "\(rewrite *\^\)$old_path\$ $old_path/*" "\1$new_path$ $new_path/" "$nginx_conf_path" +#fi + +# Change the path in the nginx config file +if [ $change_path -eq 1 ] +then + # Make a backup of the original nginx config file if modified + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" + # Set global variables for nginx helper + domain="$old_domain" + path_url="$new_path" + # Create a dedicated nginx config + ynh_add_nginx_config +fi + + +# Change the domain for nginx +if [ $change_domain -eq 1 ] +then + # Delete file checksum for the old conf file location + ynh_delete_file_checksum --file="$nginx_conf_path" + mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf + # Store file checksum for the new config file location + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +fi + + + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --time --last + diff --git a/scripts/install b/scripts/install index 2f223f6..e41a431 100755 --- a/scripts/install +++ b/scripts/install @@ -1,45 +1,118 @@ #!/bin/bash +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Exit on command errors and treat unset variables as an error -set -eu +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# RETRIEVE ARGUMENTS FROM THE MANIFEST +#================================================= # Retrieve arguments app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN -path=$YNH_APP_ARG_PATH +path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC -# Source YunoHost helpers -source /usr/share/yunohost/helpers +#================================================= +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS +#================================================= +ynh_script_progression --message="Validating installation parameters..." --time --weight=1 + +final_path=/var/www/$app +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" +# Normalize the url path syntax +path_url=$(ynh_normalize_url_path $path_url) + +# Check web path availability +ynh_webpath_available $domain $path_url +# Register (book) web path +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url + +#================================================= +# STORE SETTINGS FROM MANIFEST +#================================================= +ynh_script_progression --message="Storing installation settings..." --time --weight=1 # Save app settings -ynh_app_setting_set "$app" is_public "$is_public" +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=is_public --value=$is_public -# Check domain/path availability -yunohost app checkurl "${domain}${path}" -a "$app" \ - || ynh_die "Path not available: ${domain}${path}" +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_script_progression --message="Setting up source files..." --time --weight=1 # Retrieve sources and install them -src_path=/var/www/$app -mkdir -p $src_path +ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src - ynh_script_progression --message="Setting up source files..." --time --weight=1 - ynh_setup_source --dest_dir=$src_path + +ynh_setup_source --dest_dir="$final_path" + +#================================================= +# Permissions files +#================================================= + chown -R www-data: $src_path -# Modify Nginx configuration file and copy it to Nginx conf directory -nginx_conf=../conf/nginx.conf -sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf -sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf -cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf +# Remove the public access +ynh_app_setting_delete --app=$app --key=skipped_uris -# If app is public, add url to SSOWat conf as skipped_uris -if [[ $is_public -eq 1 ]]; then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set "$app" unprotected_uris "/" -# activate read-only - ynh_replace_string --match_string='"readonly": false,' --replace_string='"readonly": true,' --target_file="$src_path/config.js" +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring nginx web server..." --time --weight=1 + +# Modify Nginx configuration file and copy it to Nginx conf directory +ynh_replace_string --match_string="YNH_WWW_PATH" --replace_string="$path_url" --target_file="$final_path/nginx_conf" +ynh_replace_string --match_string='YNH_WWW_ALIAS' --replace_string='$final_path' --target_file="$final_path/nginx_conf" +### `ynh_add_nginx_config` will use the file conf/nginx.conf +# Create a dedicated nginx config +ynh_add_nginx_config + +if [ "$path_url" != "/" ] +then + ynh_replace_string "^#sub_path_only" "" "/etc/nginx/conf.d/$domain.d/$app.conf" fi -# Reload nginx service -systemctl reload nginx +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 + + +# If app is public, add url to SSOWat conf as skipped_uris and read-only mode +if [[ $is_public -eq 1 ]]; then + # unprotected_uris allows SSO credentials to be passed anyway. + ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" +# activate read-only + ynh_replace_string --match_string='"readonly": false,' --replace_string='"readonly": true,' --target_file="$final_path/config.js" +fi + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Installation of $app completed" --time --last \ No newline at end of file diff --git a/scripts/remove b/scripts/remove index 32713ca..d1e1303 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,17 +1,63 @@ #!/bin/bash -# Source YunoHost helpers +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + source /usr/share/yunohost/helpers -# Retrieve app settings +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 + app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get "$app" domain) -# Remove sources -ynh_secure_remove /var/www/$app +domain=$(ynh_app_setting_get --app=$app --key=domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + + +#================================================= +# REMOVE APP MAIN DIR +#================================================= +ynh_script_progression --message="Removing app main directory..." --time --weight=1 + +# Remove the app directory securely +ynh_secure_remove --file="$final_path" + +#================================================= +# REMOVE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1 + +# Remove the dedicated nginx config +ynh_remove_nginx_config + +#================================================= +# GENERIC FINALIZATION +#================================================= +# REMOVE DEDICATED USER +#================================================= +ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 + +# Delete a system user +ynh_system_user_delete --username=$app + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Removal of $app completed" --time --last + + -# Remove configuration files -rm -f /etc/nginx/conf.d/$domain.d/$app.conf -# Reload nginx service -systemctl reload nginx diff --git a/scripts/restore b/scripts/restore index 89abc87..dee9974 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,35 +1,87 @@ #!/bin/bash -# Note: each files and directories you've saved using the ynh_backup helper -# will be located in the current directory, regarding the last argument. +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Exit on command errors and treat unset variables as an error -set -eu - -# See comments in install script -app=$YNH_APP_INSTANCE_NAME - -# Source YunoHost helpers +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source /usr/share/yunohost/helpers -# Retrieve old app settings -domain=$(ynh_app_setting_get "$app" domain) -path=$(ynh_app_setting_get "$app" path) +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= -# Check domain/path availability -yunohost app checkurl "${domain}${path}" -a "$app" \ - || ynh_die "Path not available: ${domain}${path}" +ynh_clean_setup () { + #### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors -# Restore sources & data -src_path="/var/www/${app}" -cp -a ./sources "$src_path" +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 -# Restore permissions to app files -# you may need to make some file and/or directory writeable by www-data (nginx user) -chown -R www-data: "$src_path" +app=$YNH_APP_INSTANCE_NAME -# Restore NGINX configuration -cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) -# Restart webserver -systemctl reload nginx +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= +ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 + +ynh_webpath_available --domain=$domain --path_url=$path_url \ + || ynh_die --message="Path not available: ${domain}${path_url}" +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " + +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 + +ynh_restore_file --origin_path="$final_path" + +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app + +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions on app files +chown -R www-data: $final_path + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --time --last \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index ad2f6ee..506060b 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,16 +1,37 @@ #!/bin/bash +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source /usr/share/yunohost/helpers + + # Exit on command errors and treat unset variables as an error set -eu # Source YunoHost helpers source /usr/share/yunohost/helpers +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 + +app=$YNH_APP_INSTANCE_NAME # Retrieve app settings -app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get "$app" domain) -path=$(ynh_app_setting_get "$app" path) -is_public=$(ynh_app_setting_get "$app" is_public) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +admin=$(ynh_app_setting_get --app=$app --key=admin) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + + +#================================================= +# CHECK VERSION +#================================================= ### This helper will compare the version of the currently installed app and the version of the upstream package. ### $upgrade_type can have 2 different values @@ -20,35 +41,125 @@ is_public=$(ynh_app_setting_get "$app" is_public) ### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. upgrade_type=$(ynh_check_app_version_changed) -# Remove trailing "/" for next commands -path=${path%/} -# Retreive sources and install them -src_path=/var/www/$app +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 + +# Fix is_public as a boolean value +if [ "$is_public" = "Yes" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=1 + is_public=1 +elif [ "$is_public" = "No" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=0 + is_public=0 +fi + +# If final_path doesn't exist, create it +if [ -z "$final_path" ]; then + final_path=/var/www/$app + ynh_app_setting_set --app=$app --key=final_path --value=$final_path +fi + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# CHECK THE PATH +#================================================= + +# Normalize the URL path syntax +# N.B. : this is for app installations before YunoHost 2.7 +# where this value might be something like /foo/ or foo/ +# instead of /foo .... +# If nobody installed your app before 2.7, then you may +# safely remove this line +path_url=$(ynh_normalize_url_path --path_url=$path_url) + +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= + if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_secure_remove $src_path - mkdir -p $src_path - ynh_script_progression --message="Upgrading source files..." --time --weight=1 + ynh_script_progression --message="Upgrading source files..." --time --weight=1 - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir=$src_path - chown -R www-data: $src_path + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" fi +# # Retreive sources and install them +# src_path=/var/www/$app +# if [ "$upgrade_type" == "UPGRADE_APP" ] +# then +# ynh_secure_remove $src_path +# mkdir -p $src_path +# ynh_script_progression --message="Upgrading source files..." --time --weight=1 + +# # Download, check integrity, uncompress and patch the source from app.src +# ynh_setup_source --dest_dir=$src_path +# chown -R www-data: $src_path +# fi + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 # Modify Nginx configuration file and copy it to Nginx conf directory -nginx_conf=../conf/nginx.conf -sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf -sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf -cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf +ynh_replace_string --match_string="YNH_WWW_PATH" --replace_string="$path_url/" --target_file="$final_path/nginx_conf" +ynh_replace_string --match_string='YNH_WWW_ALIAS' --replace_string='$final_path/' --target_file="$final_path/nginx_conf" +### `ynh_add_nginx_config` will use the file conf/nginx.conf +# Create a dedicated nginx config +ynh_add_nginx_config -# If app is public, add url to SSOWat conf as skipped_uris -if [[ $is_public -eq 1 ]]; then - ynh_app_setting_set "$app" unprotected_uris "/" -# activate read-only - ynh_replace_string --match_string='"readonly": false,' --replace_string='"readonly": true,' --target_file="$src_path/config.js" +if [ "$path_url" != "/" ] +then + ynh_replace_string "^#sub_path_only" "" "/etc/nginx/conf.d/$domain.d/$app.conf" fi -# Reload nginx service -systemctl reload nginx +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + +# Set permissions on app files +chown -R root: $final_path + +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 + + +# If app is public, add url to SSOWat conf as skipped_uris and read-only mode +if [[ $is_public -eq 1 ]]; then + # unprotected_uris allows SSO credentials to be passed anyway. + ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" +# activate read-only + ynh_replace_string --match_string='"readonly": false,' --replace_string='"readonly": true,' --target_file="$final_path/config.js" +fi + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --time --last \ No newline at end of file From 3b3164966b78ae2d0b79b897f319a4ef34c0a24e Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 3 Jun 2020 23:46:53 +0200 Subject: [PATCH 05/23] syntax error --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index e41a431..7f42ceb 100755 --- a/scripts/install +++ b/scripts/install @@ -68,7 +68,7 @@ ynh_setup_source --dest_dir="$final_path" # Permissions files #================================================= -chown -R www-data: $src_path +chown -R www-data: $final_path # Remove the public access ynh_app_setting_delete --app=$app --key=skipped_uris From bb70f2db54d6b23c9075f14e02c667621ce68102 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 3 Jun 2020 23:52:47 +0200 Subject: [PATCH 06/23] syntax error --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 7f42ceb..fac5139 100755 --- a/scripts/install +++ b/scripts/install @@ -79,8 +79,8 @@ ynh_app_setting_delete --app=$app --key=skipped_uris ynh_script_progression --message="Configuring nginx web server..." --time --weight=1 # Modify Nginx configuration file and copy it to Nginx conf directory -ynh_replace_string --match_string="YNH_WWW_PATH" --replace_string="$path_url" --target_file="$final_path/nginx_conf" -ynh_replace_string --match_string='YNH_WWW_ALIAS' --replace_string='$final_path' --target_file="$final_path/nginx_conf" +ynh_replace_string --match_string="YNH_WWW_PATH" --replace_string="$path_url" --target_file="$final_path/nginx.conf" +ynh_replace_string --match_string='YNH_WWW_ALIAS' --replace_string='$final_path' --target_file="$final_path/nginx.conf" ### `ynh_add_nginx_config` will use the file conf/nginx.conf # Create a dedicated nginx config ynh_add_nginx_config From b1962b33f703692899146be7e2b0f3642dea8fcd Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 3 Jun 2020 23:57:07 +0200 Subject: [PATCH 07/23] syntax error --- scripts/install | 7 ++++--- scripts/upgrade | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index fac5139..f0b6fd0 100755 --- a/scripts/install +++ b/scripts/install @@ -78,13 +78,14 @@ ynh_app_setting_delete --app=$app --key=skipped_uris #================================================= ynh_script_progression --message="Configuring nginx web server..." --time --weight=1 -# Modify Nginx configuration file and copy it to Nginx conf directory -ynh_replace_string --match_string="YNH_WWW_PATH" --replace_string="$path_url" --target_file="$final_path/nginx.conf" -ynh_replace_string --match_string='YNH_WWW_ALIAS' --replace_string='$final_path' --target_file="$final_path/nginx.conf" ### `ynh_add_nginx_config` will use the file conf/nginx.conf # Create a dedicated nginx config ynh_add_nginx_config +# Modify Nginx configuration file and copy it to Nginx conf directory +ynh_replace_string --match_string="YNH_WWW_PATH" --replace_string="$path_url" --target_file="$final_path/nginx.conf" +ynh_replace_string --match_string='YNH_WWW_ALIAS' --replace_string='$final_path' --target_file="$final_path/nginx.conf" + if [ "$path_url" != "/" ] then ynh_replace_string "^#sub_path_only" "" "/etc/nginx/conf.d/$domain.d/$app.conf" diff --git a/scripts/upgrade b/scripts/upgrade index 506060b..016b4c2 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -118,12 +118,13 @@ fi #================================================= ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 +ynh_add_nginx_config + # Modify Nginx configuration file and copy it to Nginx conf directory ynh_replace_string --match_string="YNH_WWW_PATH" --replace_string="$path_url/" --target_file="$final_path/nginx_conf" ynh_replace_string --match_string='YNH_WWW_ALIAS' --replace_string='$final_path/' --target_file="$final_path/nginx_conf" ### `ynh_add_nginx_config` will use the file conf/nginx.conf # Create a dedicated nginx config -ynh_add_nginx_config if [ "$path_url" != "/" ] then From 4efd37ab8f840f48654420b97bc7bd4cc5da974a Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 4 Jun 2020 00:06:50 +0200 Subject: [PATCH 08/23] change syntax nginx_conf --- conf/nginx.conf | 5 +++-- scripts/install | 3 --- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index f65be88..508fc0a 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,7 +1,8 @@ -location YNH_WWW_PATH { +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { # Path to source - alias YNH_WWW_ALIAS ; + alias __FINALPATH__/ ; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/scripts/install b/scripts/install index f0b6fd0..0a0401a 100755 --- a/scripts/install +++ b/scripts/install @@ -82,9 +82,6 @@ ynh_script_progression --message="Configuring nginx web server..." --time --weig # Create a dedicated nginx config ynh_add_nginx_config -# Modify Nginx configuration file and copy it to Nginx conf directory -ynh_replace_string --match_string="YNH_WWW_PATH" --replace_string="$path_url" --target_file="$final_path/nginx.conf" -ynh_replace_string --match_string='YNH_WWW_ALIAS' --replace_string='$final_path' --target_file="$final_path/nginx.conf" if [ "$path_url" != "/" ] then From b4a9350fd241bb7b6a34adf70868be003ce5909b Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 4 Jun 2020 00:20:50 +0200 Subject: [PATCH 09/23] debug change url script --- scripts/change_url | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/change_url b/scripts/change_url index 8e3e9b0..f544340 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,3 +1,5 @@ +#!/bin/bash + #================================================= # GENERIC STARTING #================================================= From bdf6c2c6178b2b3ddf7c74e53fe7e920fcd19a30 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 4 Jun 2020 00:26:08 +0200 Subject: [PATCH 10/23] debug change url script --- scripts/upgrade | 6 ------ 1 file changed, 6 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 016b4c2..62af339 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -120,12 +120,6 @@ ynh_script_progression --message="Upgrading nginx web server configuration..." - ynh_add_nginx_config -# Modify Nginx configuration file and copy it to Nginx conf directory -ynh_replace_string --match_string="YNH_WWW_PATH" --replace_string="$path_url/" --target_file="$final_path/nginx_conf" -ynh_replace_string --match_string='YNH_WWW_ALIAS' --replace_string='$final_path/' --target_file="$final_path/nginx_conf" -### `ynh_add_nginx_config` will use the file conf/nginx.conf -# Create a dedicated nginx config - if [ "$path_url" != "/" ] then ynh_replace_string "^#sub_path_only" "" "/etc/nginx/conf.d/$domain.d/$app.conf" From 6c15e5906b43eb39e6343abdcf077f4973820fd5 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 4 Jun 2020 00:27:34 +0200 Subject: [PATCH 11/23] try debug upgrade and backup --- scripts/change_url | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index f544340..f945988 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,22 +28,6 @@ ynh_script_progression --message="Loading installation settings..." --time --wei # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # 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" - - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED From 70371fd230594824bd961af62f2d4423bfe5f9e9 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 4 Jun 2020 00:36:48 +0200 Subject: [PATCH 12/23] a mistake in backup --- scripts/backup | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/backup b/scripts/backup index 86f8952..85799e7 100755 --- a/scripts/backup +++ b/scripts/backup @@ -24,6 +24,8 @@ ynh_abort_if_errors #================================================= ynh_print_info --message="Loading installation settings..." +app=$YNH_APP_INSTANCE_NAME + final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) From 9c2a769882cdb6c6afba8c7cdf60e99c407b94f0 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 4 Jun 2020 00:45:35 +0200 Subject: [PATCH 13/23] a mistake in upgrade --- scripts/upgrade | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 62af339..91bb400 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -8,12 +8,6 @@ source /usr/share/yunohost/helpers - -# Exit on command errors and treat unset variables as an error -set -eu - -# Source YunoHost helpers -source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= @@ -24,7 +18,6 @@ app=$YNH_APP_INSTANCE_NAME # Retrieve app settings domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) -admin=$(ynh_app_setting_get --app=$app --key=admin) is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) @@ -100,18 +93,6 @@ then ynh_setup_source --dest_dir="$final_path" fi -# # Retreive sources and install them -# src_path=/var/www/$app -# if [ "$upgrade_type" == "UPGRADE_APP" ] -# then -# ynh_secure_remove $src_path -# mkdir -p $src_path -# ynh_script_progression --message="Upgrading source files..." --time --weight=1 - -# # Download, check integrity, uncompress and patch the source from app.src -# ynh_setup_source --dest_dir=$src_path -# chown -R www-data: $src_path -# fi #================================================= # NGINX CONFIGURATION @@ -130,7 +111,7 @@ fi #================================================= # Set permissions on app files -chown -R root: $final_path +chown -R www-data: $final_path #================================================= # SETUP SSOWAT From 0ad65c1ca3a8576b24e7aea185143cf9e8d914fa Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 4 Jun 2020 05:36:19 +0200 Subject: [PATCH 14/23] adjust syntax for new examples_ynh --- check_process | 20 +++++++++++++------- scripts/change_url | 4 ++-- scripts/install | 13 ++++++------- scripts/remove | 12 +----------- scripts/restore | 12 ++---------- scripts/upgrade | 15 +++++++-------- 6 files changed, 31 insertions(+), 45 deletions(-) diff --git a/check_process b/check_process index 740aae0..8e0b5c4 100644 --- a/check_process +++ b/check_process @@ -2,7 +2,7 @@ auto_remove=1 ; Manifest domain="domain.tld" (DOMAIN) - path="/cesium" (PATH) + path="/path" (PATH) is_public=1 (PUBLIC|public=1|private=0) ; Checks pkg_linter=1 @@ -14,10 +14,16 @@ upgrade=1 backup_restore=1 multi_instance=0 - wrong_user=0 - wrong_path=1 - incorrect_path=1 - corrupt_source=0 - fail_download_source=0 port_already_use=0 - final_path_already_use=0 + change_url=1 +;;; Levels + Level 1=auto + Level 2=auto + Level 3=auto + Level 4=na + Level 5=auto + Level 6=auto + Level 7=auto + Level 8=0 + Level 9=0 + Level 10=0 \ No newline at end of file diff --git a/scripts/change_url b/scripts/change_url index f945988..776fce8 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -23,7 +23,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) @@ -48,7 +48,7 @@ fi #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Updating nginx web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf diff --git a/scripts/install b/scripts/install index 0a0401a..132e32d 100755 --- a/scripts/install +++ b/scripts/install @@ -31,7 +31,7 @@ is_public=$YNH_APP_ARG_IS_PUBLIC #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --time --weight=1 +ynh_script_progression --message="Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" @@ -56,7 +56,7 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --time --weight=1 +ynh_script_progression --message="Setting up source files..." # Retrieve sources and install them ynh_app_setting_set --app=$app --key=final_path --value=$final_path @@ -76,7 +76,7 @@ ynh_app_setting_delete --app=$app --key=skipped_uris #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." --time --weight=1 +ynh_script_progression --message="Configuring nginx web server..." ### `ynh_add_nginx_config` will use the file conf/nginx.conf # Create a dedicated nginx config @@ -91,14 +91,13 @@ fi #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 - +ynh_script_progression --message="Configuring permissions..." # If app is public, add url to SSOWat conf as skipped_uris and read-only mode if [[ $is_public -eq 1 ]]; then # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" -# activate read-only + ynh_permission_update --permission "main" --add "visitors" + # activate read-only ynh_replace_string --match_string='"readonly": false,' --replace_string='"readonly": true,' --target_file="$final_path/config.js" fi diff --git a/scripts/remove b/scripts/remove index d1e1303..99c0aa0 100755 --- a/scripts/remove +++ b/scripts/remove @@ -22,7 +22,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --time --weight=1 +ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -35,16 +35,6 @@ ynh_script_progression --message="Removing nginx web server configuration..." -- # Remove the dedicated nginx config ynh_remove_nginx_config -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 - -# Delete a system user -ynh_system_user_delete --username=$app - #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/restore b/scripts/restore index dee9974..5edab66 100755 --- a/scripts/restore +++ b/scripts/restore @@ -34,7 +34,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 +ynh_script_progression --message="Validating restoration parameters..." ynh_webpath_available --domain=$domain --path_url=$path_url \ || ynh_die --message="Path not available: ${domain}${path_url}" @@ -52,18 +52,10 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 +ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # RESTORE USER RIGHTS #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 91bb400..e8d497a 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -38,7 +38,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 +ynh_script_progression --message="Ensuring downward compatibility..." # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then @@ -58,7 +58,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1 +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 @@ -87,7 +87,7 @@ path_url=$(ynh_normalize_url_path --path_url=$path_url) if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --time --weight=1 + ynh_script_progression --message="Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" @@ -97,7 +97,7 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading nginx web server configuration..." ynh_add_nginx_config @@ -116,14 +116,13 @@ chown -R www-data: $final_path #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 - +ynh_script_progression --message="Configuring permissions..." # If app is public, add url to SSOWat conf as skipped_uris and read-only mode if [[ $is_public -eq 1 ]]; then # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" -# activate read-only + ynh_permission_update --permission "main" --add "visitors" + # activate read-only ynh_replace_string --match_string='"readonly": false,' --replace_string='"readonly": true,' --target_file="$final_path/config.js" fi From 0ad00ba293b80895837added08815ae003d92b08 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 4 Jun 2020 06:27:02 +0200 Subject: [PATCH 15/23] adjust syntax for new examples_ynh --- manifest.json | 2 +- scripts/change_url | 14 +------------- scripts/install | 4 ++-- scripts/remove | 7 +++---- scripts/restore | 4 ++-- scripts/upgrade | 5 ++--- 6 files changed, 11 insertions(+), 25 deletions(-) diff --git a/manifest.json b/manifest.json index afc5e46..5f89554 100644 --- a/manifest.json +++ b/manifest.json @@ -15,7 +15,7 @@ "url": "https://moul.re" }, "requirements": { - "yunohost": ">> 3.5.0" + "yunohost": ">> 3.7.0" }, "multi_instance": false, "services": [ diff --git a/scripts/change_url b/scripts/change_url index 776fce8..72a982b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -52,18 +52,6 @@ ynh_script_progression --message="Updating nginx web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -## Move from sub path to root -#if [ "$new_path" == "/" ] -#then -# ynh_replace_string "\(^.*rewrite.*\^$old_path.* permanent;\)" "#sub_path_only\1" "$nginx_conf_path" -# ynh_replace_string "\(rewrite *\^\)$old_path\$ $old_path/*" "\1$new_path$ $new_path" "$nginx_conf_path" - -# Move to a sub path -#else -# ynh_replace_string "^#sub_path_only" "" "$nginx_conf_path" -# ynh_replace_string "\(rewrite *\^\)$old_path\$ $old_path/*" "\1$new_path$ $new_path/" "$nginx_conf_path" -#fi - # Change the path in the nginx config file if [ $change_path -eq 1 ] then @@ -92,7 +80,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/install b/scripts/install index 132e32d..a2b2c65 100755 --- a/scripts/install +++ b/scripts/install @@ -46,7 +46,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --time --weight=1 +ynh_script_progression --message="Storing installation settings..." # Save app settings ynh_app_setting_set --app=$app --key=domain --value=$domain @@ -104,7 +104,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/remove b/scripts/remove index 99c0aa0..275c66a 100755 --- a/scripts/remove +++ b/scripts/remove @@ -11,7 +11,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -30,7 +30,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -38,8 +38,7 @@ ynh_remove_nginx_config #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 - +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/restore b/scripts/restore index 5edab66..3ce8d38 100755 --- a/scripts/restore +++ b/scripts/restore @@ -23,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -68,7 +68,7 @@ chown -R www-data: $final_path #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index e8d497a..bd7f001 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -11,8 +11,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 - +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME # Retrieve app settings @@ -129,7 +128,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload From 06115bd77ef1a7f6cd6b52cc9d9f7f1f2210b873 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 5 Jun 2020 03:54:15 +0200 Subject: [PATCH 16/23] uncomment the helper-update-version.sh --- helper-update-version.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/helper-update-version.sh b/helper-update-version.sh index 089c11f..cc78f4e 100755 --- a/helper-update-version.sh +++ b/helper-update-version.sh @@ -1,16 +1,16 @@ -#!/bin/bash +!/bin/bash # Retrieve sources, get sha256sum, parse package version and update these strings in manifest, README and /conf/app.src -# URL=$(curl -s https://api.github.com/repos/duniter/cesium/releases/latest | grep "browser_" | grep "web" | head -1 | cut -d\" -f4) -# wget -nc --quiet $URL -P ./tmp -# CHECKSUM=$(sha256sum ./tmp/cesium-*-web.zip | head -c 64) -# sed -i "s/SOURCE_SUM=.*/SOURCE_SUM=${CHECKSUM}/" ./conf/app.src -# sed -i "s#SOURCE_URL=.*#SOURCE_URL=$URL#" ./conf/app.src +URL=$(curl -s https://api.github.com/repos/duniter/cesium/releases/latest | grep "browser_" | grep "web" | head -1 | cut -d\" -f4) +wget -nc --quiet $URL -P ./tmp +CHECKSUM=$(sha256sum ./tmp/cesium-*-web.zip | head -c 64) +sed -i "s/SOURCE_SUM=.*/SOURCE_SUM=${CHECKSUM}/" ./conf/app.src +sed -i "s#SOURCE_URL=.*#SOURCE_URL=$URL#" ./conf/app.src -# VERSION=$(echo $URL | sed "s#https://github.com/duniter/cesium/releases/download/\(.*\)/cesium.*#\1#") -# sed -i "s#\*\*Shipped version:\*\*.*#\*\*Shipped version:\*\* ${VERSION}#" ./README.md -# sed -i "s# \"version\": \".*# \"version\": \"${VERSION}\~ynh1\",#" ./manifest.json +VERSION=$(echo $URL | sed "s#https://github.com/duniter/cesium/releases/download/\(.*\)/cesium.*#\1#") +sed -i "s#\*\*Shipped version:\*\*.*#\*\*Shipped version:\*\* ${VERSION}#" ./README.md +sed -i "s# \"version\": \".*# \"version\": \"${VERSION}\~ynh1\",#" ./manifest.json -# rm -f -R ./tmp +rm -f -R ./tmp -# git commit README.md manifest.json conf/app.src -m "$VERSION" +git commit README.md manifest.json conf/app.src -m "$VERSION" From 5d5fc67dade59e0f34efe56125965d183b8a36c2 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 5 Jun 2020 04:16:05 +0200 Subject: [PATCH 17/23] change version value ~ynh1 to ~ynh3 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 5f89554..dcb85b2 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Duniter client to manage wallets, certifications in a libre money.", "fr": "Client Duniter pour gérer ses portes-monnaie, les certifications au sein d’une monnaie libre." }, - "version": "v1.6.7~ynh1", + "version": "v1.6.7~ynh3", "url": "https://github.com/duniter/cesium", "license": "AGPL-3.0-or-later", "maintainer": { From 74454d32d2ffa84306f2de5e2f7953754523d0f8 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 5 Jun 2020 23:31:23 +0200 Subject: [PATCH 18/23] add more indicators to help users know the progression of the scripts and delete --time in ynh_script_progression --- scripts/backup | 2 ++ scripts/change_url | 6 ++---- scripts/upgrade | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/backup b/scripts/backup index 85799e7..28fe666 100755 --- a/scripts/backup +++ b/scripts/backup @@ -42,12 +42,14 @@ ynh_print_info --message="Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= +ynh_print_info --message="backing up the files..." ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= +ynh_print_info --message="backing up nginx.conf..." ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" diff --git a/scripts/change_url b/scripts/change_url index 72a982b..e9a2aff 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -32,6 +32,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= +ynh_print_info --message="checking parts should be changed..." change_domain=0 if [ "$old_domain" != "$new_domain" ] @@ -64,7 +65,6 @@ then ynh_add_nginx_config fi - # Change the domain for nginx if [ $change_domain -eq 1 ] then @@ -75,8 +75,6 @@ then ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi - - #================================================= # RELOAD NGINX #================================================= @@ -88,5 +86,5 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --time --last +ynh_script_progression --message="Change of URL completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index bd7f001..699f0e3 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -136,4 +136,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --time --last \ No newline at end of file +ynh_script_progression --message="Upgrade of $app completed" \ No newline at end of file From 229a054a4791d2807a0f49f32a41aa5783e7765b Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Sat, 6 Jun 2020 00:00:22 +0200 Subject: [PATCH 19/23] add more indicators to help users know the progression of the scripts and delete --time in ynh_script_progression in scipts --- scripts/install | 2 +- scripts/remove | 2 +- scripts/restore | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index a2b2c65..0c9beff 100755 --- a/scripts/install +++ b/scripts/install @@ -112,4 +112,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --time --last \ No newline at end of file +ynh_script_progression --message="Installation of $app completed" \ No newline at end of file diff --git a/scripts/remove b/scripts/remove index 275c66a..dd743b4 100755 --- a/scripts/remove +++ b/scripts/remove @@ -45,7 +45,7 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --time --last +ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 3ce8d38..eff6ac1 100755 --- a/scripts/restore +++ b/scripts/restore @@ -76,4 +76,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --time --last \ No newline at end of file +ynh_script_progression --message="Restoration completed for $app" \ No newline at end of file From 504afdd00b4c7b28c13d16a0958f4dc3cd724e39 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 11 Jun 2020 14:22:02 +0200 Subject: [PATCH 20/23] add an 'help' key for argument 'is_public' --- manifest.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manifest.json b/manifest.json index 5f89554..889219f 100644 --- a/manifest.json +++ b/manifest.json @@ -49,6 +49,10 @@ "en": "Is it a public application?", "fr": "Est-ce une application publique ?" }, + "help": { + "en": "If it is a public application, there will not have authentification" + "fr": "Si l'application est publique, il n'y aura pas d'authentification" + }, "default": false } ] From 259888e517644c6aecff5d89bd51d810c3ff790f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 15 Jun 2020 01:58:37 +0200 Subject: [PATCH 21/23] Apply last example_ynh --- README.md | 37 +++++++++++++++++++++++--------- check_process | 19 ++++++++--------- issue_template.md | 46 ++++++++++++++++++++++++++++++++++++++++ pull_request_template.md | 18 ++++++++++++++++ scripts/_common.sh | 20 +++++++++++++++++ scripts/backup | 12 ++--------- scripts/change_url | 4 ++-- scripts/install | 45 +++++++++++++++++++-------------------- scripts/remove | 11 +--------- scripts/restore | 8 ++++--- scripts/upgrade | 20 +++++++---------- 11 files changed, 160 insertions(+), 80 deletions(-) create mode 100644 issue_template.md create mode 100644 pull_request_template.md create mode 100644 scripts/_common.sh diff --git a/README.md b/README.md index 425c4e8..836ec36 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,42 @@ # Cesium package for YunoHost -[![Integration level](https://dash.yunohost.org/integration/cesium.svg)](https://dash.yunohost.org/appci/app/cesium) ![](https://ci-apps.yunohost.org/ci/badges/cesium.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/cesium.maintain.svg) -[![Install Custom Webapp with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=cesium) +[![Integration level](https://dash.yunohost.org/integration/cesium.svg)](https://dash.yunohost.org/appci/app/cesium) ![](https://ci-apps.yunohost.org/ci/badges/cesium.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/cesium.maintain.svg) +[![Install Cesium with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=cesium) -> *This package allow you to install Cesium quickly and simply on a YunoHost server. -If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* +> *This package allows you to install Cesium 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 - [Cesium](https://cesium.app) is an [Unhosted webapp](https://unhosted.org) client for any [Duniter](https://duniter.org) crypto-currency. It allows you to manage your wallet, certify your friends, and more ! **Shipped version:** v1.6.7 +## YunoHost specific features + +#### Supported architectures + +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/cesium%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/cesium/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/cesium%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/cesium/) + ## Links -- [YunoHost website](https://yunohost.org) -- [Duniter website](https://duniter.org) -- [Cesium repository](https://github.com/duniter/cesium) + * Report a bug: https://github.com/YunoHost-Apps/cesium_ynh/issues + * App website: https://duniter.org + * Upstream app repository: https://github.com/duniter/cesium + * YunoHost website: https://yunohost.org/ -## License +--- -This software is distributed under [GNU AGPL-3.0](https://raw.github.com/duniter/cesium/master/LICENSE). +Developer info +---------------- + +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/cesium_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/cesium_ynh/tree/testing --debug +or +sudo yunohost app upgrade cesium -u https://github.com/YunoHost-Apps/cesium_ynh/tree/testing --debug +``` diff --git a/check_process b/check_process index 8e0b5c4..a07eca3 100644 --- a/check_process +++ b/check_process @@ -1,5 +1,4 @@ ;; Test complet - auto_remove=1 ; Manifest domain="domain.tld" (DOMAIN) path="/path" (PATH) @@ -12,18 +11,18 @@ setup_private=1 setup_public=1 upgrade=1 + # v1.6.7~ynh1 + upgrade=1 from_commit=99330d46e45662b922de84e2e48ad1b15a63bb6e backup_restore=1 multi_instance=0 port_already_use=0 change_url=1 ;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto - Level 4=na + # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 \ No newline at end of file +;;; Options +Email= +Notification=none +;;; Upgrade options + ; commit=99330d46e45662b922de84e2e48ad1b15a63bb6e + name=v1.6.7~ynh1 diff --git a/issue_template.md b/issue_template.md new file mode 100644 index 0000000..4cdd5f7 --- /dev/null +++ b/issue_template.md @@ -0,0 +1,46 @@ +--- +name: Bug report +about: Create a report to help us debug, it would be nice to fill the template as much as you can to help us, help you and help us all. + +--- + +**How to post a meaningful bug report** +1. *Read this whole template first.* +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!* + - *Otherwise, the issue may be due to Cesium itself. Refer to its documentation or repository for help.* + - *If you have a doubt, post here, we will figure it out together.* +3. *Delete the italic comments as you write over them below, and remove this guide.* +--- + +**Describe the bug** +*A clear and concise description of what the bug is.* + +**Versions** +- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* +- YunoHost version: x.x.x +- 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* + - If yes, please explain: +- 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`* + +**To Reproduce** +*Steps to reproduce the behavior.* +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install cesium + ``` +- *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:* + 1. *Go to '...'* + 2. *Click on '....'* + 3. *Scroll down to '....'* + 4. *See error* + +**Expected behavior** +*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* + +**Logs** +*After a failed command, YunoHost makes the log available to you, but also to others, thanks to `yunohost log display [log name] --share`. The actual command, with the correct log name, is displayed at the end of the failed attempt in the CLI. Execute it and copy here the share link it outputs.* +*If applicable and useful, add screenshots to help explain your problem.* diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 0000000..57c93b6 --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,18 @@ +## 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/cesium_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/cesium_ynh%20PR-NUM-%20(USERNAME)/) diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..ecd263f --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +#================================================= +# COMMON VARIABLES +#================================================= + +# dependencies used by the app +pkg_dependencies="" + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/backup b/scripts/backup index 28fe666..f42c579 100755 --- a/scripts/backup +++ b/scripts/backup @@ -6,6 +6,8 @@ # 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 /usr/share/yunohost/helpers #================================================= @@ -13,7 +15,6 @@ source /usr/share/yunohost/helpers #================================================= 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 @@ -34,22 +35,15 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= ynh_print_info --message="Declaring files to be backed up..." -### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs -### to be backuped and not an actual copy of any file. The actual backup that -### creates and fill the archive with the files happens in the core after this -### script is called. Hence ynh_backups calls takes basically 0 seconds to run. - #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info --message="backing up the files..." ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_print_info --message="backing up nginx.conf..." ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -58,5 +52,3 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." - - diff --git a/scripts/change_url b/scripts/change_url index e9a2aff..48ee001 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -32,7 +33,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= -ynh_print_info --message="checking parts should be changed..." +ynh_script_progression --message="checking parts should be changed..." change_domain=0 if [ "$old_domain" != "$new_domain" ] @@ -87,4 +88,3 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= ynh_script_progression --message="Change of URL completed for $app" - diff --git a/scripts/install b/scripts/install index 0c9beff..03e125b 100644 --- a/scripts/install +++ b/scripts/install @@ -1,10 +1,12 @@ #!/bin/bash + #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -12,7 +14,6 @@ source /usr/share/yunohost/helpers #================================================= 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 @@ -22,12 +23,12 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -# Retrieve arguments -app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC +app=$YNH_APP_INSTANCE_NAME + #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= @@ -35,11 +36,7 @@ ynh_script_progression --message="Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) -# Check web path availability -ynh_webpath_available $domain $path_url # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url @@ -48,7 +45,6 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= ynh_script_progression --message="Storing installation settings..." -# Save app settings ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=is_public --value=$is_public @@ -58,21 +54,10 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= ynh_script_progression --message="Setting up source files..." -# Retrieve sources and install them ynh_app_setting_set --app=$app --key=final_path --value=$final_path - # Download, check integrity, uncompress and patch the source from app.src - +# Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" -#================================================= -# Permissions files -#================================================= - -chown -R www-data: $final_path - -# Remove the public access -ynh_app_setting_delete --app=$app --key=skipped_uris - #================================================= # NGINX CONFIGURATION #================================================= @@ -88,13 +73,27 @@ then ynh_replace_string "^#sub_path_only" "" "/etc/nginx/conf.d/$domain.d/$app.conf" fi +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= +ynh_script_progression --message="Securing files and directories..." + +# Set permissions to app files +chown -R www-data: $final_path + #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." +ynh_script_progression --message="Configuring SSOwat..." + +# Remove the public access +ynh_app_setting_delete --app=$app --key=skipped_uris # If app is public, add url to SSOWat conf as skipped_uris and read-only mode -if [[ $is_public -eq 1 ]]; then +if [ $is_public -eq 1 ] +then # unprotected_uris allows SSO credentials to be passed anyway. ynh_permission_update --permission "main" --add "visitors" # activate read-only @@ -112,4 +111,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" \ No newline at end of file +ynh_script_progression --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index dd743b4..c9e6648 100755 --- a/scripts/remove +++ b/scripts/remove @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -35,18 +36,8 @@ ynh_script_progression --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading nginx web server..." -ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Removal of $app completed" - - - - diff --git a/scripts/restore b/scripts/restore index eff6ac1..fbb2c74 100755 --- a/scripts/restore +++ b/scripts/restore @@ -7,6 +7,7 @@ #================================================= #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= @@ -14,7 +15,6 @@ source /usr/share/yunohost/helpers #================================================= 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 @@ -23,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -46,6 +46,7 @@ test ! -d $final_path \ #================================================= # 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" @@ -59,6 +60,7 @@ ynh_restore_file --origin_path="$final_path" #================================================= # RESTORE USER RIGHTS #================================================= +ynh_script_progression --message="Restoring user rights..." # Restore permissions on app files chown -R www-data: $final_path @@ -76,4 +78,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" \ No newline at end of file +ynh_script_progression --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 699f0e3..eb14649 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -6,34 +6,29 @@ # IMPORT GENERIC HELPERS #================================================= +source _common.sh source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= ynh_script_progression --message="Loading installation settings..." + app=$YNH_APP_INSTANCE_NAME -# Retrieve app settings + domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) - #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." -### This helper will compare the version of the currently installed app and the version of the upstream package. -### $upgrade_type can have 2 different values -### - UPGRADE_APP if the upstream app version has changed -### - UPGRADE_PACKAGE if only the YunoHost package has changed -### ynh_check_app_version_changed will stop the upgrade if the app is up to date. -### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. upgrade_type=$(ynh_check_app_version_changed) - #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -92,12 +87,12 @@ then ynh_setup_source --dest_dir="$final_path" fi - #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Upgrading nginx web server configuration..." +# Create a dedicated nginx config ynh_add_nginx_config if [ "$path_url" != "/" ] @@ -108,6 +103,7 @@ fi #================================================= # SECURE FILES AND DIRECTORIES #================================================= +ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R www-data: $final_path @@ -115,7 +111,7 @@ chown -R www-data: $final_path #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." +ynh_script_progression --message="Upgrading SSOwat configuration..." # If app is public, add url to SSOWat conf as skipped_uris and read-only mode if [[ $is_public -eq 1 ]]; then @@ -136,4 +132,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" \ No newline at end of file +ynh_script_progression --message="Upgrade of $app completed" From 12c365e2849a2a526c89b63c618043dbb62d7ed8 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Mon, 15 Jun 2020 11:13:25 +0200 Subject: [PATCH 22/23] exepting delimiter on manifest.json file --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 889219f..bd82c1a 100644 --- a/manifest.json +++ b/manifest.json @@ -50,7 +50,7 @@ "fr": "Est-ce une application publique ?" }, "help": { - "en": "If it is a public application, there will not have authentification" + "en": "If it is a public application, there will not have authentification", "fr": "Si l'application est publique, il n'y aura pas d'authentification" }, "default": false From 76ee052ac3577a05d3f582e490acb66d816e2d0e Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 17 Jun 2020 14:35:41 +0200 Subject: [PATCH 23/23] indexation in manifest --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index bd82c1a..a0ffb24 100644 --- a/manifest.json +++ b/manifest.json @@ -34,7 +34,7 @@ }, { "name": "path", - "type": "path", + "type": "path", "ask": { "en": "Choose a path for Cesium", "fr": "Choisissez un chemin pour Césium"