From 094a09d54ef0031afda1bf3beed0f9ea8dddfca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 21 Jun 2022 15:21:49 +0200 Subject: [PATCH 1/4] change path to opt --- config_panel.toml | 4 ++-- doc/DISCLAIMER.md | 2 +- doc/DISCLAIMER_fr.md | 2 +- scripts/backup | 3 --- scripts/install | 7 +++---- scripts/restore | 3 --- 6 files changed, 7 insertions(+), 14 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index ae8fec3..f6887f3 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -11,7 +11,7 @@ services = ["__APP__"] ask = "Set MOTD" type = "string" help = "Set the MOTD message shown in Vikunja login page" - bind = "motd:/etc/vikunja/config.yml" + bind = "motd:/opt/__APP__/config.yml" [main.config.enable_registration] ask = "Enable registration" @@ -19,5 +19,5 @@ services = ["__APP__"] yes = "true" no = "false" help = "Whether to let new users registering themselves or not" - bind = "enableregistration:/etc/vikunja/config.yml" + bind = "enableregistration:/opt/__APP__/config.yml" diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index 05eb160..31983a4 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -1,6 +1,6 @@ ## Configuration -You can also configure Vikunja by editing this file `/etc/vikunja/config.yml` using the [documentation](https://vikunja.io/docs/config-options/). +You can also configure Vikunja by editing this file `/opt/vikunja/config.yml` using the [documentation](https://vikunja.io/docs/config-options/). The API is accesible with this path: https://domain.ltd/api/v1/docs \ No newline at end of file diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md index ef0c5cb..df7660e 100644 --- a/doc/DISCLAIMER_fr.md +++ b/doc/DISCLAIMER_fr.md @@ -1,3 +1,3 @@ ## Configuration -Vous pouvez configurer Vikunja en modifiant le fichier `/etc/vikunja/config.yml` en vous aidant de la [documentation](https://vikunja.io/docs/config-options/). \ No newline at end of file +Vous pouvez configurer Vikunja en modifiant le fichier `/opt/vikunja/config.yml` en vous aidant de la [documentation](https://vikunja.io/docs/config-options/). \ No newline at end of file diff --git a/scripts/backup b/scripts/backup index 146898e..dc376db 100644 --- a/scripts/backup +++ b/scripts/backup @@ -39,9 +39,6 @@ ynh_print_info --message="Declaring files to be backed up..." # Frontend ynh_backup --src_path="$final_path" -# Config -ynh_backup --src_path="/etc/$app/config.yml" - # Backend ynh_backup --src_path="/opt/$app" diff --git a/scripts/install b/scripts/install index 0acd0ea..5e9977e 100644 --- a/scripts/install +++ b/scripts/install @@ -131,12 +131,11 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -mkdir -p "/etc/$app" redis_db=$(ynh_redis_get_free_db) -ynh_add_config --template="../conf/config.yml" --destination="/etc/$app/config.yml" +ynh_add_config --template="../conf/config.yml" --destination="/opt/$app/config.yml" -chmod 400 "/etc/$app/config.yml" -chown $app:$app "/etc/$app/config.yml" +chmod 400 "/opt/$app/config.yml" +chown $app:$app "/opt/$app/config.yml" #================================================= # SETUP SYSTEMD diff --git a/scripts/restore b/scripts/restore index 5c14c96..12bc9d8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -65,9 +65,6 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" -# Config -ynh_restore_file --origin_path="/etc/$app/config.yml" - # Backend ynh_restore_file --origin_path="/opt/$app" chmod +x "/opt/$app/vikunja" From ae669c56eb226b30cac6806c4343d70b98488563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 21 Jun 2022 15:40:04 +0200 Subject: [PATCH 2/4] Fix --- conf/systemd.service | 2 +- scripts/backup | 3 ++- scripts/change_url | 5 +++-- scripts/install | 19 +++++++++++-------- scripts/remove | 12 ++++-------- scripts/restore | 7 ++++--- scripts/upgrade | 11 ++++++----- 7 files changed, 31 insertions(+), 28 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index adf2e25..8d1a42d 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,7 +7,7 @@ Requires=postgresql.service redis.service Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=/opt/__APP__ +WorkingDirectory=/opt/__APP__/ ExecStart=/opt/__APP__/vikunja RestartSec=2s Restart=always diff --git a/scripts/backup b/scripts/backup index dc376db..f8b20e9 100644 --- a/scripts/backup +++ b/scripts/backup @@ -24,6 +24,7 @@ ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) +backend_path=$(ynh_app_setting_get --app=$app --key=backend_path) domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) @@ -40,7 +41,7 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$final_path" # Backend -ynh_backup --src_path="/opt/$app" +ynh_backup --src_path="$backend_path" #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 4fefeca..9216339 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,6 +28,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) +backend_path=$(ynh_app_setting_get --app=$app --key=backend_path) port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name @@ -117,9 +118,9 @@ ynh_script_progression --message="Adding a configuration file..." --weight=1 domain="$new_domain" path="$new_path" redis_db=$(ynh_redis_get_free_db) -ynh_add_config --template="../conf/config.yml" --destination="/etc/$app/config.yml" +ynh_add_config --template="../conf/config.yml" --destination="$backend_path/config.yml" -chmod 600 "/etc/$app/config.yml" +chmod 600 "$backend_path/config.yml" #================================================= # GENERIC FINALISATION diff --git a/scripts/install b/scripts/install index 5e9977e..6cce381 100644 --- a/scripts/install +++ b/scripts/install @@ -37,6 +37,7 @@ enable_registration="true" ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/var/www/$app +backend_path=/opt/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Register (book) web path @@ -107,16 +108,18 @@ chown -R $app:www-data "$final_path" #================================================= ynh_script_progression --message="Setting up backend..." --weight=1 +ynh_app_setting_set --app=$app --key=backend_path --value=$backend_path + # Download, check integrity, uncompress and patch the source from app.src -mkdir -p "/opt/$app" -mkdir -p "/opt/$app/files" +mkdir -p "$backend_path" +mkdir -p "$backend_path/files" tempdir="$(mktemp -d)" ynh_setup_source --dest_dir=$tempdir --source_id=$YNH_ARCH back="$(find $tempdir -name "vikunja-*" \! -name "*.sha256")" -cp "$back" "/opt/$app/vikunja" +cp "$back" "$backend_path/vikunja" -chmod +x "/opt/$app/vikunja" -chown -R $app:www-data "/opt/$app/files" +chmod +x "$backend_path/vikunja" +chown -R $app:www-data "$backend_path/files" #================================================= # NGINX CONFIGURATION @@ -132,10 +135,10 @@ ynh_add_nginx_config ynh_script_progression --message="Adding a configuration file..." --weight=1 redis_db=$(ynh_redis_get_free_db) -ynh_add_config --template="../conf/config.yml" --destination="/opt/$app/config.yml" +ynh_add_config --template="../conf/config.yml" --destination="$backend_path/config.yml" -chmod 400 "/opt/$app/config.yml" -chown $app:$app "/opt/$app/config.yml" +chmod 400 "$backend_path/config.yml" +chown $app:$app "$backend_path/config.yml" #================================================= # SETUP SYSTEMD diff --git a/scripts/remove b/scripts/remove index 049da87..4c7d338 100644 --- a/scripts/remove +++ b/scripts/remove @@ -19,6 +19,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +backend_path=$(ynh_app_setting_get --app=$app --key=backend_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name @@ -74,6 +75,9 @@ ynh_script_progression --message="Removing $app main directory..." --weight=6 # Remove the app directory securely ynh_secure_remove --file="$final_path" +# Remove backend +ynh_secure_remove --file="$backend_path" + #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -92,14 +96,6 @@ ynh_script_progression --message="Removing the dedicated system user..." --weigh # Delete a system user ynh_system_user_delete --username=$app -#================================================= -# REMOVE BACKEND -#================================================= -ynh_script_progression --message="Removing backend..." --weight=1 - -# Delete /opt/vikunja -ynh_secure_remove --file="/opt/$app" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 12bc9d8..f1ba73f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -26,6 +26,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +backend_path=$(ynh_app_setting_get --app=$app --key=backend_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) @@ -66,9 +67,9 @@ chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" # Backend -ynh_restore_file --origin_path="/opt/$app" -chmod +x "/opt/$app/vikunja" -chown -R $app:www-data "/opt/$app/files" +ynh_restore_file --origin_path="$backend_path" +chmod +x "$backend_path/vikunja" +chown -R $app:www-data "$backend_path/files" #================================================= # REINSTALL DEPENDENCIES diff --git a/scripts/upgrade b/scripts/upgrade index cde8496..8ff1b15 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,6 +19,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +backend_path=$(ynh_app_setting_get --app=$app --key=backend_path) port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name @@ -103,21 +104,21 @@ then # Download, check integrity, uncompress and patch the source from app.src # Frontend - ynh_setup_source --dest_dir="$final_path" --source_id="front" --keep="/etc/$app/config.yml" + ynh_setup_source --dest_dir="$final_path" --source_id="front" # Backend - mkdir -p "/opt/$app/files" + mkdir -p "$backend_path/files" tempdir="$(mktemp -d)" ynh_setup_source --dest_dir=$tempdir --source_id=$YNH_ARCH back="$(find $tempdir -name "vikunja-*" \! -name "*.sha256")" - cp "$back" "/opt/$app/vikunja" + cp "$back" "$backend_path/vikunja" fi chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" -chmod +x "/opt/$app/vikunja" -chown -R $app:www-data "/opt/$app/files" +chmod +x "$backend_path/vikunja" +chown -R $app:www-data "$backend_path/files" #================================================= # NGINX CONFIGURATION From 0e1e9ca401d85df8dbc688ed9d31a540136ebbc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 21 Jun 2022 15:42:43 +0200 Subject: [PATCH 3/4] Update upgrade --- scripts/upgrade | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 8ff1b15..66df617 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -41,6 +41,12 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +# If backend_path doesn't exist, create it +if [ -z "$backend_path" ]; then + backend_path=/opt/$app + ynh_app_setting_set --app=$app --key=backend_path --value=$backend_path +fi + if [ -z "$set_motd" ]; then set_motd="" ynh_app_setting_set --app=$app --key=set_motd --value=$set_motd From ece9f1b7d58916f4da9bd4d457cd119217550a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 21 Jun 2022 15:43:09 +0200 Subject: [PATCH 4/4] Update upgrade --- scripts/upgrade | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 66df617..a31f1bf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -36,6 +36,20 @@ enable_registration=$(ynh_app_setting_get --app=$app --key=enable_registration) upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up $app before upgrading (may take a while)..." --weight=4 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -69,20 +83,6 @@ if ! ynh_permission_exists --permission="api"; then ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" fi -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up $app before upgrading (may take a while)..." --weight=4 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #=================================================