From 91cd8d78e453280bf9c15a8c40b83737476fdcb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 29 Sep 2024 09:13:50 +0200 Subject: [PATCH] cleaning --- manifest.toml | 2 +- scripts/backup | 5 ----- scripts/install | 16 ++++------------ scripts/remove | 11 +---------- scripts/restore | 10 +--------- scripts/upgrade | 21 ++++++--------------- 6 files changed, 13 insertions(+), 52 deletions(-) diff --git a/manifest.toml b/manifest.toml index bb50635..4cd8c24 100644 --- a/manifest.toml +++ b/manifest.toml @@ -17,7 +17,7 @@ admindoc = "https://umami.is/docs/about" code = "https://github.com/mikecao/umami" [integration] -yunohost = ">= 11.2.18" +yunohost = ">= 11.2.30" helpers_version = "2.1" architectures = "all" multi_instance = true diff --git a/scripts/backup b/scripts/backup index c20d5a6..253b5d8 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,6 +1,5 @@ #!/bin/bash -# 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,10 +17,6 @@ ynh_backup "$install_dir" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# BACKUP SYSTEMD -#================================================= - ynh_backup "/etc/systemd/system/$app.service" #================================================= diff --git a/scripts/install b/scripts/install index bcd5442..ef52b31 100755 --- a/scripts/install +++ b/scripts/install @@ -16,20 +16,15 @@ ynh_nodejs_install #================================================= ynh_script_progression "Setting up source files..." -# Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir/build" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" #================================================= # SYSTEM CONFIGURATION #================================================= ynh_script_progression "Adding system configurations related to $app..." -# Create a dedicated NGINX config ynh_config_add_nginx -# Create a dedicated systemd config ynh_config_add_systemd yunohost service add $app --description="Web Analytics" --log="/var/log/$app/$app.log" @@ -41,8 +36,7 @@ ynh_script_progression "Adding $app's configuration..." ynh_config_add --template=".env" --destination="$install_dir/build/.env" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 650 "$install_dir/build/.env" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/build/.env" +chmod 650 "$install_dir/build/.env" ynh_script_progression "Provisioning pgcrypto..." @@ -54,9 +48,8 @@ ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS pgcrypto;" ynh_script_progression "Configuring the app..." pushd "$install_dir/build" - - ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn install - ynh_hide_warnings ynh_exec_as_app node_load_PATH NEXT_TELEMETRY_DISABLED=1 yarn build + ynh_hide_warnings ynh_exec_as_app yarn install + ynh_hide_warnings ynh_exec_as_app NEXT_TELEMETRY_DISABLED=1 yarn build # Actual app is a subset of release assets # List of deps based on Dockerfile: https://github.com/umami-software/umami/blob/master/Dockerfile @@ -75,7 +68,7 @@ chown -R $app:www-data "$install_dir/release" mv -f $install_dir/build/.next/standalone/* $install_dir/build/.next/standalone/.[!.]* $install_dir/release pushd "$install_dir/release" - ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn add npm-run-all dotenv prisma + ynh_hide_warnings ynh_exec_as_app yarn add npm-run-all dotenv prisma popd ynh_safe_rm "$install_dir/.cache" @@ -87,7 +80,6 @@ ynh_safe_rm "$install_dir/build" #================================================= ynh_script_progression "Starting $app's systemd service..." -# Start a systemd service ynh_systemctl --service=$app --action="start" #================================================= diff --git a/scripts/remove b/scripts/remove index 93074f5..8789eec 100755 --- a/scripts/remove +++ b/scripts/remove @@ -5,26 +5,17 @@ source /usr/share/yunohost/helpers #================================================= # REMOVE SYSTEM CONFIGURATIONS -#================================================= -# REMOVE SYSTEMD SERVICE - #================================================= ynh_script_progression "Removing system configurations related to $app..." -# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_hide_warnings yunohost service status $app >/dev/null -then - ynh_script_progression "Removing $app service integration..." +if ynh_hide_warnings yunohost service status $app >/dev/null; then yunohost service remove $app fi -# Remove the dedicated systemd config ynh_config_remove_systemd -# Remove the app-specific logrotate config ynh_config_remove_logrotate -# Remove the dedicated NGINX config ynh_config_remove_nginx ynh_nodejs_remove diff --git a/scripts/restore b/scripts/restore index 2a9f55a..6cb9c63 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,6 +1,5 @@ #!/bin/bash -# 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 @@ -11,16 +10,11 @@ ynh_script_progression "Restoring the app main directory..." ynh_restore "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" -#================================================= -# SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= ynh_script_progression "Reinstalling dependencies..." -# Install Nodejs ynh_nodejs_install #================================================= @@ -30,13 +24,11 @@ ynh_script_progression "Restoring the database..." ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS pgcrypto;" -ynh_psql_db_shell < "./db.sql"" +ynh_psql_db_shell < ./db.sql #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -# RESTORE THE PHP-FPM CONFIGURATION -#================================================= ynh_script_progression "Restoring system configurations related to $app..." ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" diff --git a/scripts/upgrade b/scripts/upgrade index e4b0f31..bb03740 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -8,12 +8,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression "Ensuring downward compatibility..." -# If language doesn't exist, create it -# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=language --value="en-US" -if [ -z "${language:-}" ]; then - language="en-US" - ynh_app_setting_set --key=language --value=$language -fi +ynh_app_setting_set_default --key=language --value="en-US" #================================================= # STOP SYSTEMD SERVICE @@ -51,7 +46,6 @@ chown -R $app:www-data "$install_dir/build" #================================================= ynh_script_progression "Upgrading dependencies..." -# Install Nodejs ynh_nodejs_install #================================================= @@ -59,10 +53,8 @@ ynh_nodejs_install #================================================= ynh_script_progression "Upgrading system configurations related to $app..." -# Create a dedicated NGINX config ynh_config_add_nginx -# Create a dedicated systemd config ynh_config_add_systemd yunohost service add $app --description="Web Analytics" --log="/var/log/$app/$app.log" @@ -74,8 +66,7 @@ ynh_script_progression "Adding $app's configuration..." ynh_config_add --template=".env" --destination="$install_dir/build/.env" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 650 "$install_dir/build/.env" -#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/build/.env" +chmod 650 "$install_dir/build/.env" ynh_script_progression "Provisioning pgcrypto..." @@ -84,13 +75,13 @@ ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS pgcrypto;" #================================================= # CONFIGURE THE APP #================================================= + if [[ "$upgrade_type" == "UPGRADE_APP" || $(ynh_app_upgrading_from_version_before_or_equal_to 2.7.0~ynh4) ]]; then ynh_script_progression "Configuring the app..." pushd $install_dir/build - - ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn install - ynh_hide_warnings ynh_exec_as_app node_load_PATH NEXT_TELEMETRY_DISABLED=1 yarn build + ynh_hide_warnings ynh_exec_as_app yarn install + ynh_hide_warnings ynh_exec_as_app NEXT_TELEMETRY_DISABLED=1 yarn build # Actual app is a subset of release assets # List of deps based on Dockerfile: https://github.com/umami-software/umami/blob/master/Dockerfile @@ -111,7 +102,7 @@ if [[ "$upgrade_type" == "UPGRADE_APP" || $(ynh_app_upgrading_from_version_befor mv -f $install_dir/build/.next/standalone/* $install_dir/build/.next/standalone/.[!.]* $install_dir/release pushd "$install_dir/release" - ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn add npm-run-all dotenv prisma + ynh_hide_warnings ynh_exec_as_app yarn add npm-run-all dotenv prisma popd fi