From 94c1e65c62a11b8a6f240b0c2c9da3cfe63b3cbf Mon Sep 17 00:00:00 2001 From: lapineige Date: Tue, 25 Jul 2023 14:06:20 +0200 Subject: [PATCH] Unique runner ID (#4) * Use ynh NPM * Use ynh NPM * improve runner_name * improve runner_name * peertube_url * peertube_url * peertube_url * test new npm command * fix syntax * fix syntax * change npm commands * fix npm command * fix parameters * fix parameters * use npm_node * use npm_node * fix typo * relative path * debugging * fix debug * improve debug * fix node_module * fix command syntax * fix syntax * debug * Fix binary path * Fix remove * Cleaning * Delete doc/screenshots directory * Auto-update README * cleaning + remove nginx * Delete nginx.conf * cleaning + remove nginx * Delete POST_UPGRADE.md * Delete PRE_UPGRADE.md * Delete PRE_INSTALL_fr.md * Delete PRE_INSTALL.md * Update POST_INSTALL.md * Update POST_INSTALL.md * Update DESCRIPTION.md * Auto-update README * Update DESCRIPTION_fr.md * Auto-update README * Delete ADMIN.md * better doc link * Create PRE_INSTALL.md * Create PRE_INSTALL_fr.md * Fix change_url * Add path + help messages * Improvements * change hostname to unique ID * change hostname to unique ID * cleaning * register the runner (again) * fix id Co-authored-by: Alexandre Aubin * cleaning * cleaning --------- Co-authored-by: yunohost-bot Co-authored-by: Alexandre Aubin --- scripts/install | 6 +++++- scripts/remove | 2 +- scripts/restore | 9 +++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index c622825..ab9b928 100755 --- a/scripts/install +++ b/scripts/install @@ -61,9 +61,13 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= ynh_script_progression --message="Registering the runner on Peertube server..." --weight=1 +runner_id=$(ynh_string_random --length=5 --filter='0-9') +ynh_app_setting_set --app=$app --key='runner_id' --value=$runner_id + pushd "$install_dir" ynh_use_nodejs - ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$install_dir/config" NODE_ENV=production $ynh_node "$install_dir/node_modules/@peertube/peertube-runner" register --url $peertube_url --registration-token $runner_token --runner-name $app\_$(hostname) + ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$install_dir/config" NODE_ENV=production $ynh_node "$install_dir/node_modules/@peertube/peertube-runner" register --url $peertube_url --registration-token $runner_token --runner-name $app\_$runner_id + popd #================================================= diff --git a/scripts/remove b/scripts/remove index 2506ef7..5322e85 100755 --- a/scripts/remove +++ b/scripts/remove @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Unregistering the runner on Peertube server..." --weight=1 -ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$install_dir/config" NODE_ENV=production $ynh_node "$install_dir/node_modules/@peertube/peertube-runner" unregister --url $peertube_url --registration-token $runner_token --runner-name $app\_$(hostname) +ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$install_dir/config" NODE_ENV=production $ynh_node "$install_dir/node_modules/@peertube/peertube-runner" unregister --url $peertube_url --registration-token $runner_token --runner-name $app\_$runner_id #================================================= # REMOVE SYSTEM CONFIGURATIONS diff --git a/scripts/restore b/scripts/restore index 02ed2e1..39c6ac8 100755 --- a/scripts/restore +++ b/scripts/restore @@ -58,6 +58,15 @@ systemctl enable $app.service --quiet yunohost service add $app --description="Peertube remote runner" --log="/var/log/$app/$app.log" +#================================================= +# RUNNER REGISTRATION +#================================================= + +pushd "$install_dir" + ynh_use_nodejs + ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$install_dir/config" NODE_ENV=production $ynh_node "$install_dir/node_modules/@peertube/peertube-runner" register --url $peertube_url --registration-token $runner_token --runner-name $app\_$runner_id +popd + #================================================= # GENERIC FINALIZATION #=================================================