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