From 8ccf8a28b87c089b3f02e09335c469c81e467915 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 23 May 2021 10:38:54 +0200 Subject: [PATCH] Fix --- scripts/install | 18 +++++++++--------- scripts/restore | 29 ++++++++++++----------------- scripts/upgrade | 16 ++++++++-------- 3 files changed, 29 insertions(+), 34 deletions(-) diff --git a/scripts/install b/scripts/install index 000c60d..eead517 100644 --- a/scripts/install +++ b/scripts/install @@ -64,7 +64,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=9 +ynh_script_progression --message="Installing dependencies..." --weight=15 ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies @@ -72,6 +72,14 @@ tempdir="$(mktemp -d)" ynh_setup_source --dest_dir=$tempdir --source_id=crystal ynh_exec_warn_less dpkg -i $tempdir/crystal_0.36.1-1_amd64.deb +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=1 + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # CREATE A POSTGRESQL DATABASE #================================================= @@ -83,14 +91,6 @@ ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_name --db_name=$db_name -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= diff --git a/scripts/restore b/scripts/restore index 314da6d..2d28806 100644 --- a/scripts/restore +++ b/scripts/restore @@ -52,6 +52,14 @@ ynh_script_progression --message="Restoring the NGINX configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -59,20 +67,6 @@ ynh_script_progression --message="Restoring Invidious main directory..." --weigh ynh_restore_file --origin_path="$final_path" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app - -#================================================= -# RESTORE USER RIGHTS -#================================================= -ynh_script_progression --message="Restoring user rights..." - -# Restore permissions on app files chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" @@ -84,12 +78,13 @@ chown -R $app:www-data "$final_path" #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=7 -ynh_exec_warn_less apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61 -ynh_install_extra_repo --repo="deb https://dl.bintray.com/crystal/deb all stable" --append - # Define and install dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +tempdir="$(mktemp -d)" +ynh_setup_source --dest_dir=$tempdir --source_id=crystal +ynh_exec_warn_less dpkg -i $tempdir/crystal_0.36.1-1_amd64.deb + #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 39c6e1e..160e85b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -44,6 +44,14 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -120,14 +128,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated nginx config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # SETUP SYSTEMD #=================================================