From 5e5f6e0d1d937650abdcfa7d27de29561e2a5ee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Fri, 3 Feb 2023 13:54:11 +0100 Subject: [PATCH] Fix --- scripts/install | 38 ++++++-------------------------------- scripts/remove | 25 +++---------------------- scripts/upgrade | 37 ++++++------------------------------- 3 files changed, 15 insertions(+), 85 deletions(-) diff --git a/scripts/install b/scripts/install index c1e146f..c0fee55 100755 --- a/scripts/install +++ b/scripts/install @@ -23,24 +23,8 @@ ynh_app_setting_set --app=$app --key=group_description --value="$group_descripti #================================================= # FIND AND OPEN A PORT #================================================= -#REMOVEME? ynh_script_progression --message="Finding an available port..." --weight=3 - -# Find an available port -#REMOVEME? port=$(ynh_find_port --port=8095) -#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port - -#REMOVEME? ldap_port=$(ynh_find_port --port=$(($port + 1))) -#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$ldap_port - -# Find an available port for TURN -#REMOVEME? turn_port=$(ynh_find_port --port=1194) -#REMOVEME? ynh_app_setting_set --app=$app --key=turn_port --value=$turn_port - -# Open TURN port ynh_script_progression --message="Configuring firewall..." --weight=1 -ynh_exec_warn_less yunohost firewall allow Both $turn_port - # Reserve UDP Port range 49152:65535 ynh_exec_warn_less yunohost firewall allow UDP -4 49152:65535 @@ -85,20 +69,17 @@ pushd $install_dir/build_ldap/ ynh_exec_warn_less ynh_exec_as $app CGO_ENABLED=0 $ynh_go build -ldflags='-s -w' -o $install_dir/live_ldap/ popd ynh_remove_go -#REMOVEME? ynh_secure_remove --file="$install_dir/build/" -#REMOVEME? ynh_secure_remove --file="$install_dir/build_ldap/" -#REMOVEME? ynh_secure_remove --file="$install_dir/.cache/" -#REMOVEME? ynh_secure_remove --file="$install_dir/go/" -#REMOVEME? ynh_secure_remove --file="$install_dir/.go-version" +ynh_secure_remove --file="$install_dir/build/" +ynh_secure_remove --file="$install_dir/build_ldap/" +ynh_secure_remove --file="$install_dir/.cache/" +ynh_secure_remove --file="$install_dir/go/" +ynh_secure_remove --file="$install_dir/.go-version" #================================================= # CREATE DATA DIRECTORY #================================================= ynh_script_progression --message="Creating a data directory..." --weight=1 -#REMOVEME? data_dir=/home/yunohost.app/$app -#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir - mkdir -p $data_dir/{groups,recordings} chmod 750 "$data_dir" @@ -150,7 +131,7 @@ ynh_add_systemd_config --service=${app}_ldap --template="ldap.service" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=2 -yunohost service add $app --description="Videoconferencing server" --needs_exposed_ports="$turn_port" +yunohost service add $app --description="Videoconferencing server" --needs_exposed_ports="$port_turn" yunohost service add ${app}_ldap --description="LDAP integration for the videoconferencing server" #================================================= @@ -162,13 +143,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" ynh_systemd_action --service_name=${app}_ldap --action="start" --log_path="systemd" -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=2 - -ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 39fe3fb..23d30bd 100755 --- a/scripts/remove +++ b/scripts/remove @@ -37,17 +37,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..." ynh_remove_systemd_config ynh_remove_systemd_config --service=${app}_ldap -#================================================= -# REMOVE DATA DIR -#================================================= - -# Remove the data directory if --purge option is used -if [ "${YNH_APP_PURGE:-0}" -eq 1 ] -then - ynh_script_progression --message="Removing app data directory..." --weight=1 -#REMOVEME? ynh_secure_remove --file="$data_dir" -fi - #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -56,22 +45,14 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -#REMOVEME? ynh_remove_app_dependencies - #================================================= # CLOSE A PORT #================================================= -if yunohost firewall list | grep -q "\- $turn_port$" +if yunohost firewall list | grep -q "\- $port_turn$" then - ynh_script_progression --message="Closing port $turn_port..." --weight=1 - ynh_exec_warn_less yunohost firewall disallow both $turn_port + ynh_script_progression --message="Closing port $port_turn..." --weight=1 + ynh_exec_warn_less yunohost firewall disallow both $port_turn fi if yunohost firewall list | grep -q "\- 49152:65535" diff --git a/scripts/upgrade b/scripts/upgrade index f7761a5..674823a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -37,23 +37,6 @@ then ynh_exec_warn_less yunohost firewall disallow TCP $port fi -# If install_dir doesn't exist, create it -if [ -z "$install_dir" ]; then -#REMOVEME? install_dir=/var/www/$app - mkdir -p $install_dir -#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir -fi - -# If ldap_port doesn't exist, create it -if [ -z "$ldap_port" ]; then -#REMOVEME? ldap_port=$(ynh_find_port --port=$(($port + 1))) -#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$ldap_port - -# We remove the old admin/password file if present -if [ -f "$install_dir/data/passwd" ] ; then -#REMOVEME? ynh_secure_remove --file="$install_dir/data/passwd" -fi - # For version 0.6~ynh1 and before if [[ ! -d "$install_dir/live" ]] then @@ -69,7 +52,6 @@ fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= - ynh_script_progression --message="Upgrading source files..." --weight=2 ynh_setup_source --dest_dir="$install_dir/build" @@ -110,11 +92,11 @@ then ynh_exec_as $app CGO_ENABLED=0 $ynh_go build -ldflags='-s -w' -o $install_dir/live_ldap/ popd ynh_remove_go -#REMOVEME? ynh_secure_remove --file="$install_dir/build/" -#REMOVEME? ynh_secure_remove --file="$install_dir/build_ldap/" -#REMOVEME? ynh_secure_remove --file="$install_dir/.cache/" -#REMOVEME? ynh_secure_remove --file="$install_dir/go/" -#REMOVEME? ynh_secure_remove --file="$install_dir/.go-version" + ynh_secure_remove --file="$install_dir/build/" + ynh_secure_remove --file="$install_dir/build_ldap/" + ynh_secure_remove --file="$install_dir/.cache/" + ynh_secure_remove --file="$install_dir/go/" + ynh_secure_remove --file="$install_dir/.go-version" fi #================================================= @@ -165,7 +147,7 @@ ynh_add_systemd_config --service=${app}_ldap --template="ldap.service" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Videoconferencing server" --needs_exposed_ports="$turn_port" +yunohost service add $app --description="Videoconferencing server" --needs_exposed_ports="$port_turn" yunohost service add ${app}_ldap --description="LDAP integration for the videoconferencing server" #================================================= @@ -176,13 +158,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" ynh_systemd_action --service_name=${app}_ldap --action="start" --log_path="systemd" -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=2 - -ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #=================================================