From bb384b72308db306a9cb137f3d912419db3c4859 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 4 Mar 2019 17:17:05 +0100 Subject: [PATCH 1/8] Normalization from example_ynh --- README.md | 69 +++++++++++++++++++++++++++-------- check_process | 16 ++++----- conf/nginx.conf | 12 +++++-- scripts/_common.sh | 90 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/_future.sh | 45 ----------------------- scripts/backup | 5 ++- scripts/change_url | 41 ++++++++++----------- scripts/install | 38 +++++++++++++++----- scripts/remove | 1 + scripts/restore | 18 ++++++---- scripts/upgrade | 77 ++++++++++++++++++++++++--------------- 11 files changed, 275 insertions(+), 137 deletions(-) create mode 100644 scripts/_common.sh delete mode 100644 scripts/_future.sh diff --git a/README.md b/README.md index 5d6727a..84fce7a 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,67 @@ -strut_ynh -=============== +# Strut for YunoHost -Strut package for YunoHost +[![Integration level](https://dash.yunohost.org/integration/strut.svg)](https://dash.yunohost.org/appci/app/strut) +[![Install Strut with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=strut) -## IMPORTANT NOTE ABOUT THIS PACKAGE -This package doesn't contained the exact sources of the upstream https://github.com/tantaman/Strut. +> *This package allow you to install Strut 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 +Quick description of this app. + +**Shipped version:** 20171224-1 + +## Screenshots + +![](https://f.cloud.github.com/assets/1009003/515405/f1003c6a-be74-11e2-84b9-14776c652afb.png) + +## Demo + +* [Official demo](http://strut.io/editor/index.html) + +## Configuration + +## Documentation + + * YunoHost documentation: If specific documentation is needed, feel free to contribute. + +## YunoHost specific features + +#### Multi-users support + +#### Supported architectures + +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/strut%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/strut/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/strut%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/strut/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/strut%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/strut/) + +## Limitations + +## Additional information + +* This package doesn't contained the exact sources of the upstream https://github.com/tantaman/Strut. Initial Strut software includes Google Analytics and is bind to Imgur to upload images. This kind of trackers or external services are not accepted by the package team of YunoHost. So this trackers are removed from sources, a pull request has been done and merged but has finally be removed from the strut upstream with no explanation. In more, Strut developers don't deliver builded versions. To build a version it needs grunt, that can't be removed easily. To avoid to take time to build this html/js app, this package setups a builded version of Strut with the patch that remove Google Analytics and Imgur dependencies. It is a build of this version https://github.com/tantaman/Strut/commits/6761b141ee7aa622916e2d23cced84ee95618cce . So it's not the more recent version. +## Links -## Official Website: http://strut.io + * Report a bug: https://github.com/YunoHost-Apps/strut_ynh/issues + * Strut website: http://strut.io + * YunoHost website: https://yunohost.org/ -## About Strut +--- -[![Facelift](https://f.cloud.github.com/assets/1009003/515405/f1003c6a-be74-11e2-84b9-14776c652afb.png)](http://strut.io) +Developers info +---------------- -#### A GUI / Authoring Tool for ImpressJS and Bespoke.js #### - -Don't know what ImpressJS is? Check out the ImpressJS demo presentation: http://bartaz.github.com/impress.js/#/bored - -### Start using Strut! http://strut.io/editor/ -(works in Firefox, Chrome and Safari with basic support for IE10) +**Only if you want to use a testing branch for coding, instead of merging directly into master.** +Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/strut_ynh/tree/testing). +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/strut_ynh/tree/testing --debug +or +sudo yunohost app upgrade strut -u https://github.com/YunoHost-Apps/strut_ynh/tree/testing --debug +``` diff --git a/check_process b/check_process index e67c026..59838f1 100644 --- a/check_process +++ b/check_process @@ -1,5 +1,3 @@ -# See here for more informations -# https://github.com/YunoHost/package_check#syntax-check_process-file ;; Test complet ; Manifest domain="domain.tld" (DOMAIN) @@ -13,7 +11,7 @@ setup_private=1 setup_public=1 upgrade=1 -# upgrade=1 from_commit=03c3ea18cf117127749a860afe538bc6070a8e0b + upgrade=1 from_commit=f6565f66d82fa077d752226f8b8267018f7b91d8 backup_restore=1 multi_instance=1 incorrect_path=1 @@ -29,13 +27,13 @@ Level 5=auto Level 6=auto Level 7=auto -# Level 8=1 -# Level 9=1 + Level 8=0 + Level 9=0 Level 10=0 ;;; Options Email=ljf+ynh-strut@grimaud.me Notification=down -#;;; Upgrade options -# ; commit=03c3ea18cf117127749a860afe538bc6070a8e0b -# name=Update package to level 7 -# manifest_arg=domain=DOMAIN&path=PATH&is_public=Yes& +;;; Upgrade options + ; commit=f6565f66d82fa077d752226f8b8267018f7b91d8 + name=May 27, 2018 + manifest_arg=domain=DOMAIN&path=PATH&is_public=Yes& diff --git a/conf/nginx.conf b/conf/nginx.conf index 076d2f1..5b29d2d 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,10 +1,18 @@ -location __PATH__ { - alias __FINALPATH__/; +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { + + # Path to source + alias __FINALPATH__/ ; + + # Force usage of https if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } + index index.html; try_files $uri $uri/ /index.html; + + # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; } diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..b0f99a4 --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,90 @@ +#!/bin/bash + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= + +# Read the value of a key in a ynh manifest file +# +# usage: ynh_read_manifest manifest key +# | arg: -m, --manifest= - Path of the manifest to read +# | arg: -k, --key= - Name of the key to find +ynh_read_manifest () { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [m]=manifest= [k]=manifest_key= ) + local manifest + local manifest_key + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + if [ ! -e "$manifest" ]; then + # If the manifest isn't found, try the common place for backup and restore script. + manifest="../settings/manifest.json" + fi + + jq ".$manifest_key" "$manifest" --raw-output +} + +# Read the upstream version from the manifest +# The version number in the manifest is defined by ~ynh +# For example : 4.3-2~ynh3 +# This include the number before ~ynh +# In the last example it return 4.3-2 +# +# usage: ynh_app_upstream_version [-m manifest] +# | arg: -m, --manifest= - Path of the manifest to read +ynh_app_upstream_version () { + declare -Ar args_array=( [m]=manifest= ) + local manifest + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + manifest="${manifest:-../manifest.json}" + version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version") + echo "${version_key/~ynh*/}" +} + +# Checks the app version to upgrade with the existing app version and returns: +# - UPGRADE_APP if the upstream app version has changed +# - UPGRADE_PACKAGE if only the YunoHost package has changed +# +## It stops the current script without error if the package is up-to-date +# +# This helper should be used to avoid an upgrade of an app, or the upstream part +# of it, when it's not needed +# +# To force an upgrade, even if the package is up to date, +# you have to set the variable YNH_FORCE_UPGRADE before. +# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp +# +# usage: ynh_check_app_version_changed +ynh_check_app_version_changed () { + local force_upgrade=${YNH_FORCE_UPGRADE:-0} + local package_check=${PACKAGE_CHECK_EXEC:-0} + + # By default, upstream app version has changed + local return_value="UPGRADE_APP" + + local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version" || echo 1.0) + local current_upstream_version="$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json")" + local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version" || echo 1.0) + local update_upstream_version="$(ynh_app_upstream_version)" + + if [ "$current_version" == "$update_version" ] ; then + # Complete versions are the same + if [ "$force_upgrade" != "0" ] + then + echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2 + unset YNH_FORCE_UPGRADE + elif [ "$package_check" != "0" ] + then + echo "Upgrade forced for package check." >&2 + else + ynh_die "Up-to-date, nothing to do" 0 + fi + elif [ "$current_upstream_version" == "$update_upstream_version" ] ; then + # Upstream versions are the same, only YunoHost package versions differ + return_value="UPGRADE_PACKAGE" + fi + echo $return_value +} diff --git a/scripts/_future.sh b/scripts/_future.sh deleted file mode 100644 index 2fa9421..0000000 --- a/scripts/_future.sh +++ /dev/null @@ -1,45 +0,0 @@ - -log() { - echo "${1}" -} - -info() { - log "[INFO] ${1}" -} - -warn() { - log "[WARN] ${1}" -} - -err() { - log "[ERR] ${1}" -} -to_logs() { - - # When yunohost --verbose or bash -x - if $_ISVERBOSE; then - cat - else - cat > /dev/null - fi -} - -read_json () { - sudo python3 -c "import sys, json;print(json.load(open('$1'))['$2'])" -} - -read_manifest () { - if [ -f '../manifest.json' ] ; then - read_json '../manifest.json' "$1" - else - read_json '../settings/manifest.json' "$1" - fi -} -abort_if_up_to_date () { - version=$(read_json "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" 'version' 2> /dev/null || echo '20160501-7') - last_version=$(read_manifest 'version') - if [ "${version}" = "${last_version}" ]; then - info "Up-to-date, nothing to do" - ynh_die "" 0 - fi -} diff --git a/scripts/backup b/scripts/backup index 49c218f..0335e62 100644 --- a/scripts/backup +++ b/scripts/backup @@ -5,12 +5,15 @@ #================================================= # IMPORT GENERIC HELPERS #================================================= + +# source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +# Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= @@ -19,8 +22,8 @@ ynh_abort_if_errors app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get $app final_path) domain=$(ynh_app_setting_get $app domain) +final_path=$(ynh_app_setting_get $app final_path) #================================================= # STANDARD BACKUP STEPS diff --git a/scripts/change_url b/scripts/change_url index 84ce565..8724455 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -source _future.sh +# source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -21,6 +21,13 @@ new_path=$YNH_APP_NEW_PATH app=$YNH_APP_INSTANCE_NAME +#================================================= +# LOAD SETTINGS +#================================================= + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get $app final_path) + #================================================= # CHECK THE SYNTAX OF THE PATHS #================================================= @@ -46,16 +53,6 @@ then change_path=1 fi -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= - -#ynh_backup_before_upgrade # Backup the current version of the app -#ynh_clean_setup () { -# ynh_restore_upgradebackup # restore it if the upgrade fails -#} -#ynh_abort_if_errors # Exit if an error occurs during the execution of the script - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -67,25 +64,25 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf # Change the path in the nginx config file if [ $change_path -eq 1 ] then - # Replace locations starting with old_path - # Look for every location possible patterns (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location) - sed --in-place "s@location\( \(=\|~\|~\*\|\^~\)\)\? $old_path@location\1 $new_path@" "$nginx_conf_path" - # Replace path in "return" directives - sed --in-place "s@return \([[:digit:]]\{3\}\) $old_path@return \1 $new_path@" "$nginx_conf_path" + # Make a backup of the original nginx config file if modified + ynh_backup_if_checksum_is_different "$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 "$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 "/etc/nginx/conf.d/$new_domain.d/$app.conf" fi -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= - #================================================= # GENERIC FINALISATION #================================================= diff --git a/scripts/install b/scripts/install index 363394b..f58ac03 100644 --- a/scripts/install +++ b/scripts/install @@ -1,21 +1,25 @@ #!/bin/bash + #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= -#source _common.sh + +# source _common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= + # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= + domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC @@ -25,6 +29,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= + final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -34,36 +39,50 @@ ynh_webpath_register $app $domain $path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= + +ynh_app_setting_set $app domain $domain +ynh_app_setting_set $app path $path_url ynh_app_setting_set $app is_public $is_public +#================================================= +# STANDARD MODIFICATIONS #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= + ynh_app_setting_set $app final_path $final_path # Download, check integrity, uncompress and patch the source from app.src # For this app sources are in app subdirectory tmp_dir=$(mktemp -d) -ynh_clean_setup () { - ynh_secure_remove "$tmp_dir" -} + ynh_setup_source "$tmp_dir" mv "$tmp_dir/dist" "$final_path" -# Imgur is deactivated on the specific upstream selected, but this text is still here -# Don't use a patch because it's minified js -ynh_replace_string "are currently uploaded to imgur.*re working on changing this" "size is limited" "$final_path/scripts/amd-app.js" ynh_secure_remove "$tmp_dir" + #================================================= # NGINX CONFIGURATION #================================================= + # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# SPECIFIC SETUP +#================================================= +# PATCH SOURCE +#================================================= + +# Imgur is deactivated on the specific upstream selected, but this text is still here +# Don't use a patch because it's minified js +ynh_replace_string "are currently uploaded to imgur.*re working on changing this" "size is limited" "$final_path/scripts/amd-app.js" + #================================================= # GENERIC FINALIZATION #================================================= # SECURE FILES AND DIRECTORIES #================================================= -# Set strong right permissions to app files + +# Set permissions to app files chown -R root:www-data "$final_path" chmod -R 640 "$final_path" find "$final_path" -type d -print0 | xargs -0 chmod 750 @@ -72,7 +91,7 @@ find "$final_path" -type d -print0 | xargs -0 chmod 750 # SETUP SSOWAT #================================================= -# Make app public if necessary or protect it +# Make app public if necessary if [ $is_public -eq 1 ] then ynh_app_setting_set $app skipped_uris "/" @@ -81,4 +100,5 @@ fi #================================================= # RELOAD NGINX #================================================= + systemctl reload nginx diff --git a/scripts/remove b/scripts/remove index d57b7a1..189e322 100644 --- a/scripts/remove +++ b/scripts/remove @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +# source _common.sh source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/restore b/scripts/restore index 53cac08..3e8ea37 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,13 +6,14 @@ # IMPORT GENERIC HELPERS #================================================= -#source ../settings/scripts/_common.sh +# source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -# Exit on command errors and treat access to unset variables as an error + +# Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= @@ -33,17 +34,20 @@ ynh_webpath_available $domain $path_url \ || ynh_die "Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die "There is already a directory: $final_path " -conf="/etc/nginx/conf.d/$domain.d/$app.conf" -test ! -f $conf \ - || ynh_die "There is already a nginx conf file at this path: $conf " #================================================= # STANDARD RESTORATION STEPS #================================================= -# RESTORE BACKUP FILES +# RESTORE THE NGINX CONFIGURATION #================================================= -ynh_restore +ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= + +ynh_restore_file "$final_path" #================================================= # RESTORE USER RIGHTS diff --git a/scripts/upgrade b/scripts/upgrade index c91b8ab..0f45516 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -source _future.sh +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -21,19 +21,10 @@ is_public=$(ynh_app_setting_get $app is_public) final_path=$(ynh_app_setting_get $app final_path) #================================================= -# Check version -#================================================= -abort_if_up_to_date - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# CHECK VERSION #================================================= -ynh_backup_before_upgrade # Backup the current version of the app -ynh_clean_setup () { - ynh_restore_upgradebackup # restore it if the upgrade fails -} -ynh_abort_if_errors # Exit if an error occurs during the execution of the script +upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -50,14 +41,27 @@ if [ "${version}" = "20160501-7" ]; then is_public=0 fi ynh_app_setting_delete $app public_site - + # If final_path doesn't exist, create it - if [ -z $final_path ]; then + if [ -z "$final_path" ]; then final_path=/var/www/$app ynh_app_setting_set $app final_path $final_path fi fi +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= + +# 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 #================================================= @@ -71,16 +75,21 @@ path_url=$(ynh_normalize_url_path $path_url) # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -# Download, check integrity, uncompress and patch the source from app.src -# For this app sources are in app subdirectory -tmp_dir=$(mktemp -d) -ynh_setup_source "$tmp_dir" -# Dist is the compiled version. Other directories are source code and tools to build the program -cp -R "$tmp_dir/dist/." "$final_path/" -# Imgur is deactivated on the specific upstream selected, but this text is still here -# Don't use a patch because it's minified js -ynh_replace_string "are currently uploaded to imgur.*re working on changing this" "size is limited" "$final_path/scripts/amd-app.js" -ynh_secure_remove "$tmp_dir" +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + # Download, check integrity, uncompress and patch the source from app.src + # For this app sources are in app subdirectory + tmp_dir=$(mktemp -d) + + ynh_setup_source "$tmp_dir" + # Dist is the compiled version. Other directories are source code and tools to build the program + cp -a "$tmp_dir/dist/." "$final_path/" + ynh_secure_remove "$tmp_dir" + + # Imgur is deactivated on the specific upstream selected, but this text is still here + # Don't use a patch because it's minified js + ynh_replace_string "are currently uploaded to imgur.*re working on changing this" "size is limited" "$final_path/scripts/amd-app.js" +fi #================================================= # NGINX CONFIGURATION @@ -89,13 +98,26 @@ ynh_secure_remove "$tmp_dir" # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# SPECIFIC UPGRADE +#================================================= +# PATCH SOURCE +#================================================= + +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + # Imgur is deactivated on the specific upstream selected, but this text is still here + # Don't use a patch because it's minified js + ynh_replace_string "are currently uploaded to imgur.*re working on changing this" "size is limited" "$final_path/scripts/amd-app.js" +fi + #================================================= # GENERIC FINALIZATION #================================================= # SECURE FILES AND DIRECTORIES #================================================= -# Set strong right permissions +# Set permissions on app files chown -R root:www-data "$final_path" chmod -R 640 "$final_path" find "$final_path" -type d -print0 | xargs -0 chmod 750 @@ -104,15 +126,14 @@ find "$final_path" -type d -print0 | xargs -0 chmod 750 # SETUP SSOWAT #================================================= -# Make app public if necessary or protect it +# Make app public if necessary if [ $is_public -eq 1 ] then ynh_app_setting_set $app skipped_uris "/" -else - ynh_app_setting_set $app protected_uris "/" fi #================================================= # RELOAD NGINX #================================================= + systemctl reload nginx From 3ae3d1a19ce0f988e6e54c29a9dd82bef72dcc59 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 4 Mar 2019 17:17:31 +0100 Subject: [PATCH 2/8] Add progression with ynh_print_info --- manifest.json | 2 +- scripts/backup | 9 +++++++++ scripts/change_url | 9 +++++++++ scripts/install | 12 ++++++++++++ scripts/remove | 9 +++++++++ scripts/restore | 10 ++++++++++ scripts/upgrade | 14 ++++++++++++++ 7 files changed, 64 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index dab9586..a57ed94 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "url": "http://strut.io", "license": "AGPL-3.0", "requirements": { - "yunohost": ">= 2.7.2" + "yunohost": ">= 3.2.0" }, "description": { "en": "Strut is a slide editor creating impress.js presentations.", diff --git a/scripts/backup b/scripts/backup index 0335e62..effa06b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -19,6 +19,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -30,11 +31,19 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # BACKUP THE APP MAIN DIR #================================================= +ynh_print_info "Backing up the main app directory..." ynh_backup "$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= +ynh_print_info "Backing up nginx web server configuration..." ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "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 8724455..6ef2a0f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,6 +24,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get $app final_path) @@ -58,6 +59,7 @@ fi #================================================= # MODIFY URL IN NGINX CONF #================================================= +ynh_print_info "Updating nginx web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -88,5 +90,12 @@ fi #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reloading nginx web server..." systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index f58ac03..231fecf 100644 --- a/scripts/install +++ b/scripts/install @@ -29,6 +29,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +ynh_print_info "Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -39,6 +40,7 @@ ynh_webpath_register $app $domain $path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_print_info "Storing installation settings..." ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url @@ -49,6 +51,7 @@ ynh_app_setting_set $app is_public $is_public #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_print_info "Setting up source files..." ynh_app_setting_set $app final_path $final_path # Download, check integrity, uncompress and patch the source from app.src @@ -62,6 +65,7 @@ ynh_secure_remove "$tmp_dir" #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info "Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config @@ -90,6 +94,7 @@ find "$final_path" -type d -print0 | xargs -0 chmod 750 #================================================= # SETUP SSOWAT #================================================= +ynh_print_info "Configuring SSOwat..." # Make app public if necessary if [ $is_public -eq 1 ] @@ -100,5 +105,12 @@ fi #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reloading nginx web server..." systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 189e322..216a0f6 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -23,6 +24,7 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # REMOVE APP MAIN DIR #================================================= +ynh_print_info "Removing app main directory" # Remove the app directory securely ynh_secure_remove "$final_path" @@ -30,6 +32,13 @@ ynh_secure_remove "$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_print_info "Removing nginx web server configuration" # Remove the dedicated nginx config ynh_remove_nginx_config + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 3e8ea37..9186e5e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -19,6 +19,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -29,6 +30,7 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= +ynh_print_info "Validating restoration parameters..." ynh_webpath_available $domain $path_url \ || ynh_die "Path not available: ${domain}${path_url}" @@ -46,6 +48,7 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= +ynh_print_info "Restoring the app main directory..." ynh_restore_file "$final_path" @@ -63,5 +66,12 @@ find "$final_path" -type d -print0 | xargs -0 chmod 750 #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reloading nginx web server and php-fpm..." systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 0f45516..55e3508 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -29,6 +30,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= +ynh_print_info "Ensuring downward compatibility..." if [ "${version}" = "20160501-7" ]; then public_site=$(ynh_app_setting_get $app public_site) @@ -52,6 +54,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_print_info "Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -77,6 +80,8 @@ path_url=$(ynh_normalize_url_path $path_url) if [ "$upgrade_type" == "UPGRADE_APP" ] then + ynh_print_info "Upgrading source files..." + # Download, check integrity, uncompress and patch the source from app.src # For this app sources are in app subdirectory tmp_dir=$(mktemp -d) @@ -94,6 +99,7 @@ fi #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info "Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config @@ -125,6 +131,7 @@ find "$final_path" -type d -print0 | xargs -0 chmod 750 #================================================= # SETUP SSOWAT #================================================= +ynh_print_info "Upgrading SSOwat configuration..." # Make app public if necessary if [ $is_public -eq 1 ] @@ -135,5 +142,12 @@ fi #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reloading nginx web server..." systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Upgrade of $app completed" From da73b6d3abd8434e87881997b97ab8022d9c6831 Mon Sep 17 00:00:00 2001 From: Kayou Date: Tue, 5 Mar 2019 11:54:44 +0100 Subject: [PATCH 3/8] Bump version number --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index a57ed94..0412c24 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "url": "http://strut.io", "license": "AGPL-3.0", "requirements": { - "yunohost": ">= 3.2.0" + "yunohost": ">= 3.2.2" }, "description": { "en": "Strut is a slide editor creating impress.js presentations.", From f24670fa513bcbf0b2cf401e664fac4210341fc5 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 24 Mar 2019 16:47:56 +0100 Subject: [PATCH 4/8] Update pull_request_template.md --- pull_request_template.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pull_request_template.md b/pull_request_template.md index 43734e0..6a03ae6 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -19,7 +19,6 @@ - [ ] **Approval (LGTM)** : - [ ] **Approval (LGTM)** : - **CI succeeded** : -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/strut_ynh%20-BRANCH-%20(Official)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/strut_ynh%20-BRANCH-%20(Official)/) *Please replace '-BRANCH-' in this link for a PR from a local branch.* -or -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/strut_ynh%20PR-NUM-%20(Official_fork)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/strut_ynh%20PR-NUM-%20(Official_fork)/) *Replace '-NUM-' by the PR number in this link for a PR from a forked repository.* +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/strut_ynh%20PR-NUM-/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/strut_ynh%20PR-NUM-/) +*Please replace '-NUM-' in this link by the PR number.* When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. From 963ef176ed41e6b47d25c8615883bf10584e31b5 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 15 Apr 2019 20:54:52 +0200 Subject: [PATCH 5/8] Move from ci-apps-dev to ci-apps-hq --- pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pull_request_template.md b/pull_request_template.md index 6a03ae6..b71dd62 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -19,6 +19,6 @@ - [ ] **Approval (LGTM)** : - [ ] **Approval (LGTM)** : - **CI succeeded** : -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/strut_ynh%20PR-NUM-/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/strut_ynh%20PR-NUM-/) +[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/strut_ynh%20PR-NUM-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/strut_ynh%20PR-NUM-/) *Please replace '-NUM-' in this link by the PR number.* When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. From eb33e5510381a9ea3b6be11a67558b89937fc3d8 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 20 May 2019 17:20:41 +0200 Subject: [PATCH 6/8] Normalization from example_ynh --- README.md | 7 ++-- check_process | 11 ------ manifest.json | 2 +- scripts/_common.sh | 89 ---------------------------------------------- scripts/backup | 16 ++++----- scripts/change_url | 27 +++++--------- scripts/install | 36 +++++++++---------- scripts/remove | 14 ++++---- scripts/restore | 28 +++++++-------- scripts/upgrade | 46 ++++++++++++------------ 10 files changed, 84 insertions(+), 192 deletions(-) diff --git a/README.md b/README.md index 84fce7a..82bed0a 100644 --- a/README.md +++ b/README.md @@ -31,9 +31,9 @@ Quick description of this app. #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/strut%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/strut/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/strut%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/strut/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/strut%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/strut/) +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/strut%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/strut/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/strut%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/strut/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/strut%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/strut/) ## Limitations @@ -49,6 +49,7 @@ To avoid to take time to build this html/js app, this package setups a builded v * Report a bug: https://github.com/YunoHost-Apps/strut_ynh/issues * Strut website: http://strut.io + * Strut repository: https://github.com/MohannadNaj/Strut * YunoHost website: https://yunohost.org/ --- diff --git a/check_process b/check_process index 59838f1..ed5871d 100644 --- a/check_process +++ b/check_process @@ -18,18 +18,7 @@ port_already_use=0 change_url=1 ;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto -# Level 4: - Level 4=1 -# Level 5: Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 ;;; Options Email=ljf+ynh-strut@grimaud.me Notification=down diff --git a/manifest.json b/manifest.json index 0412c24..4657b01 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "url": "http://strut.io", "license": "AGPL-3.0", "requirements": { - "yunohost": ">= 3.2.2" + "yunohost": ">= 3.5.0" }, "description": { "en": "Strut is a slide editor creating impress.js presentations.", diff --git a/scripts/_common.sh b/scripts/_common.sh index b0f99a4..a9bf588 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,90 +1 @@ #!/bin/bash - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= - -# Read the value of a key in a ynh manifest file -# -# usage: ynh_read_manifest manifest key -# | arg: -m, --manifest= - Path of the manifest to read -# | arg: -k, --key= - Name of the key to find -ynh_read_manifest () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [m]=manifest= [k]=manifest_key= ) - local manifest - local manifest_key - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - if [ ! -e "$manifest" ]; then - # If the manifest isn't found, try the common place for backup and restore script. - manifest="../settings/manifest.json" - fi - - jq ".$manifest_key" "$manifest" --raw-output -} - -# Read the upstream version from the manifest -# The version number in the manifest is defined by ~ynh -# For example : 4.3-2~ynh3 -# This include the number before ~ynh -# In the last example it return 4.3-2 -# -# usage: ynh_app_upstream_version [-m manifest] -# | arg: -m, --manifest= - Path of the manifest to read -ynh_app_upstream_version () { - declare -Ar args_array=( [m]=manifest= ) - local manifest - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - manifest="${manifest:-../manifest.json}" - version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version") - echo "${version_key/~ynh*/}" -} - -# Checks the app version to upgrade with the existing app version and returns: -# - UPGRADE_APP if the upstream app version has changed -# - UPGRADE_PACKAGE if only the YunoHost package has changed -# -## It stops the current script without error if the package is up-to-date -# -# This helper should be used to avoid an upgrade of an app, or the upstream part -# of it, when it's not needed -# -# To force an upgrade, even if the package is up to date, -# you have to set the variable YNH_FORCE_UPGRADE before. -# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp -# -# usage: ynh_check_app_version_changed -ynh_check_app_version_changed () { - local force_upgrade=${YNH_FORCE_UPGRADE:-0} - local package_check=${PACKAGE_CHECK_EXEC:-0} - - # By default, upstream app version has changed - local return_value="UPGRADE_APP" - - local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version" || echo 1.0) - local current_upstream_version="$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json")" - local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version" || echo 1.0) - local update_upstream_version="$(ynh_app_upstream_version)" - - if [ "$current_version" == "$update_version" ] ; then - # Complete versions are the same - if [ "$force_upgrade" != "0" ] - then - echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2 - unset YNH_FORCE_UPGRADE - elif [ "$package_check" != "0" ] - then - echo "Upgrade forced for package check." >&2 - else - ynh_die "Up-to-date, nothing to do" 0 - fi - elif [ "$current_upstream_version" == "$update_upstream_version" ] ; then - # Upstream versions are the same, only YunoHost package versions differ - return_value="UPGRADE_PACKAGE" - fi - echo $return_value -} diff --git a/scripts/backup b/scripts/backup index effa06b..deda952 100644 --- a/scripts/backup +++ b/scripts/backup @@ -19,31 +19,31 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD BACKUP STEPS #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info "Backing up the main app directory..." +ynh_script_progression --message="Backing up the main app directory..." -ynh_backup "$final_path" +ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_print_info "Backing up nginx web server configuration..." +ynh_script_progression --message="Backing up nginx web server configuration..." -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last diff --git a/scripts/change_url b/scripts/change_url index 6ef2a0f..716c7e7 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,19 +24,10 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get $app final_path) - -#================================================= -# CHECK THE SYNTAX OF THE PATHS -#================================================= - -test -n "$old_path" || old_path="/" -test -n "$new_path" || new_path="/" -new_path=$(ynh_normalize_url_path $new_path) -old_path=$(ynh_normalize_url_path $old_path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED @@ -59,7 +50,7 @@ fi #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_print_info "Updating nginx web server configuration..." +ynh_script_progression --message="Updating nginx web server configuration..." --weight=2 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -67,7 +58,7 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf if [ $change_path -eq 1 ] then # Make a backup of the original nginx config file if modified - ynh_backup_if_checksum_is_different "$nginx_conf_path" + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" # Set global variables for nginx helper domain="$old_domain" path_url="$new_path" @@ -79,10 +70,10 @@ fi if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location - ynh_delete_file_checksum "$nginx_conf_path" + 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 "/etc/nginx/conf.d/$new_domain.d/$app.conf" + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= @@ -90,12 +81,12 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Change of URL completed for $app" +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index 231fecf..0165f1c 100644 --- a/scripts/install +++ b/scripts/install @@ -29,43 +29,43 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_print_info "Validating installation parameters..." +ynh_script_progression --message="Validating installation parameters..." --weight=2 final_path=/var/www/$app -test ! -e "$final_path" || ynh_die "This path already contains a folder" +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Register (book) web path -ynh_webpath_register $app $domain $path_url +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_print_info "Storing installation settings..." +ynh_script_progression --message="Storing installation settings..." --weight=2 -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path_url -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 #================================================= # STANDARD MODIFICATIONS #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Setting up source files..." +ynh_script_progression --message="Setting up source files..." --weight=4 -ynh_app_setting_set $app final_path $final_path +ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src # For this app sources are in app subdirectory tmp_dir=$(mktemp -d) -ynh_setup_source "$tmp_dir" +ynh_setup_source --dest_dir="$tmp_dir" mv "$tmp_dir/dist" "$final_path" -ynh_secure_remove "$tmp_dir" +ynh_secure_remove --file="$tmp_dir" #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Configuring nginx web server..." +ynh_script_progression --message="Configuring nginx web server..." --weight=4 # Create a dedicated nginx config ynh_add_nginx_config @@ -78,7 +78,7 @@ ynh_add_nginx_config # Imgur is deactivated on the specific upstream selected, but this text is still here # Don't use a patch because it's minified js -ynh_replace_string "are currently uploaded to imgur.*re working on changing this" "size is limited" "$final_path/scripts/amd-app.js" +ynh_replace_string --match_string="are currently uploaded to imgur.*re working on changing this" --replace_string="size is limited" --target_file="$final_path/scripts/amd-app.js" #================================================= # GENERIC FINALIZATION @@ -94,23 +94,23 @@ find "$final_path" -type d -print0 | xargs -0 chmod 750 #================================================= # SETUP SSOWAT #================================================= -ynh_print_info "Configuring SSOwat..." +ynh_script_progression --message="Configuring SSOwat..." # Make app public if necessary if [ $is_public -eq 1 ] then - ynh_app_setting_set $app skipped_uris "/" + ynh_app_setting_set --app=$app --key=skipped_uris --value="/" fi #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Installation of $app completed" +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 216a0f6..2ac0895 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,27 +12,27 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info "Removing app main directory" +ynh_script_progression --message="Removing app main directory..." --weight=2 # Remove the app directory securely -ynh_secure_remove "$final_path" +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_print_info "Removing nginx web server configuration" +ynh_script_progression --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -41,4 +41,4 @@ ynh_remove_nginx_config # END OF SCRIPT #================================================= -ynh_print_info "Removal of $app completed" +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 9186e5e..f3af36e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -19,23 +19,23 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading settings..." +ynh_script_progression --message="Loading settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -final_path=$(ynh_app_setting_get $app final_path) +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) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_print_info "Validating restoration parameters..." +ynh_script_progression --message="Validating restoration parameters..." --weight=3 -ynh_webpath_available $domain $path_url \ - || ynh_die "Path not available: ${domain}${path_url}" +ynh_webpath_available --domain=$domain --path_url=$path_url \ + || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ - || ynh_die "There is already a directory: $final_path " + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS @@ -43,14 +43,14 @@ test ! -d $final_path \ # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_print_info "Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." -ynh_restore_file "$final_path" +ynh_restore_file --origin_path="$final_path" #================================================= # RESTORE USER RIGHTS @@ -66,12 +66,12 @@ find "$final_path" -type d -print0 | xargs -0 chmod 750 #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server and php-fpm..." +ynh_script_progression --message="Reloading nginx web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Restoration completed for $app" +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 55e3508..b6f3ace 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,14 +12,14 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=3 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -is_public=$(ynh_app_setting_get $app is_public) -final_path=$(ynh_app_setting_get $app final_path) +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 @@ -30,16 +30,16 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_print_info "Ensuring downward compatibility..." +ynh_script_progression --message="Ensuring downward compatibility..." if [ "${version}" = "20160501-7" ]; then - public_site=$(ynh_app_setting_get $app public_site) + public_site=$(ynh_app_setting_get --app=$app --key=public_site) # Fix is_public as a boolean value if [ "$public_site" = "Yes" ]; then - ynh_app_setting_set $app is_public 1 + ynh_app_setting_set --app=$app --key=is_public --value=1 is_public=1 elif [ "$public_site" = "No" ]; then - ynh_app_setting_set $app is_public 0 + ynh_app_setting_set --app=$app --key=is_public --value=0 is_public=0 fi ynh_app_setting_delete $app public_site @@ -47,14 +47,14 @@ if [ "${version}" = "20160501-7" ]; then # If final_path doesn't exist, create it if [ -z "$final_path" ]; then final_path=/var/www/$app - ynh_app_setting_set $app final_path $final_path + ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info "Backing up the app before upgrading (may take a while)..." +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=6 # Backup the current version of the app ynh_backup_before_upgrade @@ -70,7 +70,7 @@ ynh_abort_if_errors #================================================= # Normalize the URL path syntax -path_url=$(ynh_normalize_url_path $path_url) +path_url=$(ynh_normalize_url_path --path_url=$path_url) #================================================= # STANDARD UPGRADE STEPS @@ -80,26 +80,26 @@ path_url=$(ynh_normalize_url_path $path_url) if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_print_info "Upgrading source files..." + ynh_script_progression --message="Upgrading source files..." --weight=4 # Download, check integrity, uncompress and patch the source from app.src # For this app sources are in app subdirectory tmp_dir=$(mktemp -d) - ynh_setup_source "$tmp_dir" + ynh_setup_source --dest_dir="$tmp_dir" # Dist is the compiled version. Other directories are source code and tools to build the program cp -a "$tmp_dir/dist/." "$final_path/" - ynh_secure_remove "$tmp_dir" + ynh_secure_remove --file="$tmp_dir" # Imgur is deactivated on the specific upstream selected, but this text is still here # Don't use a patch because it's minified js - ynh_replace_string "are currently uploaded to imgur.*re working on changing this" "size is limited" "$final_path/scripts/amd-app.js" + ynh_replace_string --match_string="are currently uploaded to imgur.*re working on changing this" --replace_string="size is limited" --target_file="$final_path/scripts/amd-app.js" fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config @@ -114,7 +114,7 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then # Imgur is deactivated on the specific upstream selected, but this text is still here # Don't use a patch because it's minified js - ynh_replace_string "are currently uploaded to imgur.*re working on changing this" "size is limited" "$final_path/scripts/amd-app.js" + ynh_replace_string --match_string="are currently uploaded to imgur.*re working on changing this" --replace_string="size is limited" --target_file="$final_path/scripts/amd-app.js" fi #================================================= @@ -131,23 +131,23 @@ find "$final_path" -type d -print0 | xargs -0 chmod 750 #================================================= # SETUP SSOWAT #================================================= -ynh_print_info "Upgrading SSOwat configuration..." +ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=5 # Make app public if necessary if [ $is_public -eq 1 ] then - ynh_app_setting_set $app skipped_uris "/" + ynh_app_setting_set --app=$app --key=skipped_uris --value="/" fi #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Upgrade of $app completed" +ynh_script_progression --message="Upgrade of $app completed" --last From 65999ea82ee42d1fe3752d85dc0e63f27e62e16b Mon Sep 17 00:00:00 2001 From: Kayou Date: Tue, 18 Jun 2019 10:06:12 +0200 Subject: [PATCH 7/8] Update upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index b6f3ace..7bcfcab 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh +# source _common.sh source /usr/share/yunohost/helpers #================================================= From 20b94648f275883c4752106f5097fa4f97b7a492 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 24 Jun 2019 21:11:53 +0200 Subject: [PATCH 8/8] Remove duplicated code --- scripts/upgrade | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 7bcfcab..27f6196 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -90,10 +90,6 @@ then # Dist is the compiled version. Other directories are source code and tools to build the program cp -a "$tmp_dir/dist/." "$final_path/" ynh_secure_remove --file="$tmp_dir" - - # Imgur is deactivated on the specific upstream selected, but this text is still here - # Don't use a patch because it's minified js - ynh_replace_string --match_string="are currently uploaded to imgur.*re working on changing this" --replace_string="size is limited" --target_file="$final_path/scripts/amd-app.js" fi #=================================================