diff --git a/conf/freshrss.cron b/conf/freshrss.cron index 659ed47..1946736 100644 --- a/conf/freshrss.cron +++ b/conf/freshrss.cron @@ -1 +1 @@ -*/10 * * * * __APP__ /usr/bin/php7.0 __FINALPATH__/app/actualize_script.php >/tmp/__APP__.log 2>&1 +*/10 * * * * __APP__ /usr/bin/php${YNH_PHP_VERSION}__FINALPATH__/app/actualize_script.php >/tmp/__APP__.log 2>&1 diff --git a/conf/nginx.conf b/conf/nginx.conf index 4cc8174..42b044f 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -10,7 +10,7 @@ location __PATH__/ { 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_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; fastcgi_index index.php; include fastcgi_params; diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 2052aa6..9b2ecce 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -33,7 +33,7 @@ group = __USER__ ; (IPv6 and IPv4-mapped) on a specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. -listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock +listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock ; Set listen(2) backlog. ; Default Value: 511 (-1 on FreeBSD and OpenBSD) diff --git a/manifest.json b/manifest.json index b8f3cc5..df80e6c 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "plopoyop@gmail.com" }, "requirements": { - "yunohost": ">= 3.5" + "yunohost": ">= 3.8.1" }, "multi_instance": true, "services": [ diff --git a/scripts/_common.sh b/scripts/_common.sh index b1610b5..2d5cb36 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,11 +4,9 @@ # COMMON VARIABLES #================================================= -if [ "$(lsb_release --codename --short)" == "jessie" ]; then - pkg_dependencies="php5-gd" -else - pkg_dependencies="php-gd php-zip php-dom php-mbstring php-gmp php-sqlite3 php-curl php-intl php-xml" -fi +pkg_dependencies="php${YNH_PHP_VERSION}-gd php-zip php${YNH_PHP_VERSION}-dom php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-sqlite3 php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-xml" + +YNH_PHP_VERSION="7.3" #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index f957038..dffd82b 100755 --- a/scripts/backup +++ b/scripts/backup @@ -28,32 +28,31 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= -# STANDARD BACKUP STEPS +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info --message="Backing up the main app directory..." ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Backing up nginx web server configuration..." ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_print_info --message="Backing up php-fpm configuration..." -ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE #================================================= -ynh_print_info --message="Backing up the MySQL database..." ynh_mysql_dump_db --database="$db_name" > db.sql diff --git a/scripts/change_url b/scripts/change_url index 40f2601..3494afb 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -21,11 +21,10 @@ new_path=$YNH_APP_NEW_PATH app=$YNH_APP_INSTANCE_NAME - #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) @@ -46,7 +45,6 @@ if [ -z $admin ]; then ynh_app_setting_set $app admin $admin fi - #================================================= # CHECK PATHS SYNTAX #================================================= @@ -77,7 +75,7 @@ fi #================================================= # MODIFY URL IN NGINX CONF FILE #================================================= -ynh_print_info --message="Updating nginx web server configuration..." +ynh_script_progression --message="Updating NGINX web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -107,19 +105,17 @@ fi $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 #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." + ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Change of URL completed for $app" +ynh_script_progression --message="Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index a271d72..c569af4 100755 --- a/scripts/install +++ b/scripts/install @@ -30,7 +30,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_print_info --message="Validating installation parameters..." +ynh_script_progression --message="Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" @@ -41,28 +41,24 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_print_info --message="Storing installation settings..." +ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=language --value=$language -#================================================= -# STANDARD MODIFICATIONS -#================================================= - #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_print_info --message="Installing dependencies..." +ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE A MYSQL DATABASE #================================================= -ynh_print_info --message="Creating a MySQL database..." +ynh_script_progression --message="Creating a MySQL database..." db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name @@ -72,11 +68,7 @@ ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -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_script_progression --message="Setting up source files..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src @@ -85,17 +77,15 @@ ynh_setup_source --dest_dir="$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info --message="Configuring nginx web server..." +ynh_script_progression --message="Configuring NGINX web server..." -### `ynh_add_nginx_config` will use the file conf/nginx.conf - -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info --message="Configuring system user..." +ynh_script_progression --message="Configuring system user..." # Create a system user ynh_system_user_create --username=$app @@ -103,26 +93,31 @@ ynh_system_user_create --username=$app #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_print_info --message="Configuring php-fpm..." +ynh_script_progression --message="Configuring PHP-FPM..." -# Create a dedicated php-fpm config +# Create a dedicated PHP-FPM config ynh_add_fpm_config #================================================= # SPECIFIC SETUP #================================================= -ynh_replace_string "APPNAMETOCHANGE" $app ../hooks/post_app_addaccess -ynh_replace_string "APPNAMETOCHANGE" $app ../hooks/post_user_create -ynh_replace_string "APPNAMETOCHANGE" $app ../hooks/post_user_delete +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_print_info --message="FreshRSS setup script..." +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 -# Add users -ynh_print_info --message="Creating users..." +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Creating users..." + for myuser in $(ynh_user_list) do user_token=$(ynh_string_random) @@ -132,7 +127,7 @@ done #================================================= # SETUP A CRON #================================================= -ynh_print_info --message="Setting up cron..." +ynh_script_progression --message="Setting up cron..." cron_path="/etc/cron.d/$app" ynh_replace_string --match_string="__FINALPATH__" --replace_string=$final_path --target_file="../conf/freshrss.cron" @@ -140,9 +135,6 @@ ynh_replace_string --match_string="__APP__" --replace_string=$app --target_file= cp ../conf/freshrss.cron "$cron_path" chmod 644 "$cron_path" -#================================================= - - #================================================= # GENERIC FINALIZATION #================================================= @@ -151,25 +143,22 @@ chmod 644 "$cron_path" # Set permissions to app files chown -R root: $final_path -chown -R $app: $final_path/data/ -chown -R $app: $final_path/extensions/ - +chown -R $app: $final_path/{data,extensions} #================================================= # SETUP SSOWAT #================================================= -ynh_print_info --message="Configuring SSOwat..." +ynh_script_progression --message="Configuring SSOwat..." #skip api directory ynh_app_setting_set --app="$app" --key=skipped_uris --value="/api/,/scripts/api.js" ynh_app_setting_delete --app="$app" --key=unprotected_regex ynh_app_setting_delete --app="$app" --key=unprotected_uris - #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -177,4 +166,5 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_print_info --message="Installation of $app completed" +ynh_script_progression --message="Installation of $app completed" --last + diff --git a/scripts/remove b/scripts/remove index 4b189f5..7cfaeaa 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -21,14 +21,10 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) -#================================================= -# STANDARD REMOVE -#================================================= - #================================================= # REMOVE THE MYSQL DATABASE #================================================= -ynh_print_info --message="Removing the MySQL database..." +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 @@ -36,7 +32,7 @@ ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_print_info --message="Removing dependencies..." +ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -44,7 +40,7 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info --message="Removing app main directory..." +ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -52,7 +48,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Removing nginx web server configuration..." +ynh_script_progression --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -60,9 +56,9 @@ ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= -ynh_print_info --message="Removing php-fpm configuration..." +ynh_script_progression --message="Removing PHP-FPM configuration..." -# Remove the dedicated php-fpm config +# Remove the dedicated PHP-FPM config ynh_remove_fpm_config #================================================= @@ -79,7 +75,7 @@ ynh_secure_remove "/etc/cron.d/$app" #================================================= # REMOVE DEDICATED USER #================================================= -ynh_print_info --message="Removing the dedicated system user..." +ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user ynh_system_user_delete --username=$app @@ -88,4 +84,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_print_info --message="Removal of $app completed" +ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index a582fe5..db3a0d9 100644 --- a/scripts/restore +++ b/scripts/restore @@ -19,7 +19,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading settings..." +ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -32,7 +32,7 @@ db_user=$db_name #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_print_info --message="Validating restoration parameters..." +ynh_script_progression --message="Validating restoration parameters..." ynh_webpath_available --domain=$domain --path_url=$path_url \ || ynh_die --message="Path not available: ${domain}${path_url}" @@ -44,21 +44,21 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Restoring nginx configuration..." +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_print_info --message="Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_print_info --message="Recreating the dedicated system user..." +ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create --username=$app @@ -76,14 +76,14 @@ chown -R $app: $final_path/extensions/ # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_print_info --message="Reinstalling dependencies..." +ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies @@ -91,7 +91,7 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE MYSQL DATABASE #================================================= -ynh_print_info --message="Restoring the MySQL database..." +ynh_script_progression --message="Restoring the MySQL database..." 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 @@ -108,13 +108,13 @@ ynh_restore_file --origin_path="/etc/cron.d/$app" #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_print_info --message="Reloading nginx web server and php-fpm..." +ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." -ynh_systemd_action --service_name=php7.0-fpm --action=reload +ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Restoration completed for $app" +ynh_script_progression --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 886e5c9..259ec5f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -33,7 +33,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_print_info --message="Ensuring downward compatibility..." +ynh_script_progression --message="Ensuring downward compatibility..." # If db_name doesn't exist, create it if [ -z "$db_name" ]; then @@ -59,7 +59,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info --message="Backing up the app before upgrading (may take a while)..." +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -82,7 +82,7 @@ path_url=$(ynh_normalize_url_path --path_url=$path_url) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info --message="Upgrading source files..." +ynh_script_progression --message="Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src # into tmp dir @@ -92,7 +92,7 @@ ynh_setup_source "$tmp_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info --message="Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading NGINX web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config @@ -100,14 +100,14 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_print_info --message="Upgrading dependencies..." +ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info --message="Making sure dedicated system user exists..." +ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create $app @@ -115,7 +115,7 @@ ynh_system_user_create $app #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_print_info --message="Upgrading php-fpm configuration..." +ynh_script_progression --message="Upgrading PHP-FPM configuration..." # Create a dedicated php-fpm config ynh_add_fpm_config @@ -141,14 +141,14 @@ ynh_secure_remove "$final_path" cp -rp "$tmp_path" "$final_path" #update hook for multi instance -ynh_replace_string "APPNAMETOCHANGE" $app ../hooks/post_app_addaccess -ynh_replace_string "APPNAMETOCHANGE" $app ../hooks/post_user_create -ynh_replace_string "APPNAMETOCHANGE" $app ../hooks/post_user_delete +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 #================================================= -ynh_print_info --message="Setting up cron..." +ynh_script_progression --message="Setting up cron..." cron_path="/etc/cron.d/$app" ynh_replace_string "__FINALPATH__" $final_path ../conf/freshrss.cron @@ -169,8 +169,7 @@ fi # Set permissions on app files chown -R root: $final_path chmod 755 $final_path -chown -R $app: $final_path/data/ -chown -R $app: $final_path/extensions/ +chown -R $app: $final_path/{data,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 @@ -178,7 +177,7 @@ $final_path/cli/reconfigure.php --default_user $admin --auth_type http_auth --en #================================================= # SETUP SSOWAT #================================================= -ynh_print_info --message="Upgrading SSOwat configuration..." +ynh_script_progression --message="Upgrading SSOwat configuration..." ynh_app_setting_set --app="$app" --key=skipped_uris --value="/api/,/scripts/api.js" ynh_app_setting_delete --app="$app" --key=unprotected_regex @@ -187,7 +186,7 @@ ynh_app_setting_delete --app="$app" --key=unprotected_uris #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -195,4 +194,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_print_info --message="Upgrade of $app completed" +ynh_script_progression --message="Upgrade of $app completed"