diff --git a/README.md b/README.md index c53153d..e217be3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # FreshRSS for YunoHost [![Integration level](https://dash.yunohost.org/integration/freshrss.svg)](https://dash.yunohost.org/appci/app/freshrss) ![](https://ci-apps.yunohost.org/ci/badges/freshrss.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/freshrss.maintain.svg) -[![Install FreshRSS with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=freshrss) +[![Install FreshRSS with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](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.* @@ -10,7 +10,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to An efficient but powerful RSS aggregator with a nice and mobile-friendly design, as well as extension and themes support. -**Shipped version:** 1.17.0 +**Shipped version:** 1.18.0 ## Screenshots @@ -25,8 +25,9 @@ An efficient but powerful RSS aggregator with a nice and mobile-friendly design, 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 +* Check that the API is working: https://example.net/rss/api/greader.php +* Setup your client with: username: ynh user, password: the password you just setup, URL https://example.tld/rss/api/greader.php + ## Documentation @@ -50,7 +51,7 @@ API (mini) How To: 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. +To try the testing branch, please proceed like this: ``` sudo yunohost app install https://github.com/YunoHost-Apps/freshrss_ynh/tree/testing --debug or diff --git a/conf/app.src b/conf/app.src index f17562a..3ae0e54 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/FreshRSS/FreshRSS/archive/1.17.0.tar.gz -SOURCE_SUM=57c52a15c5f4739e53db606ad652cd446a244676d2a19b2871fe6bee00b75524 +SOURCE_URL=https://github.com/FreshRSS/FreshRSS/archive/1.18.0.tar.gz +SOURCE_SUM=41698e8b1417a12440a8c4d7cc2c9ea40a581f2ad89475ded7d372a87b6b7120 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/hooks/post_app_addaccess b/hooks/post_app_addaccess index a66e3d5..7af8106 100755 --- a/hooks/post_app_addaccess +++ b/hooks/post_app_addaccess @@ -1,18 +1,17 @@ -#!/bin/bash +#!/usr/bin/env bash + +set -a +source /usr/share/yunohost/helpers + app=$1 new_users=$2 -app_path=/var/www/$app -# Source app helpers -. /usr/share/yunohost/helpers +if [[ "${0//.\/50-}" = "$app" ]]; then + final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -if [[ "APPNAMETOCHANGE" = "$app" ]]; -then - for myuser in $(echo "$new_users" | sed "s/,/ /g") + for user in $(echo "$new_users" | sed "s/,/ /g") do user_token=$(ynh_string_random) - $app_path/cli/create-user.php --user $myuser --language en --token $user_token - sudo chown -R $app: $app_path/data/users/$myuser/ + sudo -u $app $final_path/cli/create-user.php --user $user --language en --token $user_token done fi diff --git a/hooks/post_user_create b/hooks/post_user_create index de0d472..d0060f8 100755 --- a/hooks/post_user_create +++ b/hooks/post_user_create @@ -1,12 +1,10 @@ -#!/bin/bash -app=APPNAMETOCHANGE -app_path=/var/www/$app +#!/usr/bin/env bash -myuser=$1 +set -a +source /usr/share/yunohost/helpers -# Source app helpers -. /usr/share/yunohost/helpers +app="${0//.\/50-}" +username=$1 user_token=$(ynh_string_random) -sudo $app_path/cli/create-user.php --user $myuser --language en --token $user_token -sudo chown -R $app: $app_path/data/users/$myuser/ +sudo -u $app $final_path/cli/create-user.php --user $username --language en --token $user_token diff --git a/hooks/post_user_delete b/hooks/post_user_delete index 9b978a5..875c460 100755 --- a/hooks/post_user_delete +++ b/hooks/post_user_delete @@ -1,6 +1,10 @@ -#!/bin/bash -app=APPNAMETOCHANGE -app_path=/var/www/$app +#!/usr/bin/env bash -myuser=$1 -$app_path/cli/delete-user.php --user $myuser +set -a +source /usr/share/yunohost/helpers + +app="${0//.\/50-}" +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +username=$1 + +sudo -u $app $final_path/cli/delete-user.php --user $username diff --git a/manifest.json b/manifest.json index eb4f200..d5842a6 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "RSS aggregator with a nice and mobile-friendly design", "fr": "Agrégateur de flux RSS avec une interface adaptée au mobile" }, - "version": "1.17.0~ynh1", + "version": "1.18.0~ynh1", "url": "http://freshrss.org/", "license": "AGPL-3.0-only", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index dae184e..71401d9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,14 +4,23 @@ # COMMON VARIABLES #================================================= +pkg_dependencies="acl" + YNH_PHP_VERSION="7.3" -extra_php_dependencies="php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-dom php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-xml" +extra_php_dependencies="php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-dom php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-sqlite3 php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-xml" #================================================= # PERSONAL HELPERS #================================================= +function set_permissions { + chown -R root:$app $final_path + chmod -R g=u,g-w,o-rwx $final_path + chown -R $app:$app $final_path/{data,extensions} + setfacl -n -R -m u:www-data:rx -m d:u:www-data:rx $final_path +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/change_url b/scripts/change_url index 3494afb..35caa86 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -103,7 +103,7 @@ fi # SPECIFIC MODIFICATIONS #================================================= -$final_path/cli/reconfigure.php --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 +sudo -u $app $final_path/cli/reconfigure.php --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 #================================================= # GENERIC FINALIZATION diff --git a/scripts/install b/scripts/install index 9f66a19..8a0babd 100755 --- a/scripts/install +++ b/scripts/install @@ -48,6 +48,23 @@ 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 +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=3 + +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app + #================================================= # CREATE A MYSQL DATABASE #================================================= @@ -67,6 +84,8 @@ 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 --dest_dir="$final_path" +set_permissions + #================================================= # NGINX CONFIGURATION #================================================= @@ -75,14 +94,6 @@ ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -92,20 +103,12 @@ ynh_script_progression --message="Configuring PHP-FPM..." ynh_add_fpm_config --package="$extra_php_dependencies" phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -#================================================= -# SPECIFIC SETUP -#================================================= - -ynh_replace_string --match_string="APPNAMETOCHANGE" --replace_string=$app --target_file="../hooks/post_app_addaccess" -ynh_replace_string --match_string="APPNAMETOCHANGE" --replace_string=$app --target_file="../hooks/post_user_create" -ynh_replace_string --match_string="APPNAMETOCHANGE" --replace_string=$app --target_file="../hooks/post_user_delete" - #================================================= # SETUPING FRESHRSS #================================================= ynh_script_progression --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 +sudo -u $app $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 #================================================= # CREATE DEDICATED USER @@ -115,7 +118,7 @@ ynh_script_progression --message="Creating users..." for myuser in $(ynh_user_list) do user_token=$(ynh_string_random) - $final_path/cli/create-user.php --user $myuser --language $language --token $user_token + sudo -u $app $final_path/cli/create-user.php --user $myuser --language $language --token $user_token done #================================================= @@ -134,14 +137,6 @@ chmod 644 "$cron_path" #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions to app files -chown -R root: $final_path -chown -R $app: $final_path/{data,extensions} - #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/remove b/scripts/remove index f699b50..e3c5e6a 100755 --- a/scripts/remove +++ b/scripts/remove @@ -29,6 +29,14 @@ ynh_script_progression --message="Removing the MySQL database..." # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=1 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + #================================================= # REMOVE APP MAIN DIR #================================================= diff --git a/scripts/restore b/scripts/restore index fa75827..d324575 100644 --- a/scripts/restore +++ b/scripts/restore @@ -49,13 +49,6 @@ ynh_script_progression --message="Restoring NGINX configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= -ynh_script_progression --message="Restoring the app main directory..." - -ynh_restore_file --origin_path="$final_path" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -65,13 +58,21 @@ ynh_script_progression --message="Recreating the dedicated system user..." ynh_system_user_create --username=$app #================================================= -# RESTORE USER RIGHTS +# REINSTALL DEPENDENCIES #================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=1 -# Restore permissions on app files -chown -R root: $final_path -chown -R $app: $final_path/data/ -chown -R $app: $final_path/extensions/ +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring the app main directory..." + +ynh_restore_file --origin_path="$final_path" + +set_permissions #================================================= # RESTORE THE PHP-FPM CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index c50675e..6f57ad0 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -80,6 +80,21 @@ path_url=$(ynh_normalize_url_path --path_url=$path_url) #================================================= # STANDARD UPGRADE STEPS +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app + +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=1 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -98,14 +113,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -134,11 +141,6 @@ cp -r $final_path/extensions/. $tmp_path/extensions/ ynh_secure_remove "$final_path" cp -rp "$tmp_path" "$final_path" -#update hook for multi instance -ynh_replace_string --match_string="APPNAMETOCHANGE" --replace_string=$app --target_file="../hooks/post_app_addaccess" -ynh_replace_string --match_string="APPNAMETOCHANGE" --replace_string=$app --target_file="../hooks/post_user_create" -ynh_replace_string --match_string="APPNAMETOCHANGE" --replace_string=$app --target_file="../hooks/post_user_delete" - #================================================= # CRON SETUP #================================================= @@ -163,13 +165,10 @@ fi # SECURE FILES AND DIRECTORIES #================================================= -# Set permissions on app files -chown -R root: $final_path -chmod 755 $final_path -chown -R $app: $final_path/{data,extensions} +set_permissions # 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 +sudo -u $app $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 @@ -181,11 +180,12 @@ ynh_app_setting_delete --app="$app" --key=unprotected_regex ynh_app_setting_delete --app="$app" --key=unprotected_uris #================================================= -# RELOAD NGINX +# RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name=php$YNH_PHP_VERSION-fpm --action=reload #================================================= # END OF SCRIPT