From c100fd54da9b43c2c942ceacc258e020e983d4b6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 20 Oct 2022 00:14:07 +0200 Subject: [PATCH] Upgrade to 1.11.0~ynh1 --- .github/workflows/updater.sh | 49 +++-------- .github/workflows/updater.yml | 49 +++++++++++ check_process | 28 ++----- conf/app.src | 5 +- conf/nginx.conf | 5 +- doc/DISCLAIMER.md | 0 doc/DISCLAIMER_fr.md | 0 manifest.json | 148 +++++++++++++++++----------------- scripts/_common.sh | 13 ++- scripts/backup | 5 +- scripts/change_url | 12 +-- scripts/install | 44 ++++++---- scripts/remove | 18 +++-- scripts/restore | 54 ++++++++----- scripts/upgrade | 45 ++++++----- 15 files changed, 272 insertions(+), 203 deletions(-) create mode 100644 .github/workflows/updater.yml create mode 100644 doc/DISCLAIMER.md create mode 100644 doc/DISCLAIMER_fr.md diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index 89f6e64..94bb411 100755 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -9,9 +9,6 @@ # Since each app is different, maintainers can adapt its contents so as to perform # automatic actions when a new upstream release is detected. -# Remove this exit command when you are ready to run this Action -#exit 1 - #================================================= # FETCHING LATEST RELEASE AND ITS ASSETS #================================================= @@ -21,58 +18,43 @@ current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') # Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) -assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) +assets="https://github.com/$repo/archive/refs/tags/$version.tar.gz" # Later down the script, we assume the version has only digits and dots # Sometimes the release name starts with a "v", so let's filter it out. -# You may need more tweaks here if the upstream repository has different naming conventions. +# You may need more tweaks here if the upstream repository has different naming conventions. if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then - version=${version:1} + version=${version:1} fi # Setting up the environment variables echo "Current version: $current_version" echo "Latest release from upstream: $version" echo "VERSION=$version" >> $GITHUB_ENV +echo "REPO=$repo" >> $GITHUB_ENV # For the time being, let's assume the script will fail echo "PROCEED=false" >> $GITHUB_ENV # Proceed only if the retrieved version is greater than the current one if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then - echo "::warning ::No new version available" - exit 0 + echo "::warning ::No new version available" + exit 0 # Proceed only if a PR for this new version does not already exist elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then - echo "::warning ::A branch already exists for this update" - exit 0 + echo "::warning ::A branch already exists for this update" + exit 0 fi -# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.) -echo "${#assets[@]} available asset(s)" - #================================================= # UPDATE SOURCE FILES #================================================= -# Here we use the $assets variable to get the resources published in the upstream release. -# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like. - -# Let's loop over the array of assets URLs -for asset_url in ${assets[@]}; do +# Let's download source tarball +asset_url=$assets echo "Handling asset at $asset_url" -# Assign the asset to a source file in conf/ directory -# Here we base the source file name upon a unique keyword in the assets url (admin vs. update) -# Leave $src empty to ignore the asset -case $asset_url in - "v"*".tar.gz") - src="app" - ;; -esac - -# If $src is not empty, let's process the asset -if [ ! -z "$src" ]; then +src="app" # Create the temporary directory tempdir="$(mktemp -d)" @@ -97,18 +79,13 @@ cat < conf/$src.src SOURCE_URL=$asset_url SOURCE_SUM=$checksum SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz +SOURCE_FORMAT=$extension SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= SOURCE_EXTRACT=true EOT echo "... conf/$src.src updated" -else -echo "... asset ignored" -fi - -done - #================================================= # SPECIFIC UPDATE STEPS #================================================= diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml new file mode 100644 index 0000000..fb72ba0 --- /dev/null +++ b/.github/workflows/updater.yml @@ -0,0 +1,49 @@ +# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected. +# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization. +# This file should be enough by itself, but feel free to tune it to your needs. +# It calls updater.sh, which is where you should put the app-specific update steps. +name: Check for new upstream releases +on: + # Allow to manually trigger the workflow + workflow_dispatch: + # Run it every day at 6:00 UTC + schedule: + - cron: '0 6 * * *' +jobs: + updater: + runs-on: ubuntu-latest + steps: + - name: Fetch the source code + uses: actions/checkout@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Run the updater script + id: run_updater + run: | + # Setting up Git user + git config --global user.name 'yunohost-bot' + git config --global user.email 'yunohost-bot@users.noreply.github.com' + # Run the updater script + /bin/bash .github/workflows/updater.sh + - name: Commit changes + id: commit + if: ${{ env.PROCEED == 'true' }} + run: | + git commit -am "Upgrade to v$VERSION" + - name: Create Pull Request + id: cpr + if: ${{ env.PROCEED == 'true' }} + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Update to version ${{ env.VERSION }} + committer: 'yunohost-bot ' + author: 'yunohost-bot ' + signoff: false + base: testing + branch: ci-auto-update-v${{ env.VERSION }} + delete-branch: true + title: 'Upgrade to version ${{ env.VERSION }}' + body: | + Upgrade to v${{ env.VERSION }} + draft: false diff --git a/check_process b/check_process index a8960f0..64dacc0 100644 --- a/check_process +++ b/check_process @@ -1,22 +1,13 @@ ;; Test complet ; Manifest domain="domain.tld" - path="/leed" - admin="john" - password="pass" - language="fr" - market=1 + path="/path" is_public=1 + language="fr" + admin="john" + password="1Strong-Password" ; Actions is_public=0|1 - ; Config_panel - main.is_public.is_public=0|1 - main.overwrite_files.overwrite_nginx=0|1 - main.overwrite_files.overwrite_phpfpm=0|1 - main.global_config.email_type=0|1 - main.php_fpm_config.footprint=low|medium|high - main.php_fpm_config.free_footprint=20 - main.php_fpm_config.usage=low|medium|high ; Checks pkg_linter=1 setup_sub_dir=1 @@ -25,21 +16,12 @@ setup_private=1 setup_public=1 upgrade=1 - # upgrade=1 from_commit=8b622d430db9ab860aee156a32086507669243fd # 1.8.3~ynh10 upgrade=1 from_commit=ea31e4850ded0939c1b0d024db8f45325fcebac1 backup_restore=1 multi_instance=1 port_already_use=0 change_url=1 - actions=0 - config_panel=0 ;;; Options Email= -Notification=change -;;; Upgrade options - ; commit=8b622d430db9ab860aee156a32086507669243fd - name=MAJ 1.8.2 - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=pass&language=fr&market=1&is_public=1& - ; commit=ea31e4850ded0939c1b0d024db8f45325fcebac1 - name=1.8.3~ynh10 +Notification=none diff --git a/conf/app.src b/conf/app.src index f3251ab..d70f7a6 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,7 @@ -SOURCE_URL=https://github.com/LeedRSS/Leed/archive/v1.9.0.tar.gz -SOURCE_SUM=e8a9c4586234169e2dd96e6c6e90e140a2336950c3b259947b70b0b0b6ff903c +SOURCE_URL=https://github.com/LeedRSS/Leed/archive/refs/tags/v1.11.0.tar.gz +SOURCE_SUM=3a3f6e2201f7cc0ee10a4f610b0cf1ace18166a6d21e37ab1ae5283920500c87 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= SOURCE_EXTRACT=true diff --git a/conf/nginx.conf b/conf/nginx.conf index 51c7570..d9fdc4e 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,10 +2,13 @@ location __PATH__/ { # Path to source - alias __FINALPATH__/ ; + alias __FINALPATH__/; index index.php; + # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file + #client_max_body_size 50M; + try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md new file mode 100644 index 0000000..e69de29 diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md new file mode 100644 index 0000000..e69de29 diff --git a/manifest.json b/manifest.json index 5a213bb..81d957a 100644 --- a/manifest.json +++ b/manifest.json @@ -1,75 +1,79 @@ { - "name": "Leed", - "id": "leed", - "packaging_format": 1, - "description": { - "en": "Minimalistic RSS feed aggregator which allows quick and non-intrusive reading of feeds", - "fr": "Agrégateur RSS minimaliste qui permet la consultation de flux RSS de manière rapide et non intrusive" - }, - "version": "1.9.0~ynh3", - "url": "http://leed.idleman.fr/", - "upstream": { - "license": "AGPL-3.0", - "website": "http://leed.idleman.fr/", - "code": "http://git.idleman.fr/LeedRSS/Leed" + "name": "Leed", + "id": "leed", + "packaging_format": 1, + "description": { + "en": "Minimalistic RSS feed aggregator which allows quick and non-intrusive reading of feeds", + "fr": "Agrégateur RSS minimaliste qui permet la consultation de flux RSS de manière rapide et non intrusive" }, - "license": "AGPL-3.0", - "maintainer": { - "name": "", - "email": "" - }, - "previous_maintainers": [{ - "name": "Maniack Crudelis", - "email": "maniackc_dev@crudelis.fr" - }], - "requirements": { - "yunohost": ">= 4.3.0" - }, - "multi_instance": true, - "services": [ - "nginx", - "php7.3-fpm", - "mysql" - ], - "arguments": { - "install" : [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/leed", - "default": "/leed" - }, - { - "name": "admin", - "type": "user" - }, - { - "name": "is_public", - "type": "boolean", - "default": false, - "help": { - "en": "A public Leed will be accessible for third party apps. By turning on 'anonymous readers' in Leed configuration, you can made your feeds public.", - "fr": "Un Leed public sera accessible pour les applications tierces. En autorisant 'la lecture anonyme' dans la configuration de Leed, vous pouvez rendre vos flux publics." - } - }, - { - "name": "language", - "type": "string", - "ask": { - "en": "Choose your agregator's language", - "fr": "Choisissez la langue de votre agrégateur" - }, - "choices" : ["en", "fr", "es"], - "default" : "en" - }, - { - "name": "password", - "type": "password" - } - ] - } + "version": "1.11.0~ynh1", + "upstream": { + "license": "AGPL-3.0", + "code": "https://github.com/LeedRSS/Leed" + }, + "license": "AGPL-3.0", + "maintainer": { + "name": "", + "email": "" + }, + "previous_maintainers": [ + { + "name": "Maniack Crudelis", + "email": "maniackc_dev@crudelis.fr" + } + ], + "requirements": { + "yunohost": ">= 4.3.0" + }, + "multi_instance": true, + "services": [ + "nginx", + "php7.3-fpm", + "mysql" + ], + "arguments": { + "install": [ + { + "name": "domain", + "type": "domain" + }, + { + "name": "path", + "type": "path", + "example": "/leed", + "default": "/leed" + }, + { + "name": "is_public", + "type": "boolean", + "default": false, + "help": { + "en": "A public Leed will be accessible for third party apps. By turning on 'anonymous readers' in Leed configuration, you can made your feeds public.", + "fr": "Un Leed public sera accessible pour les applications tierces. En autorisant 'la lecture anonyme' dans la configuration de Leed, vous pouvez rendre vos flux publics." + } + }, + { + "name": "language", + "type": "string", + "ask": { + "en": "Choose your agregator's language", + "fr": "Choisissez la langue de votre agrégateur" + }, + "choices": [ + "en", + "fr", + "es" + ], + "default": "en" + }, + { + "name": "admin", + "type": "user" + }, + { + "name": "password", + "type": "password" + } + ] + } } diff --git a/scripts/_common.sh b/scripts/_common.sh index 96ffe33..ed43057 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,11 +3,16 @@ #================================================= # COMMON VARIABLES #================================================= +# PHP APP SPECIFIC +#================================================= -YNH_PHP_VERSION="7.3" +php_dependencies="php$YNH_DEFAULT_PHP_VERSION-fpm" + +# dependencies used by the app (must be on a single line) +pkg_dependencies="$php_dependencies" #================================================= -# FUTUR OFFICIAL HELPERS +# PERSONAL HELPERS #================================================= #================================================= @@ -444,3 +449,7 @@ ynh_check_ram () { echo $ram fi } + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= \ No newline at end of file diff --git a/scripts/backup b/scripts/backup index a999cf3..850f2ad 100644 --- a/scripts/backup +++ b/scripts/backup @@ -14,13 +14,16 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + 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..." +ynh_print_info --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME diff --git a/scripts/change_url b/scripts/change_url index dbb52f2..597a076 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 +ynh_script_progression --message="Loading settings..." --weight=2 # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) @@ -41,7 +41,7 @@ ynh_maintenance_mode_ON #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 # Backup the current version of the app ynh_backup_before_upgrade @@ -76,7 +76,7 @@ fi #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -120,7 +120,7 @@ ynh_replace_string --match_string="https://$old_domain${old_path}" --replace_str #================================================= # UPDATE THE DATABASE #================================================= -ynh_script_progression --message="Updating the database..." +ynh_script_progression --message="Updating the database..." --weight=1 ynh_mysql_execute_as_root --sql="UPDATE leed_configuration SET value='$domain_path/' WHERE value LIKE '%${old_domain}%'" --database=$app @@ -129,14 +129,14 @@ ynh_mysql_execute_as_root --sql="UPDATE leed_configuration SET value='$domain_pa #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload #================================================= # DEACTIVE MAINTENANCE MODE #================================================= -ynh_script_progression --message="Disabling maintenance mode..." +ynh_script_progression --message="Disabling maintenance mode..." --weight=1 path_url=$old_path domain=$old_domain diff --git a/scripts/install b/scripts/install index 5c6280c..4857e1d 100644 --- a/scripts/install +++ b/scripts/install @@ -13,6 +13,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -22,10 +25,10 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH -admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC language=$YNH_APP_ARG_LANGUAGE -user_pwd=$YNH_APP_ARG_PASSWORD +admin=$YNH_APP_ARG_ADMIN +password=$YNH_APP_ARG_PASSWORD app=$YNH_APP_INSTANCE_NAME @@ -47,26 +50,33 @@ ynh_script_progression --message="Storing installation settings..." --weight=2 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=admin --value=$admin ynh_app_setting_set --app=$app --key=language --value=$language +ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=overwrite_nginx --value=1 ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value=1 ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 #================================================= # STANDARD MODIFICATIONS +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=1 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # CREATE DEDICATED USER #================================================= ynh_script_progression --message="Configuring system user..." --weight=2 # Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # CREATE A MYSQL DATABASE #================================================= -ynh_script_progression --message="Creating a MySQL database..." +ynh_script_progression --message="Creating a MySQL database..." --weight=1 db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name @@ -86,14 +96,6 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=2 - -# Create a dedicated NGINX config -ynh_add_nginx_config - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -103,6 +105,14 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 ynh_add_fpm_config --usage=low --footprint=low phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring NGINX web server..." --weight=2 + +# Create a dedicated NGINX config +ynh_add_nginx_config + #================================================= # SPECIFIC SETUP #================================================= @@ -116,7 +126,7 @@ ynh_permission_update --permission="main" --add="visitors" # Installation with curl ynh_script_progression --message="Finalizing installation..." -ynh_local_curl "/install.php?installButton" "install_changeLngLeed=$language" "root=$domain$path_url" "mysqlHost=localhost" "mysqlLogin=$db_name" "mysqlMdp=$db_pwd" "mysqlBase=$db_name" "mysqlPrefix=leed_" "login=$admin" "password=$user_pwd" +ynh_local_curl "/install.php?installButton" "install_changeLngLeed=$language" "root=$domain$path_url" "mysqlHost=localhost" "mysqlLogin=$db_user" "mysqlMdp=$db_pwd" "mysqlBase=$db_name" "mysqlPrefix=leed_" "login=$admin" "password=$password" # Remove the public access ynh_permission_update --permission="main" --remove="visitors" @@ -125,7 +135,7 @@ ynh_permission_update --permission="main" --remove="visitors" # RETRIEVE SYNCHRONISATION CODE #================================================= -code_sync=$(mysql -h localhost -u $db_name -p$db_pwd -s $db_name -e 'SELECT value FROM leed_configuration WHERE `key`="synchronisationCode"' | sed -n 1p) +code_sync=$(mysql -h localhost -u $db_user -p$db_pwd -s $db_name -e 'SELECT value FROM leed_configuration WHERE `key`="synchronisationCode"' | sed -n 1p) #================================================= # SETUP CRON FILE FOR SYNCHRONISATION @@ -152,6 +162,8 @@ ynh_script_progression --message="Configuring permissions..." --weight=2 # Make app public if necessary if [ $is_public -eq 1 ] then + # Everyone can access the app. + # The "main" permission is automatically created before the install script. ynh_permission_update --permission="main" --add="visitors" fi @@ -169,7 +181,7 @@ ynh_systemd_action --service_name=nginx --action=reload # Get main domain and buid the url of the admin panel of the app. admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app" -echo "Please take note of your password for this application: '$user_pwd'. +echo "Please take note of your password for this application: '$password'. You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__. You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__. diff --git a/scripts/remove b/scripts/remove index 42e8c1f..10ed4c5 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 +ynh_script_progression --message="Loading settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME @@ -26,7 +26,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # REMOVE THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Removing the MySQL database..." +ynh_script_progression --message="Removing the MySQL database..." --weight=1 # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name @@ -34,7 +34,7 @@ ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." +ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -50,11 +50,19 @@ ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Removing PHP-FPM configuration..." +ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1 # Remove the dedicated PHP-FPM config ynh_remove_fpm_config +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=1 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + #================================================= # REMOVE FAIL2BAN CONFIGURATION #================================================= @@ -68,7 +76,7 @@ ynh_remove_fail2ban_config #================================================= # REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing various files..." +ynh_script_progression --message="Removing various files..." --weight=1 # Remove a cron file ynh_secure_remove --file="/etc/cron.d/$app" diff --git a/scripts/restore b/scripts/restore index 151572f..aa59466 100644 --- a/scripts/restore +++ b/scripts/restore @@ -14,13 +14,16 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 +ynh_script_progression --message="Loading settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME @@ -35,9 +38,10 @@ admin=$(ynh_app_setting_get --app=$app --key=admin) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." +ynh_script_progression --message="Validating restoration parameters..." --weight=1 -test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " #================================================= # ACTIVATE MAINTENANCE MODE @@ -48,25 +52,18 @@ ynh_maintenance_mode_ON #================================================= # STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RECREATE THE DEDICATED USER #================================================= ynh_script_progression --message="Recreating the dedicated system user..." --weight=2 # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_restore_file --origin_path="$final_path" @@ -74,13 +71,6 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" -#================================================= -# RESTORE THE PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the PHP-FPM configuration..." - -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" - #================================================= # RESTORE FAIL2BAN CONFIGURATION #================================================= @@ -92,6 +82,28 @@ ynh_systemd_action --action=restart --service_name=fail2ban #================================================= # SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=1 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=1 + +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" + +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + #================================================= # RESTORE THE MYSQL DATABASE #================================================= @@ -104,7 +116,7 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./ #================================================= # RESTORE VARIOUS FILES #================================================= -ynh_script_progression --message="Restoring various files..." +ynh_script_progression --message="Restoring various files..." --weight=1 ynh_restore_file --origin_path="/etc/cron.d/$app" @@ -113,7 +125,7 @@ ynh_restore_file --origin_path="/etc/cron.d/$app" #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." +ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index a374c99..801f387 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=3 +ynh_script_progression --message="Loading settings..." --weight=3 app=$YNH_APP_INSTANCE_NAME @@ -20,8 +20,10 @@ 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) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) overwrite_nginx=$(ynh_app_setting_get --app=$app --key=overwrite_nginx) overwrite_phpfpm=$(ynh_app_setting_get --app=$app --key=overwrite_phpfpm) @@ -29,11 +31,11 @@ admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html) fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) @@ -54,7 +56,7 @@ ynh_abort_if_errors #================================================= # ACTIVATE MAINTENANCE MODE #================================================= -ynh_script_progression --message="Activating maintenance mode..." +ynh_script_progression --message="Activating maintenance mode..." --weight=1 ynh_maintenance_mode_ON @@ -63,7 +65,7 @@ ynh_maintenance_mode_ON #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # If final_path doesn't exist, create it if [ -z "$final_path" ]; then @@ -129,10 +131,10 @@ fi #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -151,16 +153,11 @@ chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" #================================================= -# NGINX CONFIGURATION +# UPGRADE DEPENDENCIES #================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=1 -# Overwrite the nginx configuration only if it's allowed -if [ $overwrite_nginx -eq 1 ] -then - ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 - # Create a dedicated NGINX config - ynh_add_nginx_config -fi +ynh_install_app_dependencies $pkg_dependencies #================================================= # PHP-FPM CONFIGURATION @@ -174,18 +171,30 @@ then ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint fi +#================================================= +# NGINX CONFIGURATION +#================================================= + +# Overwrite the nginx configuration only if it's allowed +if [ $overwrite_nginx -eq 1 ] +then + ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 + # Create a dedicated NGINX config + ynh_add_nginx_config +fi + #================================================= # SPECIFIC UPGRADE #================================================= # RETRIEVE SYNCHRONISATION CODE #================================================= -code_sync=$(mysql -h localhost -u $db_name -p$db_pwd -s $db_name -e 'SELECT value FROM leed_configuration WHERE `key`="synchronisationCode"' | sed -n 1p) +code_sync=$(mysql -h localhost -u $db_user -p$db_pwd -s $db_name -e 'SELECT value FROM leed_configuration WHERE `key`="synchronisationCode"' | sed -n 1p) #================================================= # SETUP CRON FILE FOR SYNCHRONISATION #================================================= -ynh_script_progression --message="Setting up a cron file..." +ynh_script_progression --message="Setting up a cron file..." --weight=1 ynh_add_config --template="../conf/cron_leed" --destination="/etc/cron.d/$app" @@ -220,7 +229,7 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= # DEACTIVE MAINTENANCE MODE #================================================= -ynh_script_progression --message="Disabling maintenance mode..." +ynh_script_progression --message="Disabling maintenance mode..." --weight=1 ynh_maintenance_mode_OFF