From 7923f6bf9389d5b0a60d68db9945598bb1e923de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:08:57 +0200 Subject: [PATCH] cleaning --- scripts/backup | 12 ------------ scripts/install | 4 ++-- scripts/remove | 1 - scripts/restore | 6 ++---- scripts/upgrade | 40 +++++++++++----------------------------- 5 files changed, 15 insertions(+), 48 deletions(-) diff --git a/scripts/backup b/scripts/backup index 7302a3f..96f73ba 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 @@ -16,7 +15,6 @@ ynh_backup "$install_dir" # BACKUP THE DATA DIR #================================================= -# Only relevant if there is a "data_dir" resource for this app ynh_backup "$data_dir" #================================================= @@ -25,18 +23,8 @@ ynh_backup "$data_dir" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= - ynh_backup "/etc/logrotate.d/$app" -#================================================= -# BACKUP SYSTEMD -#================================================= - ynh_backup "/etc/systemd/system/$app.service" #================================================= diff --git a/scripts/install b/scripts/install index f6bc46d..b3ef862 100755 --- a/scripts/install +++ b/scripts/install @@ -28,8 +28,8 @@ pushd "$install_dir" ynh_hide_warnings ynh_exec_as_app yarn install --pure-lockfile ynh_hide_warnings ynh_exec_as_app yarn install:python - ynh_hide_warnings ynh_exec_as_app :$install_dir/node_modules/.bin yarn run build:prod - ynh_hide_warnings ynh_exec_as_app yarn cache clean + ynh_hide_warnings ynh_exec_as_app $install_dir/node_modules/.bin yarn run build:prod + ynh_hide_warnings ynh_exec_as_app yarn cache clean popd pushd "$install_dir/sandbox/pyodide" diff --git a/scripts/remove b/scripts/remove index b7e622a..8778e44 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,6 @@ ynh_script_progression "Removing system configurations related to $app..." redis_db=$(ynh_app_setting_get --key=redis_db) -# 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..." diff --git a/scripts/restore b/scripts/restore index a81a4a9..4dbacde 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 @@ -17,7 +16,8 @@ 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 | chown -R $app:www-data "$install_dir" +chown -R $app:www-data "$install_dir" + #================================================= # RESTORE THE DATA DIRECTORY #================================================= @@ -25,7 +25,6 @@ ynh_script_progression "Restoring the data directory..." ynh_restore "$data_dir" -# (Same as for install dir) chown -R $app:www-data "$data_dir" #================================================= @@ -49,7 +48,6 @@ ynh_restore "/etc/logrotate.d/$app" #================================================= ynh_script_progression "Reloading NGINX web server and $app's service..." -# Typically you only have either $app or php-fpm but not both at the same time... ynh_systemctl --service=$app --action="start" ynh_systemctl --service=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 37507e0..1d1f9ee 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -33,42 +33,27 @@ fi #================================================= # UPGRADE DEPENDENCIES #================================================= - ynh_script_progression "Upgrading dependencies..." ynh_nodejs_install -#================================================= -# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression "Upgrading source files..." -# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed -if ynh_app_upstream_version_changed -then - ynh_script_progression "Upgrading source files..." +ynh_setup_source --dest_dir="$install_dir" --full_replace - # Download, check integrity, uncompress and patch the source from manifest.toml - ynh_setup_source --dest_dir="$install_dir" --full_replace -fi +pushd "$install_dir" + ynh_hide_warnings ynh_exec_as_app yarn install --pure-lockfile + ynh_hide_warnings ynh_exec_as_app yarn install:python + ynh_hide_warnings ynh_exec_as_app $install_dir/node_modules/.bin yarn run build:prod + ynh_hide_warnings ynh_exec_as_app yarn cache clean +popd -#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" -# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed -if ynh_app_upstream_version_changed -then - pushd "$install_dir" - - ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn install --pure-lockfile - ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn install:python - ynh_hide_warnings ynh_exec_as_app node_load_PATH:$install_dir/node_modules/.bin yarn run build:prod - ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn cache clean - popd - - pushd "$install_dir/sandbox/pyodide" - ynh_hide_warnings ynh_exec_as_app node_load_PATH make setup - popd -fi +pushd "$install_dir/sandbox/pyodide" + ynh_hide_warnings ynh_exec_as_app node_load_PATH make setup +popd #================================================= # REAPPLY SYSTEM CONFIGURATIONS @@ -93,9 +78,6 @@ ynh_script_progression "Updating configuration..." admin_email=$(ynh_user_get_info --username=$admin --key=mail) ynh_config_add --template="default.env" --destination="$install_dir/default.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 400 "$install_dir/default.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/default.env" - #================================================= # START SYSTEMD SERVICE #=================================================