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 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/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", 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..3765873 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,9 @@ 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 + +ynh_node_path=$ynh_node #================================================= # CREATE DATA DIRECTORY @@ -158,6 +162,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 @@ -200,13 +211,7 @@ EOF fi ynh_script_progression --message="Finishing Archivebox Setup" --weight=1 -cd $datadir && ynh_exec_as $app $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 +cd $datadir && ynh_exec_as $app $ynh_node_load_PATH $archivebox_cmd init --setup #================================================= # SETUP SYSTEMD 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..57e5923 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 #================================================= @@ -75,6 +81,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 #================================================= @@ -102,7 +120,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" @@ -117,19 +135,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 -#================================================= -# config files for archive box live in $data_dir/ArchiveBox.conf -# and are handled manually outside of YunoHost - #================================================= # SETUP SYSTEMD #=================================================