From ec8b46e7b7dbcb3a1b96ca4d4eb2c37b801af653 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 25 Feb 2021 09:36:43 +0100 Subject: [PATCH] Open ports for turn --- check_process | 2 -- conf/systemd.service | 2 +- manifest.json | 2 +- scripts/change_url | 6 +++--- scripts/install | 15 ++++++++++++++- scripts/remove | 17 +++++++++++++++++ scripts/restore | 3 ++- scripts/upgrade | 3 ++- 8 files changed, 40 insertions(+), 10 deletions(-) diff --git a/check_process b/check_process index 54dd9e2..7d4312d 100644 --- a/check_process +++ b/check_process @@ -1,8 +1,6 @@ # See here for more information # https://github.com/YunoHost/package_check#syntax-check_process-file -# Move this file from check_process.default to check_process when you have filled it. - ;; Test complet ; Manifest domain="domain.tld" (DOMAIN) diff --git a/conf/systemd.service b/conf/systemd.service index b2134d2..a204e02 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -8,7 +8,7 @@ Type=simple WorkingDirectory=__FINALPATH__/ User=__APP__ Group=__APP__ -ExecStart=__FINALPATH__/galene -turn auto +ExecStart=__FINALPATH__/galene -turn __IPV4__:1194 LimitNOFILE=65536 [Install] diff --git a/manifest.json b/manifest.json index 8df1672..2429f67 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "" }, "requirements": { - "yunohost": ">= 4.0.8" + "yunohost": ">= 4.1.7" }, "multi_instance": false, "services": [ diff --git a/scripts/change_url b/scripts/change_url index 10d80ee..776a58b 100755 --- a/scripts/change_url +++ b/scripts/change_url @@ -106,14 +106,14 @@ fi #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=3 +ynh_script_progression --message="Starting a systemd service..." --weight=3 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +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_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/install b/scripts/install index eade927..5dd61be 100755 --- a/scripts/install +++ b/scripts/install @@ -66,6 +66,15 @@ ynh_script_progression --message="Finding an available port..." --weight=3 port=$(ynh_find_port --port=8443) ynh_app_setting_set --app=$app --key=port --value=$port +# Find an available port +turn_port=$(ynh_find_port --port=1194) +ynh_app_setting_set --app=$app --key=port --value=$port + +# Open the port +ynh_script_progression --message="Configuring firewall..." --weight=1 +ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port +ynh_exec_warn_less yunohost firewall allow Both $turn_port + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -115,6 +124,10 @@ ynh_system_user_create --username=$app #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=1 +public_ip4="$(curl ip.yunohost.org)" || true + +ynh_replace_string --match_string="__IPV4__" --replace_string="$public_ip4" --target_file="../conf/systemd.service" + # Create a dedicated systemd config ynh_add_systemd_config @@ -152,7 +165,7 @@ chmod -R 755 $final_path #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=2 -yunohost service add $app --description="Videoconferencing server" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Videoconferencing server" --log="/var/log/$app/$app.log" --needs_exposed_ports $turn_port #================================================= # START SYSTEMD SERVICE diff --git a/scripts/remove b/scripts/remove index 5855ced..e967107 100755 --- a/scripts/remove +++ b/scripts/remove @@ -18,6 +18,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) +turn_port=$(ynh_app_setting_get --app=$app --key=turn_port) final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= @@ -57,6 +58,22 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config +#================================================= +# CLOSE A PORT +#================================================= + +if yunohost firewall list | grep -q "\- $port$" +then + ynh_script_progression --message="Closing port $port..." --weight=1 + ynh_exec_warn_less yunohost firewall disallow TCP $port +fi + +if yunohost firewall list | grep -q "\- $turn_port$" +then + ynh_script_progression --message="Closing port $turn_port..." --weight=1 + ynh_exec_warn_less yunohost firewall disallow both $turn_port +fi + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index a67414f..18df114 100755 --- a/scripts/restore +++ b/scripts/restore @@ -31,6 +31,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) group_name=$(ynh_app_setting_get --app=$app --key=group_name) +turn_port=$(ynh_app_setting_get --app=$app --key=turn_port) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -86,7 +87,7 @@ systemctl enable $app.service --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=2 -yunohost service add $app --description="Videoconferencing server" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Videoconferencing server" --log="/var/log/$app/$app.log" --needs_exposed_ports $turn_port #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index d61c357..3eb862a 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,6 +23,7 @@ is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) group_name=$(ynh_app_setting_get --app=$app --key=group_name) port=$(ynh_app_setting_get --app=$app --key=port) +turn_port=$(ynh_app_setting_get --app=$app --key=turn_port) architecture=$(ynh_detect_arch) #================================================= @@ -149,7 +150,7 @@ chmod -R 755 $final_path #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Videoconferencing server" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Videoconferencing server" --log="/var/log/$app/$app.log" --needs_exposed_ports $turn_port #================================================= # START SYSTEMD SERVICE