From bb255b8ce79bebec9bee1a7efb883c90bd9d724a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Mon, 17 Jun 2024 19:01:39 +0200 Subject: [PATCH] use data_dir --- conf/systemd.service | 2 +- manifest.toml | 2 ++ scripts/backup | 17 +---------------- scripts/change_url | 6 +++--- scripts/install | 22 ++++++++++------------ scripts/remove | 2 -- scripts/restore | 14 +++++++------- scripts/upgrade | 10 +++++----- 8 files changed, 29 insertions(+), 46 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index e497297..c923514 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -8,7 +8,7 @@ Type=simple User=__APP__ Group=__APP__ Environment="__YNH_NODE_LOAD_PATH__" -WorkingDirectory=/home/yunohost.app/__APP__/app +WorkingDirectory=__DATA_DIR__/app Environment=PORT=__PORT__ ExecStart=__YNH_NPM__ run start Restart=on-failure diff --git a/manifest.toml b/manifest.toml index 5ad536c..cd159d6 100644 --- a/manifest.toml +++ b/manifest.toml @@ -54,6 +54,8 @@ ram.runtime = "50M" [resources.install_dir] + [resources.data_dir] + [resources.permissions] main.url = "/" api.url = "/api" diff --git a/scripts/backup b/scripts/backup index 4d90835..f6df0b2 100755 --- a/scripts/backup +++ b/scripts/backup @@ -15,18 +15,11 @@ source /usr/share/yunohost/helpers #================================================= ynh_print_info --message="Declaring files to be backed up..." -#================================================= -# BACKUP THE APP MAIN DIR -#================================================= - -ynh_backup --src_path="/home/yunohost.app/$app/app" -ynh_backup --src_path="/home/yunohost.app/$app/.ssh" - #================================================= # BACKUP THE REPOS DIRECTORY #================================================= -ynh_backup --src_path="/home/yunohost.app/$app/repos" --is_big +ynh_backup --src_path="$data_dir" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION @@ -34,16 +27,8 @@ ynh_backup --src_path="/home/yunohost.app/$app/repos" --is_big ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# BACKUP SYSTEMD -#================================================= - ynh_backup --src_path="/etc/systemd/system/$app.service" -#================================================= -# BACKUP VARIOUS FILES -#================================================= - ynh_backup --src_path="/etc/cron.d/$app" #================================================= diff --git a/scripts/change_url b/scripts/change_url index 8157cf0..23f1a6d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -30,10 +30,10 @@ ynh_change_url_nginx_config #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -ynh_add_config --template=".env" --destination="/home/yunohost.app/$app/app/.env.local" +ynh_add_config --template=".env" --destination="$data_dir/app/.env.local" -chmod 400 "/home/yunohost.app/$app/app/.env.local" -chown $app:$app "/home/yunohost.app/$app/app/.env.local" +chmod 400 "$data_dir/app/.env.local" +chown $app:$app "$data_dir/app/.env.local" #================================================= # GENERIC FINALISATION diff --git a/scripts/install b/scripts/install index 0bf997c..fcedbd5 100755 --- a/scripts/install +++ b/scripts/install @@ -35,21 +35,19 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -mkdir "/home/yunohost.app/$app" && chmod 700 "/home/yunohost.app/$app" - # Download, check integrity, uncompress and patch the source from manifest.toml -ynh_setup_source --dest_dir="/home/yunohost.app/$app/app" +ynh_setup_source --dest_dir="$data_dir/app" -chmod 700 "/home/yunohost.app/$app" +chmod 700 "$data_dir" -mkdir "/home/yunohost.app/$app/.ssh" && chmod 700 "/home/yunohost.app/$app/.ssh" -touch "/home/yunohost.app/$app/.ssh/authorized_keys" && chmod 600 "/home/yunohost.app/$app/.ssh/authorized_keys" +mkdir "$data_dir/.ssh" && chmod 700 "$data_dir/.ssh" +touch "$data_dir/.ssh/authorized_keys" && chmod 600 "$data_dir/.ssh/authorized_keys" -chmod 700 "/home/yunohost.app/$app/app/helpers/shells/"* +chmod 700 "$data_dir/app/helpers/shells/"* -mkdir "/home/yunohost.app/$app/repos" && chmod 700 "/home/yunohost.app/$app/repos" +mkdir "$data_dir/repos" && chmod 700 "$data_dir/repos" -chown -R $app:www-data "/home/yunohost.app/$app" +chown -R $app:www-data "$data_dir" #================================================= # SYSTEM CONFIGURATION @@ -73,10 +71,10 @@ yunohost service add $app --description="WebUI for BorgBackup" --log="/var/log/$ #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -ynh_add_config --template=".env" --destination="/home/yunohost.app/$app/app/.env.local" +ynh_add_config --template=".env" --destination="$data_dir/app/.env.local" -chmod 400 "/home/yunohost.app/$app/app/.env.local" -chown $app:$app "/home/yunohost.app/$app/app/.env.local" +chmod 400 "$data_dir/app/.env.local" +chown $app:$app "$data_dir/app/.env.local" #================================================= # INSTALL BORGWARHOUSE diff --git a/scripts/remove b/scripts/remove index ce16d7a..3ec7dc4 100755 --- a/scripts/remove +++ b/scripts/remove @@ -31,8 +31,6 @@ ynh_remove_nodejs ynh_secure_remove --file="/etc/cron.d/$app" -ynh_secure_remove --file="/home/yunohost.app/$app" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 10a0863..4b79963 100755 --- a/scripts/restore +++ b/scripts/restore @@ -15,17 +15,17 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=1 -mkdir -p "/home/yunohost.app/$app" && chmod 700 "/home/yunohost.app/$app" +mkdir -p "$data_dir" && chmod 700 "$data_dir" -ynh_restore_file --origin_path="/home/yunohost.app/$app/app" -ynh_restore_file --origin_path="/home/yunohost.app/$app/.ssh" +ynh_restore_file --origin_path="$data_dir/app" +ynh_restore_file --origin_path="$data_dir/.ssh" -ynh_restore_file --origin_path="/home/yunohost.app/$app/repos" --not_mandatory +ynh_restore_file --origin_path="$data_dir/repos" --not_mandatory -chmod -R 700 "/home/yunohost.app/$app" -chmod 600 "/home/yunohost.app/$app/.ssh/authorized_keys" +chmod -R 700 "$data_dir" +chmod 600 "$data_dir/.ssh/authorized_keys" -chown -R $app:www-data "/home/yunohost.app/$app" +chown -R $app:www-data "$data_dir" #================================================= # REINSTALL DEPENDENCIES diff --git a/scripts/upgrade b/scripts/upgrade index 274db0c..3bd9a6c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -32,9 +32,9 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from manifest.toml -ynh_setup_source --dest_dir="/home/yunohost.app/$app/app" --keep="app/.env.local app/config/users.json app/config/repo.json" +ynh_setup_source --dest_dir="$data_dir/app" --keep="app/.env.local app/config/users.json app/config/repo.json" -chown -R $app:www-data "/home/yunohost.app/$app/app" +chown -R $app:www-data "$data_dir/app" #================================================= # REAPPLY SYSTEM CONFIGURATIONS @@ -59,10 +59,10 @@ yunohost service add $app --description="WebUI for BorgBackup" --log="/var/log/$ #================================================= ynh_script_progression --message="Updating a configuration file..." --weight=1 -ynh_add_config --template=".env" --destination="/home/yunohost.app/$app/app/.env.local" +ynh_add_config --template=".env" --destination="$data_dir/app/.env.local" -chmod 400 "/home/yunohost.app/$app/app/.env.local" -chown $app:$app "/home/yunohost.app/$app/app/.env.local" +chmod 400 "$data_dir/app/.env.local" +chown $app:$app "$data_dir/app/.env.local" #================================================= # INSTALL BORGWARHOUSE