From ea9414d9523f7ddc9f6156a9f2c73473a7623ccb Mon Sep 17 00:00:00 2001 From: DorianBDev Date: Mon, 14 Feb 2022 17:46:52 +0100 Subject: [PATCH] Fix non-working backend The bug occurred because the downloaded backend's file type was wrong. It was used as a binary file rather a zip file. This commit also adds a clearer separation between backend and frontend in the scripts. --- conf/amd64.src | 3 ++- conf/arm64.src | 3 ++- conf/armhf.src | 3 ++- scripts/backup | 4 ++++ scripts/install | 14 ++++++++------ scripts/remove | 8 ++++++++ scripts/restore | 5 +++++ scripts/upgrade | 10 ++++++++-- 8 files changed, 39 insertions(+), 11 deletions(-) diff --git a/conf/amd64.src b/conf/amd64.src index 8840e83..833f81a 100644 --- a/conf/amd64.src +++ b/conf/amd64.src @@ -2,5 +2,6 @@ SOURCE_URL=https://dl.vikunja.io/api/0.18.1/vikunja-v0.18.1-linux-amd64-full SOURCE_SUM=fd259ae3c717bea715e96d0806ac08f2bd462068277ab2b62ebee36fe946f0e2 SOURCE_SUM_PRG=sha256sum SOURCE_IN_SUBDIR=false +SOURCE_FORMAT=zip SOURCE_FILENAME=vikunja -SOURCE_EXTRACT=false +SOURCE_EXTRACT=true diff --git a/conf/arm64.src b/conf/arm64.src index ffae117..3c1f538 100644 --- a/conf/arm64.src +++ b/conf/arm64.src @@ -2,5 +2,6 @@ SOURCE_URL=https://dl.vikunja.io/api/0.18.1/vikunja-v0.18.1-linux-arm64-full SOURCE_SUM=c54c6d70b348c1697ff8519d522f2b1e3c58ffb4401ac1f4c2e729913b392a27 SOURCE_SUM_PRG=sha256sum SOURCE_IN_SUBDIR=false +SOURCE_FORMAT=zip SOURCE_FILENAME=vikunja -SOURCE_EXTRACT=false +SOURCE_EXTRACT=true diff --git a/conf/armhf.src b/conf/armhf.src index 55c08ee..70c5015 100644 --- a/conf/armhf.src +++ b/conf/armhf.src @@ -2,5 +2,6 @@ SOURCE_URL=https://dl.vikunja.io/api/0.18.1/vikunja-v0.18.1-linux-arm-7-full SOURCE_SUM=79548e506538319f8aab07a5630c3c2032906b34386a83c26d1a6cfc9993b39c SOURCE_SUM_PRG=sha256sum SOURCE_IN_SUBDIR=false +SOURCE_FORMAT=zip SOURCE_FILENAME=vikunja -SOURCE_EXTRACT=false +SOURCE_EXTRACT=true diff --git a/scripts/backup b/scripts/backup index 2eaa6b2..4649990 100644 --- a/scripts/backup +++ b/scripts/backup @@ -36,8 +36,12 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= +# Frontend ynh_backup --src_path="$final_path" +# Backend +ynh_backup --src_path="/opt/vikunja" + #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= diff --git a/scripts/install b/scripts/install index ab2a509..e8651c9 100644 --- a/scripts/install +++ b/scripts/install @@ -91,28 +91,30 @@ ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name #================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE +# INSTALL FRONTEND #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_script_progression --message="Setting up frontend..." --weight=1 ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" --source_id="front" -ynh_setup_source --dest_dir="$final_path/vikunja" --source_id="$architecture" chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" #================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE +# INSTALL BACKEND #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_script_progression --message="Setting up backend..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src mkdir -p "/opt/vikunja" mkdir -p "/opt/vikunja/files" -ynh_setup_source --dest_dir="/opt/vikunja" --source_id="$architecture" +tempdir="$(mktemp -d)" +ynh_setup_source --dest_dir=$tempdir --source_id="$architecture" +back="$(find $tempdir -name "vikunja-*" \! -name "*.sha256")" +cp "$back" "/opt/vikunja/vikunja" chmod +x "/opt/vikunja/vikunja" chown -R $app:www-data "/opt/vikunja/files" diff --git a/scripts/remove b/scripts/remove index 71e049d..9fcba45 100644 --- a/scripts/remove +++ b/scripts/remove @@ -92,6 +92,14 @@ 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 +rm -rf "/opt/vikunja" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 342c673..8be991c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -59,8 +59,13 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= ynh_script_progression --message="Restoring $app main directory..." --weight=4 +# Frontend ynh_restore_file --origin_path="$final_path" +# Backend +ynh_restore_file --origin_path="/opt/vikunja" + +chmod +x "/opt/vikunja/vikunja" chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" diff --git a/scripts/upgrade b/scripts/upgrade index 508fe1c..802fbab 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -102,12 +102,18 @@ then ynh_script_progression --message="Upgrading source files..." --weight=5 # Download, check integrity, uncompress and patch the source from app.src + # Frontend ynh_setup_source --dest_dir="$final_path" --source_id="front" --keep="/etc/vikunja/config.yml" - ynh_setup_source --dest_dir="$final_path" --source_id="$architecture" + + # Backend mkdir -p "/opt/vikunja/files" - + tempdir="$(mktemp -d)" + ynh_setup_source --dest_dir=$tempdir --source_id="$architecture" + back="$(find $tempdir -name "vikunja-*" \! -name "*.sha256")" + cp "$back" "/opt/vikunja/vikunja" fi +chmod +x "/opt/vikunja/vikunja" chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path"