From 06f42c0923c52258a100081d8cd75aa7bf0fef8a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 2 Jul 2019 00:38:57 +0200 Subject: [PATCH] Apply example_ynh --- README.md | 98 ++++++++++++++++++-------------------- check_process | 21 ++------ conf/nginx.conf | 5 +- manifest.json | 12 ++--- scripts/_common.sh | 46 +++++------------- scripts/backup | 28 +++++------ scripts/change_url | 16 +++---- scripts/install | 116 +++++++++++++++------------------------------ scripts/remove | 28 +++++------ scripts/restore | 55 ++++++++++----------- scripts/upgrade | 71 ++++++++++++++------------- 11 files changed, 213 insertions(+), 283 deletions(-) diff --git a/README.md b/README.md index b8b73f7..4b1445c 100644 --- a/README.md +++ b/README.md @@ -1,69 +1,61 @@ # FreshRSS package for YunoHost +[![Integration level](https://dash.yunohost.org/integration/freshrss.svg)](https://dash.yunohost.org/appci/app/freshrss) +[![Install FreshRSS with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=freshrss) + +> *This package allow you to install FreshRSS 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 + An efficient but powerful RSS aggregator with a nice and mobile-friendly design, as well as extension and themes support. -* [FreshRSS website](http://freshrss.org) -* [YunoHost website](https://yunohost.org) +**Shipped version:** 1.14.1 -## INSTALL - -[![Install FreshRSS with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=freshrss) +## Screenshots ![](https://freshrss.org/images/screenshot.png) +## Demo -or command line : +* [Official demo](https://demo.freshrss.org) -`yunohost app install https://github.com/YunoHost-Apps/freshrss_ynh` - -## UPGRADE -`yunohost app upgrade freshrss -u https://github.com/YunoHost-Apps/freshrss_ynh` - -# :warning: WARNING :warning: -upgrade for stretch has now dedicated php-fpm pool. To make upgrade works : -Check if domain is already sets : -`yunohost app setting freshrss domain` -if this command does't return anything : -`yunohost app setting freshrss domain -v yourdomain.tld` - -if you have multiple instances : - -`yunohost app setting freshrss__instancenumber domain -v yourdomain.tld` - -Changelog: - -* 2019-04-07 : - * Upgrade to 1.14.1 -* 2019-03-31 : - * Upgrade to 1.14.0 -* 2019-01-29 : - * Upgrade to 1.13.1 - * Remove ynh_abort_if_errors to comply with linter - * Change licence to comply with linter -* 2019-01-04 : - * Fix user add access hook - * Upgrade to 1.13.0 - * Open /api url instead of /api/greader.php -* 2018-10-28 : - * Update to FreshRSS 1.12.0 -* 2018-09-23 : - * Update to FreshRSS 1.11.2 - * Fix install on domain root path -* 2018-07-07 : - * Update to FreshRSS 1.11.1 - * Remove deprecated helpers - * php-fpm dedicated pool -* 2018-06-03 : Update to FreshRSS 1.11.0 -* 2018-02-04 : Update to FreshRSS 1.10.1 -* 2017-12-27 : Update to FreshRSS 1.9.0 -* 2017-12-03 : Update to FreshRSS 1.8.0 -* 2017-06-03 : Update to FreshRSS 1.7.0 -* 2017-03-13 : Update to FreshRSS 1.6.3 -* 2017-03-13 : Complete package refactoring -* 2017-01-22 : Update to FreshRSS 1.6.2 +## Configuration API (mini) How To : * Into your user profile : Settings > profil * Setup an API password * Check the API is working : https://exemple.tld/rss/api/greader.php * Setup your client with : username : ynh user, password : the password you just setup, url https://exemple.tld/rss/api/greader.php + +## Documentation + + * Official documentation: https://freshrss.github.io/FreshRSS/ + +#### Supported architectures + +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/freshrss%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/freshrss/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/freshrss%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/freshrss/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/freshrss%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/freshrss/) + +## Links + + * Report a bug: https://github.com/YunoHost-Apps/freshrss_ynh/issues + * App website: https://freshrss.org/ + * Upstream app repository: https://github.com/FreshRSS/FreshRSS + * YunoHost website: https://yunohost.org/ + +--- + +Developers info +---------------- + +**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/freshrss_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/freshrss_ynh/tree/testing --debug +or +sudo yunohost app upgrade freshrss -u https://github.com/YunoHost-Apps/freshrss_ynh/tree/testing --debug +``` diff --git a/check_process b/check_process index cc3f696..7494fa0 100644 --- a/check_process +++ b/check_process @@ -12,28 +12,17 @@ setup_nourl=0 setup_private=0 setup_public=0 + upgrade=1 upgrade=1 from_commit=b89554865459520d7d90a5a666f09f6987f41de6 backup_restore=1 multi_instance=1 - wrong_user=1 - wrong_path=1 - incorrect_path=1 - corrupt_source=0 - fail_download_source=0 + # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. + # incorrect_path=1 port_already_use=0 - final_path_already_use=1 change_url=1 ;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto - Level 4=1 - Level 5=1 - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 + # If the level 5 (Package linter) is forced to 1. Please add justifications here. + Level 5=auto ;;; Upgrade options ; commit=b89554865459520d7d90a5a666f09f6987f41de6 name=Tue Jan 29 21:28:14 2019 +0100 update README diff --git a/conf/nginx.conf b/conf/nginx.conf index 09d1d2e..d0b9555 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,18 +4,21 @@ location __PATH__/ { if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } + +### Example PHP configuration (remove it if not used) index index.html index.php; try_files $uri $uri/ /index.php?$args; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; + fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $request_filename; } - +### End of PHP configuration part # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/manifest.json b/manifest.json index d4a983f..6b5d1a0 100644 --- a/manifest.json +++ b/manifest.json @@ -1,12 +1,12 @@ { "name": "FreshRSS", "id": "freshrss", - "version": "1.14.1", "packaging_format": 1, "description": { "en": "FreshRSS is a selfhostable RSS reader", "fr": "FreshRSS est un agrégateur de flux RSS à auto-héberger" }, + "version": "1.14.1~ynh1", "url": "http://freshrss.org/", "license": "AGPL-3.0-only", "maintainer": { @@ -14,7 +14,7 @@ "email": "plopoyop@gmail.com" }, "requirements": { - "yunohost": ">= 3.0.0" + "yunohost": ">= 3.5" }, "multi_instance": true, "services": [ @@ -28,8 +28,8 @@ "name": "domain", "type": "domain", "ask": { - "en": "Choose a domain for FreshRSS", - "fr": "Choisissez un domaine pour FreshRSS" + "en": "Choose a domain name for FreshRSS", + "fr": "Choisissez un nom de domaine pour FreshRSS" }, "example": "domain.org" }, @@ -48,8 +48,8 @@ "type": "user", "optional": false, "ask": { - "en": "Choose the default user", - "fr": "Choisissez l'utilisateur par defaut" + "en": "Choose an admin user", + "fr": "Choisissez l’administrateur" }, "example": "homer" }, diff --git a/scripts/_common.sh b/scripts/_common.sh index f960c0a..12a73ff 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,17 +1,8 @@ -# -# Common variables -# -APPNAME="freshrss" -# FreshRSS version -VERSION="1.14.1" +#!/bin/bash -# FreshRSS complete tarball checksum -FRESHRSS_SOURCE_SHA256="fd5ce6906021282e12cd6346844d21b82b70ac12d08834079a46b8722bfb0cce" - -# Remote URL to fetch FreshRSS source tarball -FRESHRSS_SOURCE_URL="https://github.com/FreshRSS/FreshRSS/archive/${VERSION}.tar.gz" - -PKGDIR=$(cd ../; pwd) +#================================================= +# COMMON VARIABLES +#================================================= if [ "$(lsb_release --codename --short)" == "jessie" ]; then pkg_dependencies="php5-gd" @@ -19,25 +10,14 @@ else pkg_dependencies="php-gd php-zip php-dom php-mbstring" fi -# -# Common helpers -# -# Download and extract FreshRSS sources to the given directory -# usage: extract_freshrss DESTDIR -extract_freshrss() { - local DESTDIR=$1 +#================================================= +# PERSONAL HELPERS +#================================================= - # retrieve and extract FreshRSS tarball - rc_tarball="${DESTDIR}/freshrss.tar.gz" - wget -q -O "$rc_tarball" "$FRESHRSS_SOURCE_URL" \ - || ynh_die "Unable to download FreshRSS tarball" - echo "$FRESHRSS_SOURCE_SHA256 $rc_tarball" | sha256sum -c >/dev/null \ - || ynh_die "Invalid checksum of downloaded tarball" - tar xf "$rc_tarball" -C "$DESTDIR" --strip-components 1 \ - || ynh_die "Unable to extract FreshRss tarball" - sudo rm "$rc_tarball" -} +#================================================= +# EXPERIMENTAL HELPERS +#================================================= -install_freshrss_dependencies() { - ynh_install_app_dependencies $pkg_dependencies -} +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/backup b/scripts/backup index d81e857..f957038 100755 --- a/scripts/backup +++ b/scripts/backup @@ -19,43 +19,43 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get $app final_path) -domain=$(ynh_app_setting_get $app domain) -db_name=$(ynh_app_setting_get $app db_name) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # STANDARD BACKUP STEPS #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info "Backing up the main app directory..." +ynh_print_info --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_print_info --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" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Backing up php-fpm configuration..." +ynh_print_info --message="Backing up php-fpm configuration..." -ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE #================================================= -ynh_print_info "Backing up the MySQL database..." +ynh_print_info --message="Backing up the MySQL database..." -ynh_mysql_dump_db "$db_name" > db.sql +ynh_mysql_dump_db --database="$db_name" > db.sql #================================================= # SPECIFIC BACKUP @@ -63,10 +63,10 @@ ynh_mysql_dump_db "$db_name" > db.sql # BACKUP A CRON FILE #================================================= -ynh_backup "/etc/cron.d/$app" +ynh_backup --src_path="/etc/cron.d/$app" #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index 375a9ee..40f2601 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -25,7 +25,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) @@ -77,7 +77,7 @@ fi #================================================= # MODIFY URL IN NGINX CONF FILE #================================================= -ynh_print_info "Updating nginx web server configuration..." +ynh_print_info --message="Updating nginx web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -85,7 +85,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" domain="$old_domain" path_url="$new_path" # Create a dedicated nginx config @@ -95,10 +95,10 @@ fi # Change the domain for nginx if [ $change_domain -eq 1 ] then - 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 #================================================= @@ -115,11 +115,11 @@ $final_path/cli/reconfigure.php --auth_type http_auth --environment production - #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." -sudo systemctl reload nginx +ynh_print_info --message="Reloading nginx web server..." +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Change of URL completed for $app" +ynh_print_info --message="Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 0d0bfd7..2923ce2 100755 --- a/scripts/install +++ b/scripts/install @@ -19,48 +19,34 @@ ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= + domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN language=$YNH_APP_ARG_LANGUAGE -### If it's a multi-instance app, meaning it can be installed several times independently -### The id of the app as stated in the manifest is available as $YNH_APP_ID -### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...) -### The app instance name is available as $YNH_APP_INSTANCE_NAME -### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample -### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2 -### - ynhexample__{N} for the subsequent installations, with N=3,4, ... -### The app instance name is probably what interests you most, since this is -### guaranteed to be unique. This is a good unique identifier to define installation path, -### db names, ... app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_print_info "Validating installation parameters..." +ynh_print_info --message="Validating installation parameters..." -### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". -### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app" final_path=/var/www/$app -test ! -e "$final_path" || ynh_die "This path already contains a folder" - -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) +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_print_info --message="Storing installation settings..." -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path_url -ynh_app_setting_set $app admin $admin -ynh_app_setting_set $app language $language +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 #================================================= # STANDARD MODIFICATIONS @@ -69,52 +55,37 @@ ynh_app_setting_set $app language $language #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_print_info "Installing dependencies..." - -### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. -### Those deb packages will be installed as dependencies of this package. -### If you're not using this helper: -### - Remove the section "REMOVE DEPENDENCIES" in the remove script -### - As well as the section "REINSTALL DEPENDENCIES" in the restore script -### - And the section "UPGRADE DEPENDENCIES" in the upgrade script +ynh_print_info --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE A MYSQL DATABASE #================================================= -ynh_print_info "Creating a MySQL database..." +ynh_print_info --message="Creating a MySQL database..." -### Use these lines if you need a database for the application. -### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password. -### The password will be stored as 'mysqlpwd' into the app settings, -### and will be available as $db_pwd -### If you're not using these lines: -### - Remove the section "BACKUP THE MYSQL DATABASE" in the backup script -### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script -### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script - -db_name=$(ynh_sanitize_dbid $app) -ynh_app_setting_set $app db_name $db_name -ynh_mysql_setup_db $db_name $db_name +db_name=$(ynh_sanitize_dbid --db_name=$app) +db_user=$db_name +ynh_app_setting_set --app=$app --key=db_name --value=$db_name +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Setting up source files..." +ynh_print_info --message="Setting up source files..." ### `ynh_setup_source` is used to install an app from a zip or tar.gz file, ### downloaded from an upstream source, like a git repository. ### `ynh_setup_source` use the file conf/app.src -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 -ynh_setup_source "$final_path" +ynh_setup_source --dest_dir="$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Configuring nginx web server..." +ynh_print_info --message="Configuring nginx web server..." ### `ynh_add_nginx_config` will use the file conf/nginx.conf @@ -124,26 +95,15 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info "Configuring system user..." +ynh_print_info --message="Configuring system user..." # Create a system user -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Configuring php-fpm..." - -### `ynh_add_fpm_config` is used to set up a PHP config. -### You can remove it if your app doesn't use PHP. -### `ynh_add_fpm_config` will use the files conf/php-fpm.conf and conf/php-fpm.ini -### If you're not using these lines: -### - You can remove these files in conf/. -### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script -### - Remove also the section "REMOVE PHP-FPM CONFIGURATION" in the remove script -### - As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script -### With the reload at the end of the script. -### - And the section "PHP-FPM CONFIGURATION" in the upgrade script +ynh_print_info --message="Configuring php-fpm..." # Create a dedicated php-fpm config ynh_add_fpm_config @@ -151,11 +111,14 @@ ynh_add_fpm_config #================================================= # SPECIFIC SETUP #================================================= -ynh_print_info "FreshRSS setup script..." +# SETUPING FRESHRSS +#================================================= +ynh_print_info --message="FreshRSS setup script..." + $final_path/cli/do-install.php --default_user $admin --auth_type http_auth --environment production --base_url https://$domain$path_url --title FreshRSS --api_enabled --db-type mysql --db-host localhost --db-user $db_name --db-password $db_pwd --db-base $db_name # Add users -ynh_print_info "Creating users..." +ynh_print_info --message="Creating users..." for myuser in $(ynh_user_list) do user_token=$(ynh_string_random) @@ -163,12 +126,13 @@ do done #================================================= -# CRON SETUP +# SETUP A CRON #================================================= -ynh_print_info "Setting up cron..." +ynh_print_info --message="Setting up cron..." + cron_path="/etc/cron.d/$app" -ynh_replace_string "__FINALPATH__" $final_path ../conf/freshrss.cron -ynh_replace_string "__APP__" $app ../conf/freshrss.cron +ynh_replace_string --match_string="__FINALPATH__" --replace_string=$final_path --target_file="../conf/freshrss.cron" +ynh_replace_string --match_string="__APP__" --replace_string=$app --target_file="../conf/freshrss.cron" cp ../conf/freshrss.cron "$cron_path" chmod 644 "$cron_path" @@ -181,10 +145,6 @@ chmod 644 "$cron_path" # SECURE FILES AND DIRECTORIES #================================================= -### For security reason, any app should set the permissions to root: before anything else. -### Then, if write authorization is needed, any access should be given only to directories -### that really need such authorization. - # Set permissions to app files chown -R root: $final_path chown -R $app: $final_path/data/ @@ -194,21 +154,21 @@ chown -R $app: $final_path/extensions/ #================================================= # SETUP SSOWAT #================================================= -ynh_print_info "Configuring SSOwat..." +ynh_print_info --message="Configuring SSOwat..." #skip api directory -ynh_app_setting_set "$app" unprotected_regex "^\/api\/.*|\/scripts\/api.js$" -ynh_app_setting_delete "$app" unprotected_uris +ynh_app_setting_set --app="$app" --key=unprotected_regex --value="^\/api\/.*|\/scripts\/api.js$" +ynh_app_setting_delete --app="$app" --key=unprotected_uris #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --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_print_info --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index df3390e..4b189f5 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,14 +12,14 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -db_name=$(ynh_app_setting_get $app db_name) +domain=$(ynh_app_setting_get --app=$app --key=domain) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name -final_path=$(ynh_app_setting_get $app final_path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE @@ -28,15 +28,15 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # REMOVE THE MYSQL DATABASE #================================================= -ynh_print_info "Removing the MySQL database" +ynh_print_info --message="Removing the MySQL database..." # Remove a database if it exists, along with the associated user -ynh_mysql_remove_db $db_user $db_name +ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_print_info "Removing dependencies" +ynh_print_info --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -44,15 +44,15 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info "Removing app main directory" +ynh_print_info --message="Removing app main directory..." # 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_print_info --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -60,7 +60,7 @@ ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Removing php-fpm configuration" +ynh_print_info --message="Removing php-fpm configuration..." # Remove the dedicated php-fpm config ynh_remove_fpm_config @@ -79,13 +79,13 @@ ynh_secure_remove "/etc/cron.d/$app" #================================================= # REMOVE DEDICATED USER #================================================= -ynh_print_info "Removing the dedicated system user" +ynh_print_info --message="Removing the dedicated system user..." # Delete a system user -ynh_system_user_delete $app +ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Removal of $app completed" +ynh_print_info --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 27fb564..a582fe5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -18,48 +19,49 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading settings..." +ynh_print_info --message="Loading settings..." 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) -db_name=$(ynh_app_setting_get $app db_name) +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) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_print_info "Validating restoration parameters..." +ynh_print_info --message="Validating restoration parameters..." -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 #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_print_info "Restoring nginx configuration..." +ynh_print_info --message="Restoring 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_print_info --message="Restoring the app main directory..." -ynh_restore_file "$final_path" +ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_print_info "Recreating the dedicated system user..." +ynh_print_info --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= # RESTORE USER RIGHTS @@ -74,14 +76,14 @@ chown -R $app: $final_path/extensions/ # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_print_info "Reinstalling dependencies..." +ynh_print_info --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies @@ -89,31 +91,30 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE MYSQL DATABASE #================================================= -ynh_print_info "Restoring the MySQL database..." +ynh_print_info --message="Restoring the MySQL database..." -db_pwd=$(ynh_app_setting_get $app mysqlpwd) -ynh_mysql_setup_db $db_name $db_name $db_pwd -ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= # RESTORE THE CRON FILE #================================================= -ynh_restore_file "/etc/cron.d/$app" - +ynh_restore_file --origin_path="/etc/cron.d/$app" #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_print_info "Reloading nginx web server and php-fpm..." +ynh_print_info --message="Reloading nginx web server and php-fpm..." -systemctl reload php7.0-fpm -systemctl reload nginx +ynh_systemd_action --service_name=php7.0-fpm --action=reload +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Restoration completed for $app" +ynh_print_info --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 557962f..7c59e6c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,49 +12,54 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -admin=$(ynh_app_setting_get $app admin) -final_path=$(ynh_app_setting_get $app final_path) -language=$(ynh_app_setting_get $app language) -db_name=$(ynh_app_setting_get $app db_name) -db_pwd=$(ynh_app_setting_get $app mysqlpwd) +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) +language=$(ynh_app_setting_get --app=$app --key=language) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) + +#================================================= +# CHECK VERSION +#================================================= + +upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_print_info "Ensuring downward compatibility..." +ynh_print_info --message="Ensuring downward compatibility..." # If db_name doesn't exist, create it -if [ -z $db_name ]; then - db_name=$(ynh_sanitize_dbid $app) - ynh_app_setting_set $app db_name $db_name +if [ -z "$db_name" ]; then + db_name=$(ynh_sanitize_dbid --db_name=$app) + ynh_app_setting_set --app=$app --key=db_name --value=$db_name fi -if [ -z $admin ]; then - admin=$(ynh_app_setting_get $app admin_user) +if [ -z "$admin" ]; then + admin=$(ynh_app_setting_get --app=$app --key=admin_user) if [ -z $admin ]; then ynh_die --message="no admin user found" fi; - ynh_app_setting_delete $app admin_user - ynh_app_setting_set $app admin $admin + ynh_app_setting_delete --app=$app --key=admin_user + ynh_app_setting_set --app=$app --key=admin --value=$admin fi # 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 + ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info "Backing up the app before upgrading (may take a while)..." +ynh_print_info --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -65,20 +70,19 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors - #================================================= # CHECK THE PATH #================================================= # 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 #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Upgrading source files..." +ynh_print_info --message="Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src # into tmp dir @@ -88,7 +92,7 @@ ynh_setup_source "$tmp_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Upgrading nginx web server configuration..." +ynh_print_info --message="Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config @@ -96,14 +100,14 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_print_info "Upgrading dependencies..." +ynh_print_info --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info "Making sure dedicated system user exists..." +ynh_print_info --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create $app @@ -111,7 +115,7 @@ ynh_system_user_create $app #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Upgrading php-fpm configuration..." +ynh_print_info --message="Upgrading php-fpm configuration..." # Create a dedicated php-fpm config ynh_add_fpm_config @@ -144,7 +148,7 @@ ynh_replace_string "APPNAMETOCHANGE" $app ../hooks/post_user_delete #================================================= # CRON SETUP #================================================= -ynh_print_info "Setting up cron..." +ynh_print_info --message="Setting up cron..." cron_path="/etc/cron.d/$app" ynh_replace_string "__FINALPATH__" $final_path ../conf/freshrss.cron ynh_replace_string "__APP__" $app ../conf/freshrss.cron @@ -165,22 +169,23 @@ chown -R $app: $final_path/extensions/ # reconfigure application with latest parameters $final_path/cli/reconfigure.php --default_user $admin --auth_type http_auth --environment production --base_url https://$domain$path_url --title FreshRSS --api_enabled --db-type mysql --db-host localhost --db-user $db_name --db-password $db_pwd --db-base $db_name + #================================================= # SETUP SSOWAT #================================================= -ynh_print_info "Upgrading SSOwat configuration..." +ynh_print_info --message="Upgrading SSOwat configuration..." -ynh_app_setting_set "$app" unprotected_regex "^\/api\/.*|\/scripts\/api.js$" +ynh_app_setting_set --app="$app" --key=unprotected_regex --value="^\/api\/.*|\/scripts\/api.js$" #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --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_print_info --message="Upgrade of $app completed"