diff --git a/README.md b/README.md index 6aa255a..682af44 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Vikunja is a self-hosted open-source to-do list application for all platforms. - CalDAV - Links -**Shipped version:** 0.18.2~ynh2 +**Shipped version:** 0.18.2~ynh3 **Demo:** https://try.vikunja.io/login diff --git a/README_fr.md b/README_fr.md index fe6e45c..82c383d 100644 --- a/README_fr.md +++ b/README_fr.md @@ -26,7 +26,7 @@ Vikunja est une application de liste de tâches Open Source auto-hébergée pour - CalDAV - Links -**Version incluse :** 0.18.2~ynh2 +**Version incluse :** 0.18.2~ynh3 **Démo :** https://try.vikunja.io/login 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/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/manifest.json b/manifest.json index b0d1b4c..ad084a5 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Self-hosted To-Do list application", "fr": "Application de liste de tâches auto-hébergée" }, - "version": "0.18.2~ynh2", + "version": "0.18.2~ynh3", "url": "https://vikunja.io/", "upstream": { "license": "GPL-3.0", diff --git a/scripts/backup b/scripts/backup index 146898e..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) @@ -39,11 +40,8 @@ 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" +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 0acd0ea..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 @@ -131,12 +134,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="$backend_path/config.yml" -chmod 400 "/etc/$app/config.yml" -chown $app:$app "/etc/$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 5c14c96..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) @@ -65,13 +66,10 @@ 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" -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..a31f1bf 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 @@ -35,11 +36,31 @@ 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 #================================================= 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 @@ -62,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 #================================================= @@ -103,21 +110,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