From 1ebc03231603c3c5aad3e5dbc89b0496839ec1cb Mon Sep 17 00:00:00 2001 From: Limezy Date: Mon, 6 May 2024 15:11:20 +0700 Subject: [PATCH] Test with env variable --- scripts/backup | 9 ++------- scripts/change_url | 6 +++--- scripts/install | 31 ++++++++++++++----------------- scripts/remove | 2 -- scripts/restore | 16 ++++++++-------- scripts/upgrade | 10 +++++----- 6 files changed, 32 insertions(+), 42 deletions(-) diff --git a/scripts/backup b/scripts/backup index 4d6fc8c..af6b2dc 100755 --- a/scripts/backup +++ b/scripts/backup @@ -19,18 +19,13 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" - -unlink "/home/$app/app" -unlink "/home/$app/repos" - -ynh_backup --src_path="/home/$app" +ynh_backup --src_path="/home/yunohost.app/$app/app" #================================================= # BACKUP THE REPOS DIRECTORY #================================================= -ynh_backup --src_path="/home/yunohost.app/$app" --is_big +ynh_backup --src_path="/home/yunohost.app/$app/repos" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 43b84fb..8157cf0 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="$install_dir/app/.env.local" +ynh_add_config --template=".env" --destination="/home/yunohost.app/$app/app/.env.local" -chmod 400 "$install_dir/app/.env.local" -chown $app:$app "$install_dir/app/.env.local" +chmod 400 "/home/yunohost.app/$app/app/.env.local" +chown $app:$app "/home/yunohost.app/$app/app/.env.local" #================================================= # GENERIC FINALISATION diff --git a/scripts/install b/scripts/install index 5c7e942..84a96e2 100755 --- a/scripts/install +++ b/scripts/install @@ -35,22 +35,19 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -# Download, check integrity, uncompress and patch the source from manifest.toml -ynh_setup_source --dest_dir="$install_dir/app" - -mkdir "/home/$app" && chmod 700 "/home/$app" -ln -s "$install_dir/app" "/home/$app/app" - -mkdir "/home/$app/.ssh" && chmod 700 "/home/$app/.ssh" -touch "/home/$app/.ssh/authorized_keys" && chmod 600 "/home/$app/.ssh/authorized_keys" - mkdir "/home/yunohost.app/$app" && chmod 700 "/home/yunohost.app/$app" -ln -s "/home/yunohost.app/$app" "/home/$app/repos" && chmod 700 "/home/$app/repos" -chown -R $app:www-data "$install_dir" -chown -R $app:www-data "/home/$app" +# Download, check integrity, uncompress and patch the source from manifest.toml +ynh_setup_source --dest_dir="/home/yunohost.app/$app/app" -chmod 700 "/home/$app/app/helpers/shells/"* +chmod 700 "/home/yunohost.app/$app" + +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" + +chown -R $app:www-data "/home/yunohost.app/$app" + +chmod 700 "/home/yunohost.app/$app/app/helpers/shells/"* #================================================= # SYSTEM CONFIGURATION @@ -74,17 +71,17 @@ 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="$install_dir/app/.env.local" +ynh_add_config --template=".env" --destination="home/yunohost.app/$app/app/.env.local" -chmod 400 "$install_dir/app/.env.local" -chown $app:$app "$install_dir/app/.env.local" +chmod 400 "/home/yunohost.app/$app/app/.env.local" +chown $app:$app "/home/yunohost.app/$app/app/.env.local" #================================================= # INSTALL BORGWARHOUSE #================================================= ynh_script_progression --message="Installing $app..." --weight=10 -pushd $install_dir/app +pushd /home/yunohost.app/$app/app ynh_use_nodejs ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH $ynh_npm ci ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH NODE_ENV=production $ynh_npm run build diff --git a/scripts/remove b/scripts/remove index b2abf47..ce16d7a 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/$app" - ynh_secure_remove --file="/home/yunohost.app/$app" #================================================= diff --git a/scripts/restore b/scripts/restore index 4152f8e..280aebd 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 -ynh_restore_file --origin_path="$install_dir" +mkdir -p "/home/yunohost.app/$app" && chmod 700 "/home/yunohost.app/$app" -chown -R $app:www-data "$install_dir" +ynh_restore_file --origin_path="/home/yunohost.app/$app/app" -ynh_restore_file --origin_path="/home/$app" -ynh_restore_file --origin_path="/home/yunohost.app/$app" --not_mandatory +chown -R $app:www-data "/home/yunohost.app/$app/app" -chown -R $app:www-data "/home/$app" -chown -R $app:www-data "/home/yunohost.app/$app" -ln -s "/home/yunohost.app/$app" "/home/$app/repos" && chmod 700 "/home/$app/repos" -ln -s "$install_dir/app" "/home/$app/app" && chmod 700 "/home/$app/app" +ynh_restore_file --origin_path="/home/yunohost.app/$app/repos" --not_mandatory + +chown -R $app:www-data "/home/yunohost.app/$app/repos" + +chmod 700 "/home/yunohost.app/$app" #================================================= # REINSTALL DEPENDENCIES diff --git a/scripts/upgrade b/scripts/upgrade index e59d464..d609955 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -37,10 +37,10 @@ then 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="$install_dir" --keep="app/.env.local app/config/users.json app/config/repo.json" + ynh_setup_source --dest_dir="/home/yunohost.app/$app/app" --keep="app/.env.local app/config/users.json app/config/repo.json" fi -chown -R $app:www-data "$install_dir" +chown -R $app:www-data "/home/yunohost.app/$app/app" #================================================= # REAPPLY SYSTEM CONFIGURATIONS @@ -60,10 +60,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="$install_dir/app/.env.local" +ynh_add_config --template=".env" --destination="/home/yunohost.app/$app/app/.env.local" -chmod 400 "$install_dir/app/.env.local" -chown $app:$app "$install_dir/app/.env.local" +chmod 400 "/home/yunohost.app/$app/app/.env.local" +chown $app:$app "/home/yunohost.app/$app/app/.env.local" #================================================= # START SYSTEMD SERVICE