From fb601f925daccb077f73e264a7632f974f676976 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 20 Mar 2020 21:09:24 +0100 Subject: [PATCH 01/23] [fix/enh] manifest Addresses #1 regarding "services" key. Fixed typo. Added reminder about ZeroTier app. Added help text regarding publicness. --- manifest.json | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 55c5a54..cd3a873 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "packaging_format": 1, "description": { "en": "ZeroTier network controller user interface", - "fr": "Interface utilisateur pour le contrôler de réseau ZeroTier" + "fr": "Interface utilisateur pour le contrôleur de réseau ZeroTier" }, "version": "0.5.8~ynh1", "url": "https://key-networks.com/ztncui", @@ -17,9 +17,6 @@ "yunohost": ">= 3.5" }, "multi_instance": false, - "services": [ - "zerotier-one" - ], "arguments": { "install" : [ { @@ -29,6 +26,10 @@ "en": "Choose a domain name for ztncui", "fr": "Choisissez un nom de domaine pour ztncui" }, + "help": { + "en": "REMINDER: ztncui needs the ZeroTier app to be already installed.", + "fr": "RAPPEL: ztncui nécessite que l'app ZeroTier soit déjà installée." + }, "example": "example.com" }, { @@ -38,6 +39,10 @@ "en": "Is it a public application?", "fr": "Est-ce une application publique ?" }, + "help": { + "en": "It does not really matter, since ztncui has its own login system.", + "fr": "Cela n'a pas trop d'importance, puisque ztncui a son propre système de connection." + }, "default": false } ] From 0a008ec37293bc5a0c90e3a577c9d0dc18d230e2 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 20 Mar 2020 21:16:20 +0100 Subject: [PATCH 02/23] [enh] test for ZeroTier installation --- scripts/install | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/install b/scripts/install index eabc49f..8788a4b 100644 --- a/scripts/install +++ b/scripts/install @@ -53,6 +53,9 @@ app=$YNH_APP_INSTANCE_NAME ### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call. ynh_script_progression --message="Validating installation parameters..." --time --weight=1 +# Testing if ZeroTier is installed +type zerotier > /dev/null || echo "ZeroTier is needed, but it is not installed. There is a package for that!" + ### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". ### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app" final_path=/opt/key-networks/ztncui From b4fe63f9a756add8f75b0addd1ec2ee36ab1ff27 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 20 Mar 2020 21:16:35 +0100 Subject: [PATCH 03/23] [upg] nodejs to v12 --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index d5160da..ac79128 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,7 +4,7 @@ # COMMON VARIABLES #================================================= -nodejs_version=10 +nodejs_version=12 #================================================= # PERSONAL HELPERS From 234fe49cc5327e962bfddbef3332ead2aa80d7e7 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 20 Mar 2020 22:51:45 +0100 Subject: [PATCH 04/23] [fix] overhaul See #2. Getting rid of start script. cp instead of ln the "fake" ssl certificates. --- conf/start.sh | 5 ----- conf/systemd.service | 6 +++--- scripts/install | 13 +++++++------ 3 files changed, 10 insertions(+), 14 deletions(-) delete mode 100644 conf/start.sh diff --git a/conf/start.sh b/conf/start.sh deleted file mode 100644 index 43f8d7f..0000000 --- a/conf/start.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -pushd __FINALPATH__/src/ - npm start -popd diff --git a/conf/systemd.service b/conf/systemd.service index d2f3180..4072a8b 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -4,11 +4,11 @@ After=network.target [Service] Type=simple -User=root -Group=root +User=ztncui +Group=ztncui Environment="PATH=__ENV_PATH__" WorkingDirectory=__FINALPATH__/src/ -ExecStart=/bin/bash __FINALPATH__/src/start.sh >> /var/log/__APP__/__APP__.log 2>&1 +ExecStart=__NODEJS_PATH__/npm start [Install] WantedBy=multi-user.target diff --git a/scripts/install b/scripts/install index 8788a4b..3fd84dc 100644 --- a/scripts/install +++ b/scripts/install @@ -161,14 +161,11 @@ popd mkdir -p $final_path env_file=$final_path/src/.env touch $env_file +chmod 600 $env_file echo "ZT_TOKEN=$(> $env_file echo "HTTP_PORT=$port" >> $env_file -cp ../conf/start.sh $final_path/src/ -ynh_replace_string "__APP__" "$app" "$final_path/src/start.sh" -ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/src/start.sh" - cp $final_path/src/etc/default.passwd $final_path/src/etc/passwd #================================================= @@ -178,8 +175,8 @@ cp $final_path/src/etc/default.passwd $final_path/src/etc/passwd # Even though one can stay in HTTP mode, the ztncui requires SSL certificates # let's use the ones of the domain pushd $final_path/src/etc/tls - ln -s /etc/yunohost/certs/$domain/key.pem privkey.pem - ln -s /etc/yunohost/certs/$domain/crt.pem fullchain.pem + cp /etc/yunohost/certs/$domain/key.pem privkey.pem + cp /etc/yunohost/certs/$domain/crt.pem fullchain.pem popd #================================================= @@ -201,6 +198,9 @@ ynh_script_progression --message="Configuring a systemd service..." --time --wei # Create a dedicated systemd config ynh_add_systemd_config ynh_replace_string "__ENV_PATH__" "$PATH" "/etc/systemd/system/$app.service" +ynh_replace_string "__NODEJS_PATH__" "/opt/node_n/n/versions/node/$nodejs_version/bin/" "/etc/systemd/system/$app.service" +ynh_replace_string "__FINALPATH__" "$final_path" "/etc/systemd/system/$app.service" + systemctl daemon-reload #================================================= @@ -294,3 +294,4 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= ynh_script_progression --message="Installation of $app completed" --time --last +ynh_print_warn --message="Installation of $app completed. Default credentials: admin/password" From c01b1ebd3d3e7b2c35de2b703e9d77646bb64e91 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 21 Mar 2020 00:11:35 +0100 Subject: [PATCH 05/23] [fix] retrieve actual zerotier port --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index 3fd84dc..0ffc6a7 100644 --- a/scripts/install +++ b/scripts/install @@ -164,6 +164,7 @@ touch $env_file chmod 600 $env_file echo "ZT_TOKEN=$(> $env_file +echo "ZT_ADDR=localhost:$(> $env_file echo "HTTP_PORT=$port" >> $env_file cp $final_path/src/etc/default.passwd $final_path/src/etc/passwd From a4da9a51265a08710bbc5fd99c502ce741e6b78e Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 16 Apr 2020 16:01:37 +0200 Subject: [PATCH 06/23] [enh] install zerotier during package check --- check_process | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/check_process b/check_process index dd1c025..2b13920 100644 --- a/check_process +++ b/check_process @@ -5,28 +5,31 @@ ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - path="/" (PATH) - admin="john" (USER) - language="fr" - is_public=1 (PUBLIC|public=1|private=0) - password="pass" - port="666" (PORT) + domain="domain.tld" (DOMAIN) + path="/" (PATH) + admin="john" (USER) + language="fr" + is_public=1 (PUBLIC|public=1|private=0) + password="pass" + port="666" (PORT) + ; pre-install + sudo yunohost app fetchlist + sudo yunohost app install zerotier ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - upgrade=1 from_commit=CommitHash - backup_restore=1 - multi_instance=1 - # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. - # incorrect_path=1 - port_already_use=0 - change_url=1 + pkg_linter=1 + setup_sub_dir=0 + setup_root=1 + setup_nourl=0 + setup_private=1 + setup_public=1 + upgrade=1 + upgrade=1 from_commit=CommitHash + backup_restore=1 + multi_instance=1 + # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. + # incorrect_path=1 + port_already_use=0 + change_url=1 ;;; Levels # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto @@ -37,4 +40,3 @@ Notification=none ; commit=CommitHash name=Name and date of the commit. manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& - From 62713698e37e08fb3e112008907c30f61af1b792 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 16 Apr 2020 16:02:22 +0200 Subject: [PATCH 07/23] [fix] manifest fix license and readd empty services array --- manifest.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index cd3a873..5edbb51 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ }, "version": "0.5.8~ynh1", "url": "https://key-networks.com/ztncui", - "license": "gpl", + "license": "GPL-3.0-only", "maintainer": { "name": "tituspijean", "email": "tituspijean@outlook.com" @@ -16,6 +16,7 @@ "requirements": { "yunohost": ">= 3.5" }, + "services": [], "multi_instance": false, "arguments": { "install" : [ From 82f0224d690825720167ded2331eb4699c2d5a5b Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 16 Apr 2020 16:08:39 +0200 Subject: [PATCH 08/23] [add] g++ dependency --- scripts/_common.sh | 3 +++ scripts/install | 6 +++++- scripts/remove | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index ac79128..38aa8ed 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,6 +6,9 @@ nodejs_version=12 +# dependencies used by the app +pkg_dependencies="g++" + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 0ffc6a7..d110514 100644 --- a/scripts/install +++ b/scripts/install @@ -58,7 +58,7 @@ type zerotier > /dev/null || echo "ZeroTier is needed, but it is not installed. ### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". ### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app" -final_path=/opt/key-networks/ztncui +final_path=/opt/yunohost/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Register (book) web path @@ -108,6 +108,8 @@ ynh_script_progression --message="Installing dependencies..." --time --weight=1 ### - As well as the section "REINSTALL DEPENDENCIES" in the restore script ### - And the section "UPGRADE DEPENDENCIES" in the upgrade script +ynh_install_app_dependencies $pkg_dependencies + ynh_install_nodejs --nodejs_version=$nodejs_version ynh_use_nodejs @@ -150,7 +152,9 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Performing Node app installation..." --time --weight=1 pushd $final_path/src + npm install -g node-gyp npm install + npm audit fix popd #================================================= diff --git a/scripts/remove b/scripts/remove index b201fd3..c057776 100644 --- a/scripts/remove +++ b/scripts/remove @@ -38,6 +38,8 @@ fi #================================================= ynh_script_progression --message="Removing dependencies..." --time --weight=1 +# Remove metapackage and its dependencies +ynh_remove_app_dependencies ynh_remove_nodejs #================================================= From 9eec37e2150200a9a28a980144fe380da0fa6d40 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 17 Apr 2020 15:08:02 +0200 Subject: [PATCH 09/23] [add] debug --- scripts/install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index d110514..a8a9c33 100644 --- a/scripts/install +++ b/scripts/install @@ -152,9 +152,9 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Performing Node app installation..." --time --weight=1 pushd $final_path/src - npm install -g node-gyp - npm install - npm audit fix + ynh_debug_exec npm install node-gyp + ynh_debug_exec npm install + ynh_debug_exec npm audit fix popd #================================================= From c874edf301adc7d15568a012db3672dc19a8ea33 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 17 Apr 2020 15:26:42 +0200 Subject: [PATCH 10/23] [fix] use specified nodejs version --- scripts/install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index a8a9c33..25da065 100644 --- a/scripts/install +++ b/scripts/install @@ -152,9 +152,9 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Performing Node app installation..." --time --weight=1 pushd $final_path/src - ynh_debug_exec npm install node-gyp - ynh_debug_exec npm install - ynh_debug_exec npm audit fix + ynh_debug_exec $nodejs_path/npm install node-gyp + ynh_debug_exec $nodejs_path/npm install + ynh_debug_exec $nodejs_path/npm audit fix popd #================================================= From 430f3d900071e5f73d4ad41ac1cfeb3ca63df1ae Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 17 Apr 2020 20:16:53 +0200 Subject: [PATCH 11/23] [enh] to level 6 --- check_process | 4 ++-- scripts/_common.sh | 15 +++++++++++++++ scripts/install | 16 +++++++++------- scripts/remove | 8 ++++++++ scripts/upgrade | 48 ++++++++++++++++++++++++++++++++++++++++++---- 5 files changed, 78 insertions(+), 13 deletions(-) diff --git a/check_process b/check_process index 2b13920..89023cf 100644 --- a/check_process +++ b/check_process @@ -23,9 +23,9 @@ setup_private=1 setup_public=1 upgrade=1 - upgrade=1 from_commit=CommitHash + ;upgrade=1 from_commit=CommitHash backup_restore=1 - multi_instance=1 + multi_instance=0 # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. # incorrect_path=1 port_already_use=0 diff --git a/scripts/_common.sh b/scripts/_common.sh index 38aa8ed..f55d066 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -17,6 +17,21 @@ pkg_dependencies="g++" # EXPERIMENTAL HELPERS #================================================= +#!/bin/bash + +# Execute a command as another user +# usage: exec_as USER COMMAND [ARG ...] +exec_as() { + local USER=$1 + shift 1 + + if [[ $USER = $(whoami) ]]; then + eval "$@" + else + sudo PATH=$PATH -u "$USER" "$@" + fi +} + #================================================= # FUTURE OFFICIAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 25da065..01599c3 100644 --- a/scripts/install +++ b/scripts/install @@ -142,7 +142,7 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring system user..." --time --weight=1 # Create a system user -ynh_system_user_create --username=$app +ynh_system_user_create $app $final_path #================================================= # SPECIFIC SETUP @@ -151,10 +151,12 @@ ynh_system_user_create --username=$app #================================================= ynh_script_progression --message="Performing Node app installation..." --time --weight=1 +chown -R $app: $final_path + pushd $final_path/src - ynh_debug_exec $nodejs_path/npm install node-gyp - ynh_debug_exec $nodejs_path/npm install - ynh_debug_exec $nodejs_path/npm audit fix + exec_as $app $nodejs_path/npm install node-gyp + exec_as $app $nodejs_path/npm install + exec_as $app $nodejs_path/npm audit fix popd #================================================= @@ -202,9 +204,9 @@ ynh_script_progression --message="Configuring a systemd service..." --time --wei # Create a dedicated systemd config ynh_add_systemd_config -ynh_replace_string "__ENV_PATH__" "$PATH" "/etc/systemd/system/$app.service" -ynh_replace_string "__NODEJS_PATH__" "/opt/node_n/n/versions/node/$nodejs_version/bin/" "/etc/systemd/system/$app.service" -ynh_replace_string "__FINALPATH__" "$final_path" "/etc/systemd/system/$app.service" +ynh_replace_string "__ENV_PATH__" "$PATH" "$finalsystemdconf" +ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "$finalsystemdconf" +ynh_replace_string "__FINALPATH__" "$final_path" "$finalsystemdconf" systemctl daemon-reload diff --git a/scripts/remove b/scripts/remove index c057776..9cf7ddf 100644 --- a/scripts/remove +++ b/scripts/remove @@ -33,6 +33,14 @@ then yunohost service remove $app fi +#================================================= +# STOP AND REMOVE SERVICE +#================================================= +ynh_script_progression --message="Stopping and removing the systemd service..." --time --weight=1 + +# Remove the dedicated systemd config +ynh_remove_systemd_config + #================================================= # REMOVE DEPENDENCIES #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 1957c55..c9b9c15 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,6 +20,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # CHECK VERSION @@ -119,7 +120,10 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 -#ynh_install_app_dependencies $pkg_dependencies +ynh_install_app_dependencies $pkg_dependencies + +ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_use_nodejs #================================================= # CREATE DEDICATED USER @@ -127,7 +131,7 @@ ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app +ynh_system_user_create $app $final_path #================================================= # SPECIFIC UPGRADE @@ -136,8 +140,39 @@ ynh_system_user_create --username=$app #================================================= ynh_script_progression --message="Performing Node app installation..." --time --weight=1 +chown -R $app: $final_path + pushd $final_path/src - npm install + exec_as $app $nodejs_path/npm install node-gyp + exec_as $app $nodejs_path/npm install + exec_as $app $nodejs_path/npm audit fix +popd + +#================================================= +# MODIFY A CONFIG FILE +#================================================= + +# Setup env file +mkdir -p $final_path +env_file=$final_path/src/.env +touch $env_file +chmod 600 $env_file + +echo "ZT_TOKEN=$(> $env_file +echo "ZT_ADDR=localhost:$(> $env_file +echo "HTTP_PORT=$port" >> $env_file + +cp $final_path/src/etc/default.passwd $final_path/src/etc/passwd + +#================================================= +# LINK CERTIFICATES +#================================================= + +# Even though one can stay in HTTP mode, the ztncui requires SSL certificates +# let's use the ones of the domain +pushd $final_path/src/etc/tls + cp /etc/yunohost/certs/$domain/key.pem privkey.pem + cp /etc/yunohost/certs/$domain/crt.pem fullchain.pem popd #================================================= @@ -155,6 +190,11 @@ ynh_script_progression --message="Upgrading systemd configuration..." --time --w # Create a dedicated systemd config ynh_add_systemd_config +ynh_replace_string "__ENV_PATH__" "$PATH" "$finalsystemdconf" +ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "$finalsystemdconf" +ynh_replace_string "__FINALPATH__" "$final_path" "$finalsystemdconf" + +systemctl daemon-reload #================================================= # GENERIC FINALIZATION @@ -163,7 +203,7 @@ ynh_add_systemd_config #================================================= # Set permissions on app files -chown -R root: $final_path +chown -R $app: $final_path #================================================= # SETUP SSOWAT From d5f354b63d1cfb6a54a0518256ead73ea345da40 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 17 Apr 2020 20:19:17 +0200 Subject: [PATCH 12/23] [rem] change_url --- check_process | 2 +- scripts/change_url | 134 --------------------------------------------- 2 files changed, 1 insertion(+), 135 deletions(-) delete mode 100644 scripts/change_url diff --git a/check_process b/check_process index 89023cf..f881f7d 100644 --- a/check_process +++ b/check_process @@ -29,7 +29,7 @@ # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. # incorrect_path=1 port_already_use=0 - change_url=1 + change_url=0 ;;; Levels # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto diff --git a/scripts/change_url b/scripts/change_url deleted file mode 100644 index 3f21bc8..0000000 --- a/scripts/change_url +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -source _common.sh -source /usr/share/yunohost/helpers - -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH - -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 - -# Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -# Add settings here as needed by your application -#db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#db_user=$db_name -#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. - ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -change_domain=0 -if [ "$old_domain" != "$new_domain" ] -then - change_domain=1 -fi - -change_path=0 -if [ "$old_path" != "$new_path" ] -then - change_path=1 -fi - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 - -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" - -#================================================= -# MODIFY URL IN NGINX CONF -#================================================= -ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1 - -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -# Change the path in the nginx config file -if [ $change_path -eq 1 ] -then - # Make a backup of the original nginx config file if modified - ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for nginx helper - domain="$old_domain" - path_url="$new_path" - # Create a dedicated nginx config - ynh_add_nginx_config -fi - -# Change the domain for nginx -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location - ynh_delete_file_checksum --file="$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi - -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= - -#================================================= -# GENERIC FINALISATION -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 - -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload - -#================================================= -# END OF SCRIPT -#================================================= - -ynh_script_progression --message="Change of URL completed for $app" --time --last From 38cb8a218bb62ea7a8b83452d74e2f52cc3fe678 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 18 Apr 2020 10:30:09 +0200 Subject: [PATCH 13/23] [enh] silence npm warnings --- scripts/install | 6 +++--- scripts/upgrade | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index 01599c3..c27a502 100644 --- a/scripts/install +++ b/scripts/install @@ -154,9 +154,9 @@ ynh_script_progression --message="Performing Node app installation..." --time -- chown -R $app: $final_path pushd $final_path/src - exec_as $app $nodejs_path/npm install node-gyp - exec_as $app $nodejs_path/npm install - exec_as $app $nodejs_path/npm audit fix + exec_as $app $nodejs_path/npm --loglevel=error install node-gyp + exec_as $app $nodejs_path/npm --loglevel=error install + exec_as $app $nodejs_path/npm --loglevel=error audit fix popd #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index c9b9c15..1d0cff3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -143,9 +143,9 @@ ynh_script_progression --message="Performing Node app installation..." --time -- chown -R $app: $final_path pushd $final_path/src - exec_as $app $nodejs_path/npm install node-gyp - exec_as $app $nodejs_path/npm install - exec_as $app $nodejs_path/npm audit fix + exec_as $app $nodejs_path/npm --loglevel=error install node-gyp + exec_as $app $nodejs_path/npm --loglevel=error install + exec_as $app $nodejs_path/npm --loglevel=error audit fix popd #================================================= From 6be758ab42cadb32f826dbc802f7e48958b8c6f0 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 18 Apr 2020 12:08:41 +0200 Subject: [PATCH 14/23] [add] change_url --- check_process | 2 +- scripts/change_url | 134 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 scripts/change_url diff --git a/check_process b/check_process index f881f7d..89023cf 100644 --- a/check_process +++ b/check_process @@ -29,7 +29,7 @@ # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. # incorrect_path=1 port_already_use=0 - change_url=0 + change_url=1 ;;; Levels # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..3f21bc8 --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,134 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +old_domain=$YNH_APP_OLD_DOMAIN +old_path=$YNH_APP_OLD_PATH + +new_domain=$YNH_APP_NEW_DOMAIN +new_path=$YNH_APP_NEW_PATH + +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +# Add settings here as needed by your application +#db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#db_user=$db_name +#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# CHECK WHICH PARTS SHOULD BE CHANGED +#================================================= + +change_domain=0 +if [ "$old_domain" != "$new_domain" ] +then + change_domain=1 +fi + +change_path=0 +if [ "$old_path" != "$new_path" ] +then + change_path=1 +fi + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1 + +nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf + +# Change the path in the nginx config file +if [ $change_path -eq 1 ] +then + # Make a backup of the original nginx config file if modified + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" + # Set global variables for nginx helper + domain="$old_domain" + path_url="$new_path" + # Create a dedicated nginx config + ynh_add_nginx_config +fi + +# Change the domain for nginx +if [ $change_domain -eq 1 ] +then + # Delete file checksum for the old conf file location + ynh_delete_file_checksum --file="$nginx_conf_path" + mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf + # Store file checksum for the new config file location + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +fi + +#================================================= +# SPECIFIC MODIFICATIONS +#================================================= +# ... +#================================================= + +#================================================= +# GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --time --last From 04bdc45749015635718a489c734ef88507463265 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 18 Apr 2020 12:08:56 +0200 Subject: [PATCH 15/23] [enh] recalculate checksum --- scripts/install | 1 + scripts/upgrade | 1 + 2 files changed, 2 insertions(+) diff --git a/scripts/install b/scripts/install index c27a502..2fd526e 100644 --- a/scripts/install +++ b/scripts/install @@ -207,6 +207,7 @@ ynh_add_systemd_config ynh_replace_string "__ENV_PATH__" "$PATH" "$finalsystemdconf" ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "$finalsystemdconf" ynh_replace_string "__FINALPATH__" "$final_path" "$finalsystemdconf" +ynh_store_file_checksum --file="$finalsystemdconf" systemctl daemon-reload diff --git a/scripts/upgrade b/scripts/upgrade index 1d0cff3..84c1073 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -193,6 +193,7 @@ ynh_add_systemd_config ynh_replace_string "__ENV_PATH__" "$PATH" "$finalsystemdconf" ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "$finalsystemdconf" ynh_replace_string "__FINALPATH__" "$final_path" "$finalsystemdconf" +ynh_store_file_checksum --file="$finalsystemdconf" systemctl daemon-reload From 772480a9af425818e103fbffbd9d4f6dcc3a3cf3 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 18 Apr 2020 12:42:51 +0200 Subject: [PATCH 16/23] [enh] prepare systemd conf and check for zerotier app or die Co-Authored-By: Kayou --- conf/systemd.service | 4 ++-- scripts/install | 13 ++++++------- scripts/upgrade | 11 +++++------ 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index 4072a8b..b5a4e27 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,8 +6,8 @@ After=network.target Type=simple User=ztncui Group=ztncui -Environment="PATH=__ENV_PATH__" -WorkingDirectory=__FINALPATH__/src/ +Environment="PATH=__PATH__" +WorkingDirectory=__FINAL_PATH__/src/ ExecStart=__NODEJS_PATH__/npm start [Install] diff --git a/scripts/install b/scripts/install index 2fd526e..1ff3e5c 100644 --- a/scripts/install +++ b/scripts/install @@ -54,7 +54,7 @@ app=$YNH_APP_INSTANCE_NAME ynh_script_progression --message="Validating installation parameters..." --time --weight=1 # Testing if ZeroTier is installed -type zerotier > /dev/null || echo "ZeroTier is needed, but it is not installed. There is a package for that!" +yunohost app list | grep "id: zerotier" || ynh_die "ZeroTier is needed, but it is not installed. There is a package for that!" ### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". ### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app" @@ -202,14 +202,13 @@ ynh_script_progression --message="Configuring a systemd service..." --time --wei ### - As well as the section "RESTORE SYSTEMD" in the restore script ### - And the section "SETUP SYSTEMD" in the upgrade script +# Set the systemd service settings +ynh_replace_string "__PATH__" "$PATH" "../conf/systemd.service" +ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "../conf/systemd.service" +ynh_replace_string "__FINAL_PATH__" "$final_path" "../conf/systemd.service" + # Create a dedicated systemd config ynh_add_systemd_config -ynh_replace_string "__ENV_PATH__" "$PATH" "$finalsystemdconf" -ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "$finalsystemdconf" -ynh_replace_string "__FINALPATH__" "$final_path" "$finalsystemdconf" -ynh_store_file_checksum --file="$finalsystemdconf" - -systemctl daemon-reload #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 84c1073..790ef32 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -188,14 +188,13 @@ ynh_use_logrotate --non-append #================================================= ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1 +# Set the systemd service settings +ynh_replace_string "__PATH__" "$PATH" "../conf/systemd.service" +ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "../conf/systemd.service" +ynh_replace_string "__FINAL_PATH__" "$final_path" "../conf/systemd.service" + # Create a dedicated systemd config ynh_add_systemd_config -ynh_replace_string "__ENV_PATH__" "$PATH" "$finalsystemdconf" -ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "$finalsystemdconf" -ynh_replace_string "__FINALPATH__" "$final_path" "$finalsystemdconf" -ynh_store_file_checksum --file="$finalsystemdconf" - -systemctl daemon-reload #================================================= # GENERIC FINALIZATION From 600ccede11dcc58c5dbb189567d02462f44cd88d Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 18 Apr 2020 13:26:22 +0200 Subject: [PATCH 17/23] [enh] use permissions system --- manifest.json | 4 ++-- scripts/install | 5 ++--- scripts/upgrade | 9 --------- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/manifest.json b/manifest.json index 5edbb51..685567c 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "tituspijean@outlook.com" }, "requirements": { - "yunohost": ">= 3.5" + "yunohost": ">= 3.7" }, "services": [], "multi_instance": false, @@ -31,7 +31,7 @@ "en": "REMINDER: ztncui needs the ZeroTier app to be already installed.", "fr": "RAPPEL: ztncui nécessite que l'app ZeroTier soit déjà installée." }, - "example": "example.com" + "example": "zt.example.com" }, { "name": "is_public", diff --git a/scripts/install b/scripts/install index 1ff3e5c..efccb86 100644 --- a/scripts/install +++ b/scripts/install @@ -280,13 +280,12 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 +ynh_script_progression --message="Configuring SSOwat..." # Make app public if necessary if [ $is_public -eq 1 ] then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" + ynh_permission_update --permission "main" --add visitors fi #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 790ef32..282704b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -39,15 +39,6 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 -fi - # If db_name doesn't exist, create it if [ -z "$db_name" ]; then db_name=$(ynh_sanitize_dbid --db_name=$app) From ea93407686d4cb091d8021b7c3b0e5cbd1545ebe Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 18 Apr 2020 14:53:52 +0200 Subject: [PATCH 18/23] [add] setting user and password --- manifest.json | 120 ++++++++++++++++++++++++++++-------------------- scripts/install | 11 ++++- scripts/upgrade | 7 ++- 3 files changed, 87 insertions(+), 51 deletions(-) diff --git a/manifest.json b/manifest.json index 685567c..b4ea67b 100644 --- a/manifest.json +++ b/manifest.json @@ -1,51 +1,73 @@ { - "name": "ztncui", - "id": "ztncui", - "packaging_format": 1, - "description": { - "en": "ZeroTier network controller user interface", - "fr": "Interface utilisateur pour le contrôleur de réseau ZeroTier" - }, - "version": "0.5.8~ynh1", - "url": "https://key-networks.com/ztncui", - "license": "GPL-3.0-only", - "maintainer": { - "name": "tituspijean", - "email": "tituspijean@outlook.com" - }, - "requirements": { - "yunohost": ">= 3.7" - }, - "services": [], - "multi_instance": false, - "arguments": { - "install" : [ - { - "name": "domain", - "type": "domain", - "ask": { - "en": "Choose a domain name for ztncui", - "fr": "Choisissez un nom de domaine pour ztncui" - }, - "help": { - "en": "REMINDER: ztncui needs the ZeroTier app to be already installed.", - "fr": "RAPPEL: ztncui nécessite que l'app ZeroTier soit déjà installée." - }, - "example": "zt.example.com" - }, - { - "name": "is_public", - "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?" - }, - "help": { - "en": "It does not really matter, since ztncui has its own login system.", - "fr": "Cela n'a pas trop d'importance, puisque ztncui a son propre système de connection." - }, - "default": false - } - ] - } + "name": "ztncui", + "id": "ztncui", + "packaging_format": 1, + "description": { + "en": "ZeroTier network controller user interface", + "fr": "Interface utilisateur pour le contrôleur de réseau ZeroTier" + }, + "version": "0.5.8~ynh1", + "url": "https://key-networks.com/ztncui", + "license": "GPL-3.0-only", + "maintainer": { + "name": "tituspijean", + "email": "tituspijean@outlook.com" + }, + "requirements": { + "yunohost": ">= 3.7" + }, + "services": [], + "multi_instance": false, + "arguments": { + "install": [ + { + "name": "domain", + "type": "domain", + "ask": { + "en": "Choose a domain name for ztncui", + "fr": "Choisissez un nom de domaine pour ztncui" + }, + "help": { + "en": "REMINDER: ztncui needs the ZeroTier app to be already installed.", + "fr": "RAPPEL: ztncui nécessite que l'app ZeroTier soit déjà installée." + }, + "example": "zt.example.com" + }, + { + "name": "is_public", + "type": "boolean", + "ask": { + "en": "Is it a public application?", + "fr": "Est-ce une application publique ?" + }, + "help": { + "en": "Ztncui has its own login system, but setting it as private is advised.", + "fr": "Ztncui a son propre système de connexion, mais la rendre privée est conseillé." + }, + "default": false + }, + { + "name": "admin", + "type": "user", + "ask": { + "en": "Choose an admin user", + "fr": "Choisissez l’administrateur" + }, + "example": "johndoe" + }, + { + "name": "password", + "type": "password", + "ask": { + "en": "Set the administrator password", + "fr": "Définissez le mot de passe administrateur" + }, + "help": { + "en": "It will always be asked by Ztncui, in addition to your YunoHost credentials if set to private.", + "fr": "Il sera toujours demandé par Ztncui, en plus des identifiants YunoHost si l'app est privée." + }, + "example": "Choose a password" + } + ] + } } diff --git a/scripts/install b/scripts/install index efccb86..f99aadb 100644 --- a/scripts/install +++ b/scripts/install @@ -27,6 +27,8 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" #$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC +admin=$YNH_APP_ARG_ADMIN +password=$YNH_APP_ARG_PASSWORD ### If it's a multi-instance app, meaning it can be installed several times independently ### The id of the app as stated in the manifest is available as $YNH_APP_ID @@ -156,6 +158,7 @@ chown -R $app: $final_path pushd $final_path/src exec_as $app $nodejs_path/npm --loglevel=error install node-gyp exec_as $app $nodejs_path/npm --loglevel=error install + exec_as $app $nodejs_path/npm --loglevel=error install argon-cli exec_as $app $nodejs_path/npm --loglevel=error audit fix popd @@ -173,7 +176,13 @@ echo "ZT_TOKEN=$(> $env_file echo "ZT_ADDR=localhost:$(> $env_file echo "HTTP_PORT=$port" >> $env_file -cp $final_path/src/etc/default.passwd $final_path/src/etc/passwd +# Setup user credentials file +hashedpassword=$(echo -n "$password" | argon2-cli -e) +echo "{\"$admin\":{\"name\":\"$admin\",\"pass_set\":true,\"hash\":\"$hashedpassword\"}}" >> "$final_path/src/etc/passwd" + +# Store user settings +ynh_app_setting_set --app=$app --key=admin --value=$admin +ynh_app_setting_set --app=$app --key=hashedpassword --value=$hashedpassword #================================================= # LINK CERTIFICATES diff --git a/scripts/upgrade b/scripts/upgrade index 282704b..3e37aa9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,6 +21,8 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) +admin=$(ynh_app_setting_get --app=$app --key=admin) +hashedpassword=$(ynh_app_setting_get --app=$app --key=hashedpassword) #================================================= # CHECK VERSION @@ -136,6 +138,7 @@ chown -R $app: $final_path pushd $final_path/src exec_as $app $nodejs_path/npm --loglevel=error install node-gyp exec_as $app $nodejs_path/npm --loglevel=error install + exec_as $app $nodejs_path/npm --loglevel=error install argon-cli exec_as $app $nodejs_path/npm --loglevel=error audit fix popd @@ -153,7 +156,9 @@ echo "ZT_TOKEN=$(> $env_file echo "ZT_ADDR=localhost:$(> $env_file echo "HTTP_PORT=$port" >> $env_file -cp $final_path/src/etc/default.passwd $final_path/src/etc/passwd +# Setup user credentials file +hashedpassword=$(echo -n "$password" | argon2-cli -e) +echo "{\"$admin\":{\"name\":\"$admin\",\"pass_set\":true,\"hash\":\"$hashedpassword\"}}" >> "$final_path/src/etc/passwd" #================================================= # LINK CERTIFICATES From 35d8edd4c859cc95bae818edd349ce8310f0e37d Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 18 Apr 2020 15:33:31 +0200 Subject: [PATCH 19/23] [fix] proper path to argon2-cli --- scripts/install | 4 ++-- scripts/upgrade | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index f99aadb..3427ada 100644 --- a/scripts/install +++ b/scripts/install @@ -158,7 +158,7 @@ chown -R $app: $final_path pushd $final_path/src exec_as $app $nodejs_path/npm --loglevel=error install node-gyp exec_as $app $nodejs_path/npm --loglevel=error install - exec_as $app $nodejs_path/npm --loglevel=error install argon-cli + exec_as $app $nodejs_path/npm --loglevel=error install argon2-cli exec_as $app $nodejs_path/npm --loglevel=error audit fix popd @@ -177,7 +177,7 @@ echo "ZT_ADDR=localhost:$(> $env_fil echo "HTTP_PORT=$port" >> $env_file # Setup user credentials file -hashedpassword=$(echo -n "$password" | argon2-cli -e) +hashedpassword=$(echo -n "$password" | $final_path/src/node_modules/.bin/argon2-cli -e) echo "{\"$admin\":{\"name\":\"$admin\",\"pass_set\":true,\"hash\":\"$hashedpassword\"}}" >> "$final_path/src/etc/passwd" # Store user settings diff --git a/scripts/upgrade b/scripts/upgrade index 3e37aa9..d2ad7d3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -138,7 +138,7 @@ chown -R $app: $final_path pushd $final_path/src exec_as $app $nodejs_path/npm --loglevel=error install node-gyp exec_as $app $nodejs_path/npm --loglevel=error install - exec_as $app $nodejs_path/npm --loglevel=error install argon-cli + exec_as $app $nodejs_path/npm --loglevel=error install argon2-cli exec_as $app $nodejs_path/npm --loglevel=error audit fix popd @@ -157,7 +157,7 @@ echo "ZT_ADDR=localhost:$(> $env_fil echo "HTTP_PORT=$port" >> $env_file # Setup user credentials file -hashedpassword=$(echo -n "$password" | argon2-cli -e) +hashedpassword=$(echo -n "$password" | $final_path/src/node_modules/argon2-cli -e) echo "{\"$admin\":{\"name\":\"$admin\",\"pass_set\":true,\"hash\":\"$hashedpassword\"}}" >> "$final_path/src/etc/passwd" #================================================= From e45afc154380750fc190adad7bdf30720f899cbf Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 18 Apr 2020 16:31:38 +0200 Subject: [PATCH 20/23] [fix] no need to rehash password during upgrade --- scripts/upgrade | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index d2ad7d3..f4c271a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -157,7 +157,6 @@ echo "ZT_ADDR=localhost:$(> $env_fil echo "HTTP_PORT=$port" >> $env_file # Setup user credentials file -hashedpassword=$(echo -n "$password" | $final_path/src/node_modules/argon2-cli -e) echo "{\"$admin\":{\"name\":\"$admin\",\"pass_set\":true,\"hash\":\"$hashedpassword\"}}" >> "$final_path/src/etc/passwd" #================================================= From d29e919bfa2d3f8988d004fc6735c20de1353cab Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 18 Apr 2020 16:58:14 +0200 Subject: [PATCH 21/23] [upd] readme --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8be2894..9d0bc5d 100644 --- a/README.md +++ b/README.md @@ -19,19 +19,19 @@ ztncui is a web user interface for a standalone ZeroTier network controller. It ## Configuration -How to configure this app: by an admin panel, a plain file with SSH, or any other way. +No particular configuration is needed after initial installation. ## Documentation - * Official documentation: Link to the official documentation of this app + * [Official documentation](https://key-networks.com/ztncui/) * YunoHost documentation: If specific documentation is needed, feel free to contribute. ## YunoHost specific features #### Multi-users support - * No LDAP and HTTP auth supported. ztncui implements its own `passwd` file. - * Can the app be used by multiple users? Yes. See `/opt/key-networks/ztncui/src/etc/passwd` + * No LDAP and HTTP auth supported. + * Can the app be used by multiple users? Yes, you have to add them manually in `/opt/key-networks/ztncui/src/etc/passwd`, see ztncui documentation. #### Supported architectures @@ -40,7 +40,7 @@ How to configure this app: by an admin panel, a plain file with SSH, or any othe ## Limitations -* [ZeroTier for YunoHost](https://github.com/tituspijean/zerotier_ynh) has to be installed beforehand. +* [ZeroTier for YunoHost](https://github.com/YunoHost-Apps/zerotier_ynh) has to be installed beforehand. ## Additional information From d9d7444b09a755152c24d8e8c19ae67a5f2a0eb2 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 18 Apr 2020 16:58:36 +0200 Subject: [PATCH 22/23] [rem] default credentials --- scripts/install | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/install b/scripts/install index 3427ada..9da2313 100644 --- a/scripts/install +++ b/scripts/install @@ -309,4 +309,3 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= ynh_script_progression --message="Installation of $app completed" --time --last -ynh_print_warn --message="Installation of $app completed. Default credentials: admin/password" From 86821d48e0121ea21edaa254a11cf3ab142b55cb Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 18 Apr 2020 17:03:30 +0200 Subject: [PATCH 23/23] [enh] quiet grep Co-Authored-By: Kayou --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 9da2313..21f9cbe 100644 --- a/scripts/install +++ b/scripts/install @@ -56,7 +56,7 @@ app=$YNH_APP_INSTANCE_NAME ynh_script_progression --message="Validating installation parameters..." --time --weight=1 # Testing if ZeroTier is installed -yunohost app list | grep "id: zerotier" || ynh_die "ZeroTier is needed, but it is not installed. There is a package for that!" +yunohost app list | grep -q "id: zerotier" || ynh_die "ZeroTier is needed, but it is not installed. There is a package for that!" ### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". ### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"