From 63df56b4de5e77b9b79bdf559861c139dfe658b2 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 5 Jun 2021 11:44:15 +0200 Subject: [PATCH] Fix --- scripts/install | 38 +++++++++++++++++++++++--------------- scripts/restore | 33 +++++++++++++++++++++++++-------- scripts/upgrade | 32 +++++++++++++++++++++++--------- 3 files changed, 71 insertions(+), 32 deletions(-) diff --git a/scripts/install b/scripts/install index b8e0f27..46a5214 100644 --- a/scripts/install +++ b/scripts/install @@ -82,8 +82,6 @@ ynh_exec_warn_less yunohost firewall allow Both $port if [ "$mumbleweb" -eq 1 ] ; then port_web=$(ynh_find_port --port=64737) ynh_app_setting_set --app=$app --key=port_web --value=$port_web - # Open port in firewall - #ynh_exec_warn_less yunohost firewall allow Both $port_web fi #================================================= @@ -111,9 +109,8 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= ynh_script_progression --message="Installing Mumble Web..." --weight=4 -ynh_app_setting_set --app=$app --key=final_path --value=$final_path - if [ "$mumbleweb" -eq 1 ] ; then + ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_setup_source --dest_dir="$final_path" fi @@ -123,7 +120,9 @@ fi ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated nginx config -ynh_add_nginx_config +if [ "$mumbleweb" -eq 1 ] ; then + ynh_add_nginx_config +fi #================================================= # SPECIFIC SETUP @@ -198,7 +197,9 @@ ynh_script_progression --message="Integrating service in YunoHost..." # Add Mumble as a YunoHost service yunohost service add $app --description="Mumble server" --log="/var/log/$app/$app.log" --needs_exposed_ports=$port # Add Mumble as a YunoHost service -yunohost service add mumble-web --description="Mumble web interface" --log="/var/log/$app/mumble-web.log" +if [ "$mumbleweb" -eq 1 ] ; then + yunohost service add mumble-web --description="Mumble web interface" --log="/var/log/$app/mumble-web.log" +fi #================================================= # START SYSTEMD SERVICE @@ -206,26 +207,33 @@ yunohost service add mumble-web --description="Mumble web interface" --log="/var ynh_script_progression --message="Starting a systemd service..." --weight=3 ynh_systemd_action --service_name=$app --action=restart --log_path="/var/log/$app/$app.log" - -ynh_systemd_action --service_name=mumble-web --action=restart --log_path="/var/log/$app/mumble-web.log" +if [ "$mumbleweb" -eq 1 ] ; then + ynh_systemd_action --service_name=mumble-web --action=restart --log_path="/var/log/$app/mumble-web.log" +fi #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 -# Make app public if necessary -if [ $is_public -eq 1 ] -then - ynh_permission_update --permission="main" --add="visitors" +if [ "$mumbleweb" -eq 1 ] ; then + ynh_script_progression --message="Configuring permissions..." --weight=1 + + # Make app public if necessary + if [ $is_public -eq 1 ] + then + ynh_permission_update --permission="main" --add="visitors" + fi fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +if [ "$mumbleweb" -eq 1 ] ; then + ynh_script_progression --message="Reloading NGINX web server..." --weight=1 + + ynh_systemd_action --service_name=nginx --action=reload +fi #================================================= # SEND README TO ADMIN diff --git a/scripts/restore b/scripts/restore index 2fc6666..baaf25b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -26,18 +26,20 @@ 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) port=$(ynh_app_setting_get --app=$app --key=port) +mumbleweb=$(ynh_app_setting_get --app=$app --key=mumbleweb) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 -ynh_script_progression --message="Validating restoration parameters..." --weight=1 +if [ "$mumbleweb" -eq 1 ] ; then + ynh_script_progression --message="Validating restoration parameters..." --weight=1 ynh_webpath_available --domain=$domain --path_url=$path_url \ || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " +fi #================================================= # STANDARD RESTORATION STEPS @@ -45,7 +47,9 @@ test ! -d $final_path \ # RESTORE THE NGINX CONFIGURATION #================================================= +if [ "$mumbleweb" -eq 1 ] ; then ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +fi #================================================= # RECREATE THE DEDICATED USER @@ -71,6 +75,10 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=4 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies +if [ "$mumbleweb" -eq 1 ] ; then + ynh_install_nodejs --nodejs_version=$nodejs_version +fi + #================================================= # RESTORE USER RIGHTS #================================================= @@ -102,7 +110,9 @@ ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 # Add Mumble as a YunoHost service yunohost service add $app --description="Mumble server" --log="/var/log/$app/$app.log" --needs_exposed_ports=$port # Add Mumble as a YunoHost service -yunohost service add mumble-web --description="Mumble web interface" --log="/var/log/$app/mumble-web.log" +if [ "$mumbleweb" -eq 1 ] ; then + yunohost service add mumble-web --description="Mumble web interface" --log="/var/log/$app/mumble-web.log" +fi #================================================= # RESTORE SYSTEMD @@ -112,8 +122,10 @@ ynh_script_progression --message="Restoring the systemd configuration..." --weig ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable "$app.service" --quiet -ynh_restore_file --origin_path="/etc/systemd/system/mumble-web.service" -systemctl enable "mumble-web.service" --quiet +if [ "$mumbleweb" -eq 1 ] ; then + ynh_restore_file --origin_path="/etc/systemd/system/mumble-web.service" + systemctl enable "mumble-web.service" --quiet +fi #================================================= # START SYSTEMD SERVICE @@ -121,16 +133,21 @@ systemctl enable "mumble-web.service" --quiet ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="mumble-web" --action="start" --log_path="/var/log/$app/mumble-web.log" +if [ "$mumbleweb" -eq 1 ] ; then + ynh_systemd_action --service_name="mumble-web" --action="start" --log_path="/var/log/$app/mumble-web.log" +fi #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +if [ "$mumbleweb" -eq 1 ] ; then + ynh_script_progression --message="Reloading NGINX web server..." --weight=1 + + ynh_systemd_action --service_name=nginx --action=reload +fi #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index 0b229aa..764e6d0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -125,7 +125,9 @@ ynh_abort_if_errors ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name="$app" --action="stop" -ynh_systemd_action --service_name="mumble-web" --action="stop" +if [ "$mumbleweb" -eq 1 ] ; then + ynh_systemd_action --service_name="mumble-web" --action="stop" +fi #================================================= # CREATE DEDICATED USER @@ -152,7 +154,9 @@ fi ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=5 # Create a dedicated nginx config -ynh_add_nginx_config +if [ "$mumbleweb" -eq 1 ] ; then + ynh_add_nginx_config +fi #================================================= # INSTALL DEPENDENCIES @@ -162,6 +166,10 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=1 # Install Mumble Debian package via apt ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +if [ "$mumbleweb" -eq 1 ] ; then + ynh_install_nodejs --nodejs_version=$nodejs_version +fi + #================================================= # SPECIFIC UPGRADE #================================================= @@ -194,7 +202,7 @@ chmod -R 770 "$final_path" chown -R :mumble-server "$final_path" #================================================= -#ADD USER TO SSL-CERT +# ADD USER TO SSL-CERT #================================================= # Add user to ssl-cert so it can read certificates @@ -222,7 +230,9 @@ systemctl disable mumble-server --quiet # Add Mumble as a YunoHost service yunohost service add $app --description="Mumble server" --log="/var/log/$app/$app.log" --needs_exposed_ports=$port # Add Mumble as a YunoHost service -yunohost service add mumble-web --description="Mumble web interface" --log="/var/log/$app/mumble-web.log" +if [ "$mumbleweb" -eq 1 ] ; then + yunohost service add mumble-web --description="Mumble web interface" --log="/var/log/$app/mumble-web.log" +fi #================================================= # START SYSTEMD SERVICE @@ -230,21 +240,25 @@ yunohost service add mumble-web --description="Mumble web interface" --log="/var ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name="mumble-web" --action="start" --log_path="/var/log/$app/mumble-web.log" +if [ "$mumbleweb" -eq 1 ] ; then + ynh_systemd_action --service_name="mumble-web" --action="start" --log_path="/var/log/$app/mumble-web.log" +fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=2 +if [ "$mumbleweb" -eq 1 ] ; then + ynh_script_progression --message="Reloading NGINX web server..." --weight=2 -ynh_systemd_action --service_name=nginx --action=reload + ynh_systemd_action --service_name=nginx --action=reload +fi #================================================= # SEND README TO ADMIN #================================================= message=" -Mumble-server was updated! +Mumble server was updated! Port : $port Password to join server: $server_password @@ -252,7 +266,7 @@ SuperUser Password : $su_passwd Welcome text : $welcometext Root channel (your mumble server name): $registername Final path (where to find your files) : $final_path -Mumble configuration file : ../conf/mumble-server.ini +Mumble configuration file : $final_path/mumble-server.ini Note about config file: this package will regenerate the config file on upgrade. If you changed it manually and upgrade mumble, you'll find a backup in $final_path.