From faf2d9da1361cc342f8641a741ae7f9379f12554 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 3 Dec 2021 21:14:34 +0100 Subject: [PATCH 1/7] Install NodeJS and npm with the core helper --- scripts/_common.sh | 4 +++- scripts/install | 4 +++- scripts/restore | 2 ++ scripts/upgrade | 19 ++++++++++++------- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 2419486..4dc40f7 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,12 +5,14 @@ #================================================= # dependencies used by the app -pkg_dependencies="python3-venv expect nodejs npm \ +pkg_dependencies="python3-venv expect \ apt-transport-https ca-certificates gnupg2 zlib1g-dev dumb-init gosu cron unzip curl \ fontconfig fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-symbola fonts-noto fonts-freefont-ttf \ wget curl chromium git ffmpeg youtube-dl ripgrep \ build-essential python-dev python3-dev" +nodejs_version=14 + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index b66bb57..da4d7b5 100755 --- a/scripts/install +++ b/scripts/install @@ -77,6 +77,8 @@ ynh_script_progression --message="Installing dependencies..." --weight=8 ynh_install_app_dependencies $pkg_dependencies +ynh_install_nodejs --nodejs_version=$nodejs_version + #================================================= # CREATE DEDICATED USER #================================================= @@ -137,7 +139,7 @@ archivebox_cmd="$final_path/venv/bin/archivebox" #================================================= cp ../conf/package.json "$final_path/package.json" cp ../conf/package-lock.json "$final_path/package-lock.json" -cd $final_path; npm ci +cd $final_path; ynh_npm ci #================================================= # CREATE DATA DIRECTORY diff --git a/scripts/restore b/scripts/restore index fe475e1..07ee68c 100755 --- a/scripts/restore +++ b/scripts/restore @@ -92,6 +92,8 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=1 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies +ynh_install_nodejs --nodejs_version=$nodejs_version + #================================================= # RESTORE SYSTEMD #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 1a28962..b7ae57a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -75,6 +75,18 @@ 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" +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=1 + +ynh_install_app_dependencies $pkg_dependencies + +if [ $nodejs_version != $(ynh_app_setting_get --app=$app --key=nodejs_version) ]; then + ynh_remove_nodejs + ynh_install_nodejs --nodejs_version=$nodejs_version +fi + #================================================= # UPGRADE VIA PIP #================================================= @@ -117,13 +129,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=1 - -ynh_install_app_dependencies $pkg_dependencies - #================================================= # UPDATE A CONFIG FILE #================================================= From 4442a06abb0972ccffc9acf5292752f8d6cb3e43 Mon Sep 17 00:00:00 2001 From: notplants Date: Sat, 4 Dec 2021 16:22:06 +0100 Subject: [PATCH 2/7] Specify node binary for ArchiveBox.conf --- conf/ArchiveBox.conf | 2 ++ scripts/install | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 conf/ArchiveBox.conf diff --git a/conf/ArchiveBox.conf b/conf/ArchiveBox.conf new file mode 100644 index 0000000..18d8522 --- /dev/null +++ b/conf/ArchiveBox.conf @@ -0,0 +1,2 @@ +[DEPENDENCY_CONFIG] +NODE_BINARY=__YNH_NODE__ \ No newline at end of file diff --git a/scripts/install b/scripts/install index da4d7b5..95a6d1d 100755 --- a/scripts/install +++ b/scripts/install @@ -141,6 +141,9 @@ cp ../conf/package.json "$final_path/package.json" cp ../conf/package-lock.json "$final_path/package-lock.json" cd $final_path; ynh_npm ci +ynh_node_path=$ynh_node +ynh_script_progression --message="ynh_node_path: $ynh_node_path" --weight=1 + #================================================= # CREATE DATA DIRECTORY #================================================= @@ -160,6 +163,13 @@ chown -R $app:www-data "$datadir" # CREATE ARCHIVEBOX CONFIG #================================================= +# copy configuration file +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" #================================================= # INITIALIZE ARCHIVEBOX From 0fc1499a6fcbd7f9d780051df56a7ea372f94755 Mon Sep 17 00:00:00 2001 From: notplants Date: Sat, 4 Dec 2021 16:38:19 +0100 Subject: [PATCH 3/7] Useynh_node_load_PATH --- scripts/install | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 95a6d1d..c91501a 100755 --- a/scripts/install +++ b/scripts/install @@ -143,6 +143,7 @@ cd $final_path; ynh_npm ci ynh_node_path=$ynh_node ynh_script_progression --message="ynh_node_path: $ynh_node_path" --weight=1 +ynh_script_progression --message="ynh_node_load_PATH: $ynh_node_load_PATH" --weight=1 #================================================= # CREATE DATA DIRECTORY @@ -212,7 +213,7 @@ EOF fi ynh_script_progression --message="Finishing Archivebox Setup" --weight=1 -cd $datadir && ynh_exec_as $app $archivebox_cmd init --setup +cd $datadir && ynh_exec_as $app $ynh_node_load_PATH $archivebox_cmd init --setup #================================================= # ADD A CONFIGURATION From 5b53519e8d183e20e577864acf9af1a3317deb95 Mon Sep 17 00:00:00 2001 From: notplants Date: Sun, 5 Dec 2021 16:20:38 +0100 Subject: [PATCH 4/7] Fix upgrade script --- scripts/install | 6 ------ scripts/upgrade | 17 ++++++++++------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/scripts/install b/scripts/install index c91501a..53e907f 100755 --- a/scripts/install +++ b/scripts/install @@ -215,12 +215,6 @@ fi ynh_script_progression --message="Finishing Archivebox Setup" --weight=1 cd $datadir && ynh_exec_as $app $ynh_node_load_PATH $archivebox_cmd init --setup -#================================================= -# ADD A CONFIGURATION -#================================================= -# config files for archive box live in $data_dir/ArchiveBox.conf -# and are handled manually outside of YunoHost - #================================================= # SETUP SYSTEMD #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b7ae57a..457288e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -26,6 +26,12 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) language=$(ynh_app_setting_get --app=$app --key=language) port=$(ynh_app_setting_get --app=$app --key=port) + +#================================================= +# SET CORRECT NODE VERSION +#================================================= +ynh_use_nodejs --nodejs_version=$nodejs_version + #================================================= # CHECK VERSION #================================================= @@ -93,6 +99,9 @@ fi datadir=/home/yunohost.app/$app +# debug message +ynh_script_progression --message="ynh_node_load_PATH: $ynh_node_load_PATH" --weight=1 + if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading via pip" --weight=1 @@ -114,7 +123,7 @@ then # rerun archivebox setup (its idempotent, so it should be ok during upgrade) ynh_script_progression --message="Finishing Archivebox Setup" --weight=1 - cd $datadir && ynh_exec_as $app $archivebox_cmd init --setup + cd $datadir && ynh_exec_as $app $ynh_node_load_PATH $archivebox_cmd init --setup fi chmod 750 "$final_path" @@ -129,12 +138,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# UPDATE A CONFIG FILE -#================================================= -# config files for archive box live in $data_dir/ArchiveBox.conf -# and are handled manually outside of YunoHost - #================================================= # SETUP SYSTEMD #================================================= From e8a53347061d10525f9222be2f7870472a298cd3 Mon Sep 17 00:00:00 2001 From: notplants Date: Sun, 5 Dec 2021 20:20:13 +0100 Subject: [PATCH 5/7] Bump version number to ynh9 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index a94dfcb..fd9584e 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Archiving solution to collect, save, and view sites you want to preserve offline", "fr": "Solution d'archivage pour collecter, enregistrer et afficher les sites que vous souhaitez conserver hors ligne" }, - "version": "0.6.2~ynh8", + "version": "0.6.2~ynh9", "url": "https://archivebox.io/", "upstream": { "license": "MIT", From 018e5e14817e9c31407e45284123570b91b1fdb3 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sun, 5 Dec 2021 19:21:03 +0000 Subject: [PATCH 6/7] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 31ae4b0..9f48c03 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Archiving solution to collect, save, and view sites you want to preserve offline -**Shipped version:** 0.6.2~ynh8 +**Shipped version:** 0.6.2~ynh9 **Demo:** https://archiveboxdemo.commoninternet.net diff --git a/README_fr.md b/README_fr.md index c405dc7..30e4d17 100644 --- a/README_fr.md +++ b/README_fr.md @@ -13,7 +13,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Solution d'archivage pour collecter, enregistrer et afficher les sites que vous souhaitez conserver hors ligne -**Version incluse :** 0.6.2~ynh8 +**Version incluse :** 0.6.2~ynh9 **Démo :** https://archiveboxdemo.commoninternet.net From 7a8852a4805c07f3b4cb9686c61dac6f53916cb3 Mon Sep 17 00:00:00 2001 From: notplants Date: Sun, 5 Dec 2021 20:21:45 +0100 Subject: [PATCH 7/7] Remove debug messages --- scripts/install | 2 -- scripts/upgrade | 3 --- 2 files changed, 5 deletions(-) diff --git a/scripts/install b/scripts/install index 53e907f..3765873 100755 --- a/scripts/install +++ b/scripts/install @@ -142,8 +142,6 @@ cp ../conf/package-lock.json "$final_path/package-lock.json" cd $final_path; ynh_npm ci ynh_node_path=$ynh_node -ynh_script_progression --message="ynh_node_path: $ynh_node_path" --weight=1 -ynh_script_progression --message="ynh_node_load_PATH: $ynh_node_load_PATH" --weight=1 #================================================= # CREATE DATA DIRECTORY diff --git a/scripts/upgrade b/scripts/upgrade index 457288e..57e5923 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -99,9 +99,6 @@ fi datadir=/home/yunohost.app/$app -# debug message -ynh_script_progression --message="ynh_node_load_PATH: $ynh_node_load_PATH" --weight=1 - if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading via pip" --weight=1