From 10848b078adaeeda073d22413b0b5c60d6741b59 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 22 Sep 2022 00:37:16 +0200 Subject: [PATCH] Fix #14 --- scripts/install | 14 ++++++------- scripts/upgrade | 53 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 55 insertions(+), 12 deletions(-) diff --git a/scripts/install b/scripts/install index 4994aee..627c2c6 100755 --- a/scripts/install +++ b/scripts/install @@ -111,7 +111,7 @@ ynh_add_nginx_config #================================================= # PIP INSTALLATION #================================================= -ynh_script_progression --message="Install project via pip..." --weight=80 +ynh_script_progression --message="Installing project via pip..." --weight=80 python3 -m venv "${final_path}/venv" cp ../conf/requirements.txt "$final_path/requirements.txt" @@ -134,13 +134,13 @@ archivebox_cmd="$final_path/venv/bin/archivebox" #================================================= # INSTALL NODE DEPENDENCIES #================================================= -ynh_script_progression --message="Install node dependencies..." +ynh_script_progression --message="Installing node dependencies..." -ynh_use_nodejs cp ../conf/package.json "$final_path/package.json" cp ../conf/package-lock.json "$final_path/package-lock.json" pushd $final_path - ynh_npm ci + ynh_use_nodejs + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm ci popd #================================================= @@ -164,10 +164,8 @@ ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_add_config --template="../conf/ArchiveBox.conf" --destination="$datadir/ArchiveBox.conf" -# permissions -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:www-data "$datadir" +chmod 400 "$datadir/ArchiveBox.conf" +chown $app:$app "$datadir/ArchiveBox.conf" #================================================= # INITIALIZE ARCHIVEBOX diff --git a/scripts/upgrade b/scripts/upgrade index 9ca909f..b59fd6a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -77,6 +77,22 @@ ynh_script_progression --message="Making sure dedicated system user exists..." - # Create a dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= + +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading source files..." --weight=1 + + # Download, check integrity, uncompress and patch the source from app.src + mkdir -p $final_path +fi + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # UPGRADE DEPENDENCIES #================================================= @@ -118,7 +134,40 @@ then # we use this virtualenv archivebox for further commands now archivebox_cmd="$final_path/venv/bin/archivebox" +fi +#================================================= +# UPGRADE NODE DEPENDENCIES +#================================================= + +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading node dependencies..." + + cp -f ../conf/package.json "$final_path/package.json" + cp -f ../conf/package-lock.json "$final_path/package-lock.json" + pushd $final_path + ynh_use_nodejs + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm ci + popd +fi + +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a configuration file..." --weight=1 + +ynh_add_config --template="../conf/ArchiveBox.conf" --destination="$datadir/ArchiveBox.conf" + +chmod 400 "$datadir/ArchiveBox.conf" +chown $app:$app "$datadir/ArchiveBox.conf" + +#================================================= +# FINISH ARCHIVEBOX SETUP +#================================================= + +if [ "$upgrade_type" == "UPGRADE_APP" ] +then # rerun archivebox setup (its idempotent, so it should be ok during upgrade) ynh_script_progression --message="Finishing Archivebox Setup" --weight=1 pushd $datadir @@ -126,10 +175,6 @@ then popd fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - #================================================= # SETUP SYSTEMD #=================================================