From 6e7df45f125b4a4709b2a770ae65d0faadaa2868 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Tue, 21 Nov 2017 11:22:26 +0100 Subject: [PATCH 01/13] Add generic headers and _common.sh --- scripts/_common.sh | 3 +++ scripts/install | 59 +++++++++++++++++++++++++++------------------- scripts/remove | 17 +++++++------ scripts/upgrade | 13 ++++++++-- 4 files changed, 59 insertions(+), 33 deletions(-) create mode 100644 scripts/_common.sh diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..7a693aa --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,3 @@ +#!/bin/bash + + diff --git a/scripts/install b/scripts/install index 4b67ab7..5eb697e 100644 --- a/scripts/install +++ b/scripts/install @@ -1,24 +1,35 @@ #!/bin/bash -#debug commands -#exec > >(tee /tmp/mumble-install.log) -#exec 2>&1 -# Exit on command errors and treat unset variables as an error -set -eu +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# RETRIEVE ARGUMENTS FROM THE MANIFEST +#================================================= # Retrieve arguments -app="mumbleserver" +app=$YNH_APP_INSTANCE_NAME server_password=$YNH_APP_ARG_SERVER_LOGIN_PASSWORD su_passwd=$YNH_APP_ARG_PASSWORD welcometext=$YNH_APP_ARG_WELCOMETEXT port=$YNH_APP_ARG_PORT registerName=$YNH_APP_ARG_REGISTERNAME -# Source YunoHost helpers -source /usr/share/yunohost/helpers - # Check port availability -sudo yunohost app checkport $port +yunohost app checkport $port if [[ ! $? -eq 0 ]]; then ynh_die fi @@ -32,33 +43,33 @@ fi ynh_app_setting_set $app port "$port" # Install Mumble Debian package via apt -sudo apt update > /dev/null 2>&1 -sudo apt install -y mumble-server > /dev/null 2>&1 +apt update > /dev/null 2>&1 +apt install -y mumble-server > /dev/null 2>&1 # Configuring with given settings mumble_conf="../conf/mumble-server.ini" -sudo sed -i "s/welcometext=.*/welcometext=$welcometext/" $mumble_conf -sudo sed -i "s/port=.*/port=$port/" $mumble_conf -sudo sed -i "s/serverpassword=.*/serverpassword=$server_password/" $mumble_conf -sudo sed -i "s/#registerName=.*/registerName=$registerName/" $mumble_conf +sed -i "s/welcometext=.*/welcometext=$welcometext/" $mumble_conf +sed -i "s/port=.*/port=$port/" $mumble_conf +sed -i "s/serverpassword=.*/serverpassword=$server_password/" $mumble_conf +sed -i "s/#registerName=.*/registerName=$registerName/" $mumble_conf # Copying conf file mumble_conf="/etc/mumble-server.ini" -sudo cp ../conf/mumble-server.ini $mumble_conf -sudo chmod 660 $mumble_conf -sudo chown :mumble-server $mumble_conf +cp ../conf/mumble-server.ini $mumble_conf +chmod 660 $mumble_conf +chown :mumble-server $mumble_conf # Open port in firewall -sudo yunohost firewall allow Both $port > /dev/null 2>&1 +yunohost firewall allow Both $port > /dev/null 2>&1 # Start Mumble server -sudo /etc/init.d/mumble-server start +/etc/init.d/mumble-server start # Set super-user password -sudo murmurd -supw $su_passwd +murmurd -supw $su_passwd # Restart Mumble server -sudo /etc/init.d/mumble-server restart +/etc/init.d/mumble-server restart # Add Mumble as a YunoHost service -sudo yunohost service add mumble-server -l /var/log/mumble-server/mumble-server.log +yunohost service add mumble-server -l /var/log/mumble-server/mumble-server.log diff --git a/scripts/remove b/scripts/remove index 53bd38f..7488bca 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,9 +1,12 @@ #!/bin/bash -# Exit and treat unset variables as an error -set -u +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Source YunoHost helpers +source _common.sh source /usr/share/yunohost/helpers app=mumbleserver @@ -12,13 +15,13 @@ app=mumbleserver port=$(ynh_app_setting_get $app port) # Uninstall Mumble and its dependencies -sudo apt autoremove -y mumble-server > /dev/null 2>&1 +apt autoremove -y mumble-server > /dev/null 2>&1 # Close ports -sudo yunohost firewall disallow Both $port > /dev/null 2>&1 +yunohost firewall disallow Both $port > /dev/null 2>&1 # Removing config file -sudo rm -f /etc/mumble-server.ini +rm -f /etc/mumble-server.ini # Remove mumble-server service -sudo yunohost service remove mumble-server +yunohost service remove mumble-server diff --git a/scripts/upgrade b/scripts/upgrade index a1a1178..27b6b28 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,4 +1,13 @@ #!/bin/bash -# Exit on command errors and treat unset variables as an error -set -eu +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= +source _common.sh +source /usr/share/yunohost/helpers + +ynh_abort_if_errors + +ynh_die "There is no upgrade yet" From c736ccf103aa706215ddb5056053de27723e7a7a Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Tue, 21 Nov 2017 11:31:25 +0100 Subject: [PATCH 02/13] change install file structure --- scripts/install | 58 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index 5eb697e..95148fc 100644 --- a/scripts/install +++ b/scripts/install @@ -28,6 +28,10 @@ welcometext=$YNH_APP_ARG_WELCOMETEXT port=$YNH_APP_ARG_PORT registerName=$YNH_APP_ARG_REGISTERNAME +#================================================= +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS +#================================================= + # Check port availability yunohost app checkport $port if [[ ! $? -eq 0 ]]; then @@ -39,13 +43,39 @@ if [[ -z "$su_passwd" ]]; then ynh_die fi +#================================================= +# STORE SETTINGS FROM MANIFEST +#================================================= + # Save app settings ynh_app_setting_set $app port "$port" + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# FIND AND OPEN A PORT +#================================================= + +# Open port in firewall +yunohost firewall allow Both $port > /dev/null 2>&1 + +#================================================= +# INSTALL DEPENDENCIES +#================================================= + # Install Mumble Debian package via apt apt update > /dev/null 2>&1 apt install -y mumble-server > /dev/null 2>&1 + +#================================================= +# SPECIFIC SETUP +#================================================= +# mumble server conf.ini +#================================================= +# TODO: clean this + # Configuring with given settings mumble_conf="../conf/mumble-server.ini" sed -i "s/welcometext=.*/welcometext=$welcometext/" $mumble_conf @@ -56,20 +86,38 @@ sed -i "s/#registerName=.*/registerName=$registerName/" $mumble_conf # Copying conf file mumble_conf="/etc/mumble-server.ini" cp ../conf/mumble-server.ini $mumble_conf -chmod 660 $mumble_conf -chown :mumble-server $mumble_conf -# Open port in firewall -yunohost firewall allow Both $port > /dev/null 2>&1 +#================================================= +# STORE THE CHECKSUM OF THE CONFIG FILE +#================================================= + +# TODO: add this checksum step + +#================================================= +# Start services +#================================================= # Start Mumble server /etc/init.d/mumble-server start # Set super-user password -murmurd -supw $su_passwd +murmurd -ini $mumble_conf -supw $su_passwd # Restart Mumble server /etc/init.d/mumble-server restart +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + +chmod 660 $mumble_conf +chown :mumble-server $mumble_conf + +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + # Add Mumble as a YunoHost service yunohost service add mumble-server -l /var/log/mumble-server/mumble-server.log From f6368ee675e625c15e5a1d875f83c08485f6e51d Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Tue, 21 Nov 2017 11:52:26 +0100 Subject: [PATCH 03/13] Use helpers and shellcheck --- conf/mumble-server.ini | 8 ++++---- scripts/install | 43 +++++++++++++++++++++--------------------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/conf/mumble-server.ini b/conf/mumble-server.ini index 6d6836f..a1d092e 100644 --- a/conf/mumble-server.ini +++ b/conf/mumble-server.ini @@ -85,17 +85,17 @@ pidfile=/var/run/mumble-server/mumble-server.pid # configure it here than through D-Bus or Ice. # # Welcome message sent to clients when they connect. -welcometext="
Welcome to this server running Murmur.
Enjoy your stay!
" +welcometext="__WELCOME__" # Port to bind TCP and UDP sockets to. -port=64738 +port=__PORT__ # Specific IP or hostname to bind to. # If this is left blank (default), Murmur will bind to all available addresses. #host= # Password to join server. -serverpassword= +serverpassword=__SRV_PWD__ # Maximum bandwidth (in bits per second) clients are allowed # to send speech at. @@ -143,7 +143,7 @@ users=100 # addresses. # Only uncomment the 'registerName' parameter if you wish to give your "Root" channel a custom name. # -#registerName=Mumble Server +registerName=__REGISTER__ #registerPassword=secret #registerUrl=http://mumble.sourceforge.net/ #registerHostname= diff --git a/scripts/install b/scripts/install index 95148fc..41acbaf 100644 --- a/scripts/install +++ b/scripts/install @@ -33,14 +33,14 @@ registerName=$YNH_APP_ARG_REGISTERNAME #================================================= # Check port availability -yunohost app checkport $port -if [[ ! $? -eq 0 ]]; then - ynh_die + +if [[ ! $(yunohost app checkport "$port") -eq 0 ]]; then + ynh_die "Port is not available" fi # Check if su_password is not empty if [[ -z "$su_passwd" ]]; then - ynh_die + ynh_die "Password is not set" fi #================================================= @@ -48,8 +48,11 @@ fi #================================================= # Save app settings -ynh_app_setting_set $app port "$port" - +ynh_app_setting_set "$app" port "$port" +ynh_app_setting_set "$app" server_password "$server_password" +ynh_app_setting_set "$app" su_passwd "$su_passwd" +ynh_app_setting_set "$app" welcometext "$welcometext" +ynh_app_setting_set "$app" registerName "$registerName" #================================================= # STANDARD MODIFICATIONS @@ -58,16 +61,14 @@ ynh_app_setting_set $app port "$port" #================================================= # Open port in firewall -yunohost firewall allow Both $port > /dev/null 2>&1 +yunohost firewall allow Both "$port" #================================================= # INSTALL DEPENDENCIES #================================================= # Install Mumble Debian package via apt -apt update > /dev/null 2>&1 -apt install -y mumble-server > /dev/null 2>&1 - +ynh_install_app_dependencies mumble-server #================================================= # SPECIFIC SETUP @@ -77,21 +78,21 @@ apt install -y mumble-server > /dev/null 2>&1 # TODO: clean this # Configuring with given settings -mumble_conf="../conf/mumble-server.ini" -sed -i "s/welcometext=.*/welcometext=$welcometext/" $mumble_conf -sed -i "s/port=.*/port=$port/" $mumble_conf -sed -i "s/serverpassword=.*/serverpassword=$server_password/" $mumble_conf -sed -i "s/#registerName=.*/registerName=$registerName/" $mumble_conf - -# Copying conf file mumble_conf="/etc/mumble-server.ini" -cp ../conf/mumble-server.ini $mumble_conf + +cp ../conf/mumble-server.ini "$mumble_conf" + +ynh_replace_string "__WELCOME__" "$welcometext" "$mumble_conf" +ynh_replace_string "__PORT__" "$port" "$mumble_conf" +ynh_replace_string "__SRV_PWD__" "$server_password" "$mumble_conf" +ynh_replace_string "__REGISTER__" "$registerName" "$mumble_conf" #================================================= # STORE THE CHECKSUM OF THE CONFIG FILE #================================================= # TODO: add this checksum step +ynh_store_file_checksum "$mumble_conf" #================================================= # Start services @@ -101,7 +102,7 @@ cp ../conf/mumble-server.ini $mumble_conf /etc/init.d/mumble-server start # Set super-user password -murmurd -ini $mumble_conf -supw $su_passwd +murmurd -ini "$mumble_conf" -supw "$su_passwd" # Restart Mumble server /etc/init.d/mumble-server restart @@ -112,8 +113,8 @@ murmurd -ini $mumble_conf -supw $su_passwd # SECURE FILES AND DIRECTORIES #================================================= -chmod 660 $mumble_conf -chown :mumble-server $mumble_conf +chmod 660 "$mumble_conf" +chown :mumble-server "$mumble_conf" #================================================= # ADVERTISE SERVICE IN ADMIN PANEL From 3d4cf111b3e4877a4c927a977a48708a1f83a7d8 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Wed, 29 Nov 2017 23:33:21 +0100 Subject: [PATCH 04/13] Rewrite installation --- check_process | 2 +- conf/mumble-server.ini | 6 +++--- conf/systemd.service | 15 ++++++++++++++ manifest.json | 3 ++- scripts/install | 45 +++++++++++++++++++++++++++++------------- 5 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 conf/systemd.service diff --git a/check_process b/check_process index bb4a25d..31b9cf2 100644 --- a/check_process +++ b/check_process @@ -4,7 +4,7 @@ server_login_password="super_secret_password" (PASSWORD) password="super_secret_password" welcometext="Welcome to my mumble server" - port="64738" (PORT) + port=64738 (PORT) registername="Root" ; Checks pkg_linter=1 diff --git a/conf/mumble-server.ini b/conf/mumble-server.ini index a1d092e..e91f299 100644 --- a/conf/mumble-server.ini +++ b/conf/mumble-server.ini @@ -13,7 +13,7 @@ # Path to database. If blank, will search for # murmur.sqlite in default locations or create it if not found. -database=/var/lib/mumble-server/mumble-server.sqlite +database=__FINALPATH__/mumble-server.sqlite # If you wish to use something other than SQLite, you'll need to set the name # of the database above, and also uncomment the below. @@ -72,13 +72,13 @@ icesecretwrite= # logs to the file 'murmur.log'. If you leave this field blank # on Unix-like systems, Murmur will force itself into foreground # mode which logs to the console. -logfile=/var/log/mumble-server/mumble-server.log +logfile=/var/log/mumble-server/__APP__.log # If set, Murmur will write its process ID to this file # when running in daemon mode (when the -fg flag is not # specified on the command line). Only available on # Unix-like systems. -pidfile=/var/run/mumble-server/mumble-server.pid +pidfile=/var/run/mumble-server/__APP__.pid # The below will be used as defaults for new configured servers. # If you're just running one server (the default), it's easier to diff --git a/conf/systemd.service b/conf/systemd.service new file mode 100644 index 0000000..7f0e148 --- /dev/null +++ b/conf/systemd.service @@ -0,0 +1,15 @@ +[Unit] +Description=Mumble Server (Murmur, app __APP__) +Requires=network-online.target +After=network.target + +[Service] +User=mumble-server +Group=mumble-server +Type=forking +ExecStart=/usr/sbin/murmurd -ini __FINALPATH__/mumble-server.ini +PIDFile=/var/run/mumble-server/__APP__.pid +ExecReload=/bin/kill -s HUP $MAINPID + +[Install] +WantedBy=multi-user.target diff --git a/manifest.json b/manifest.json index fd6a149..41cd762 100644 --- a/manifest.json +++ b/manifest.json @@ -7,7 +7,7 @@ "fr": "Mumble est un logiciel libre de voix sur IP (VoIP), son principal usage étant la communication pendant les parties de jeux en réseau." }, "url": "https://mumble.info", - "license": "free", + "license": "BSD-3-Clause", "maintainer": { "name": "Moul", "email": "moul@moul.re" @@ -15,6 +15,7 @@ "requirements": { "yunohost": ">> 2.4.0" }, + "version": "1.2.8-1", "multi_instance": false, "services": [ ], diff --git a/scripts/install b/scripts/install index 41acbaf..4ffe185 100644 --- a/scripts/install +++ b/scripts/install @@ -32,9 +32,13 @@ registerName=$YNH_APP_ARG_REGISTERNAME # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +final_path=/var/www/$app +test ! -e "$final_path" || ynh_die "This path already contains a folder" + # Check port availability -if [[ ! $(yunohost app checkport "$port") -eq 0 ]]; then +yunohost app checkport "$port" +if [[ ! $? -eq 0 ]]; then ynh_die "Port is not available" fi @@ -75,50 +79,63 @@ ynh_install_app_dependencies mumble-server #================================================= # mumble server conf.ini #================================================= -# TODO: clean this + +mkdir -p "$final_path" +ynh_app_setting_set "$app" final_path "$final_path" # Configuring with given settings -mumble_conf="/etc/mumble-server.ini" +mumble_conf="$final_path/mumble-server.ini" cp ../conf/mumble-server.ini "$mumble_conf" +ynh_replace_string "__FINALPATH__" "$final_path" "$mumble_conf" +ynh_replace_string "__APP__" "$app" "$mumble_conf" ynh_replace_string "__WELCOME__" "$welcometext" "$mumble_conf" ynh_replace_string "__PORT__" "$port" "$mumble_conf" ynh_replace_string "__SRV_PWD__" "$server_password" "$mumble_conf" ynh_replace_string "__REGISTER__" "$registerName" "$mumble_conf" +#================================================= +# SETUP SYSTEMD +#================================================= + +# Create a dedicated systemd config +ynh_add_systemd_config + #================================================= # STORE THE CHECKSUM OF THE CONFIG FILE #================================================= -# TODO: add this checksum step ynh_store_file_checksum "$mumble_conf" #================================================= # Start services #================================================= -# Start Mumble server -/etc/init.d/mumble-server start - -# Set super-user password +mkdir -p /var/run/mumble-server/ murmurd -ini "$mumble_conf" -supw "$su_passwd" -# Restart Mumble server -/etc/init.d/mumble-server restart - #================================================= # GENERIC FINALIZATION #================================================= # SECURE FILES AND DIRECTORIES #================================================= -chmod 660 "$mumble_conf" -chown :mumble-server "$mumble_conf" +chmod -R 770 "$final_path" +chown -R :mumble-server "$final_path" + +#================================================= +# Disable default server installed by Debian's package +#================================================= + +systemctl stop mumble-server +systemctl disable mumble-server #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= # Add Mumble as a YunoHost service -yunohost service add mumble-server -l /var/log/mumble-server/mumble-server.log +yunohost service add "$app" -l "/var/log/mumble-server/$app.log" + +systemctl restart "$app" From 969facc313a9a6dbce377036d034748c8beea814 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Wed, 29 Nov 2017 23:33:33 +0100 Subject: [PATCH 05/13] Rewrite removal --- scripts/remove | 66 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 11 deletions(-) diff --git a/scripts/remove b/scripts/remove index 7488bca..32ef767 100644 --- a/scripts/remove +++ b/scripts/remove @@ -9,19 +9,63 @@ source _common.sh source /usr/share/yunohost/helpers -app=mumbleserver +#================================================= +# LOAD SETTINGS +#================================================= -# Getting port used by mumble to close it -port=$(ynh_app_setting_get $app port) +app=$YNH_APP_INSTANCE_NAME -# Uninstall Mumble and its dependencies -apt autoremove -y mumble-server > /dev/null 2>&1 +domain=$(ynh_app_setting_get "$app" domain) +port=$(ynh_app_setting_get "$app" port) +final_path=$(ynh_app_setting_get "$app" final_path) -# Close ports -yunohost firewall disallow Both $port > /dev/null 2>&1 +#================================================= +# STANDARD REMOVE +#================================================= +# STOP AND REMOVE SERVICE +#================================================= -# Removing config file -rm -f /etc/mumble-server.ini +# Remove the dedicated systemd config +ynh_remove_systemd_config -# Remove mumble-server service -yunohost service remove mumble-server +#================================================= +# REMOVE SERVICE FROM ADMIN PANEL +#================================================= + +if yunohost service status | grep -q "$app" +then + echo "Remove $app service" + yunohost service remove "$app" +fi + +#================================================= +# REMOVE DEPENDENCIES +#================================================= + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + +#================================================= +# REMOVE APP MAIN DIR +#================================================= + +# Remove the app directory securely +ynh_secure_remove "$final_path" + +#================================================= +# CLOSE A PORT +#================================================= + +if yunohost firewall list | grep -q "\- $port$" +then + echo "Close port $port" + yunohost firewall disallow Both "$port" > /dev/null 2>&1 +fi + +#================================================= +# SPECIFIC REMOVE +#================================================= +# REMOVE OTHER FILES +#================================================= + +ynh_secure_remove "/var/log/mumble-server/$app.log" From fc8639d23d7ce662f3f15bc88cd3247ee57074cf Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Mon, 4 Dec 2017 23:37:56 +0100 Subject: [PATCH 06/13] Add multi-install, remove port (sent by email), add helper --- check_process | 14 +++++--------- manifest.json | 13 ++----------- scripts/_common.sh | 31 +++++++++++++++++++++++++++++++ scripts/install | 31 ++++++++++++++++++++++--------- 4 files changed, 60 insertions(+), 29 deletions(-) diff --git a/check_process b/check_process index 31b9cf2..eb07c79 100644 --- a/check_process +++ b/check_process @@ -4,7 +4,6 @@ server_login_password="super_secret_password" (PASSWORD) password="super_secret_password" welcometext="Welcome to my mumble server" - port=64738 (PORT) registername="Root" ; Checks pkg_linter=1 @@ -13,16 +12,13 @@ setup_nourl=1 setup_private=0 setup_public=0 - upgrade=1 - backup_restore=1 - multi_instance=0 + upgrade=0 + backup_restore=0 + multi_instance=1 wrong_user=0 wrong_path=0 - incorrect_path=0 - corrupt_source=0 - fail_download_source=0 - port_already_use=1 - final_path_already_use=0 + incorrect_path=1 + port_already_use=0 ;;; Levels Level 1=auto Level 2=auto diff --git a/manifest.json b/manifest.json index 41cd762..142e335 100644 --- a/manifest.json +++ b/manifest.json @@ -13,10 +13,10 @@ "email": "moul@moul.re" }, "requirements": { - "yunohost": ">> 2.4.0" + "yunohost": ">> 2.7.0" }, "version": "1.2.8-1", - "multi_instance": false, + "multi_instance": true, "services": [ ], "arguments": { @@ -47,15 +47,6 @@ }, "example": "Welcome to my mumble server" }, - { - "name": "port", - "ask": { - "en": "Choose a port for your server. Let as default if you don't want to change it", - "fr": "Entrez un port pour votre serveur. Laissez par défaut si vous ne voulez pas en changer" - }, - "example": "64738", - "default": "64738" - }, { "name": "registername", "ask": { diff --git a/scripts/_common.sh b/scripts/_common.sh index 7a693aa..b938388 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,3 +1,34 @@ #!/bin/bash +send_readme_to_admin() { + app_message=$1 + if [[ -z $app_message ]]; then + ynh_die "Package shoud send basic info to the administrator" + fi + + # list domains, select second line and extract the domain + # ynh_domain=$(yunohost domain list | sed -e '1d' -e '2q' | cut -d' ' -f4) + # ynh_admin="admin@$ynh_domain" + + # list host, kernel, packages and system information + ynh_info=$(yunohost tools diagnosis | grep -B 100 "services:" | sed 's/services://') + + mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!" + mail_message=" + This is an automated message from your beloved YunoHost server. + + ----- + Specific information for this application ($app) + ----- + $app_message + + ----- + Automatic diagnosis data from YunoHost + ----- + $ynh_info + " + + # Email server admin - for ACTION + echo "$mail_message" | mail -s "$mail_subject" root -u root +} diff --git a/scripts/install b/scripts/install index 4ffe185..321e5e9 100644 --- a/scripts/install +++ b/scripts/install @@ -1,5 +1,7 @@ #!/bin/bash +# doc: https://wiki.mumble.info/wiki/Running_Murmur + #================================================= # GENERIC START #================================================= @@ -25,7 +27,6 @@ app=$YNH_APP_INSTANCE_NAME server_password=$YNH_APP_ARG_SERVER_LOGIN_PASSWORD su_passwd=$YNH_APP_ARG_PASSWORD welcometext=$YNH_APP_ARG_WELCOMETEXT -port=$YNH_APP_ARG_PORT registerName=$YNH_APP_ARG_REGISTERNAME #================================================= @@ -35,13 +36,6 @@ registerName=$YNH_APP_ARG_REGISTERNAME final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" -# Check port availability - -yunohost app checkport "$port" -if [[ ! $? -eq 0 ]]; then - ynh_die "Port is not available" -fi - # Check if su_password is not empty if [[ -z "$su_passwd" ]]; then ynh_die "Password is not set" @@ -52,7 +46,6 @@ fi #================================================= # Save app settings -ynh_app_setting_set "$app" port "$port" ynh_app_setting_set "$app" server_password "$server_password" ynh_app_setting_set "$app" su_passwd "$su_passwd" ynh_app_setting_set "$app" welcometext "$welcometext" @@ -64,6 +57,9 @@ ynh_app_setting_set "$app" registerName "$registerName" # FIND AND OPEN A PORT #================================================= +port=$(ynh_find_port 64738) +ynh_app_setting_set "$app" port "$port" + # Open port in firewall yunohost firewall allow Both "$port" @@ -115,6 +111,23 @@ ynh_store_file_checksum "$mumble_conf" mkdir -p /var/run/mumble-server/ murmurd -ini "$mumble_conf" -supw "$su_passwd" +#================================================= +# Start services +#================================================= +message=" +Port : $port +Password to join server: $server_password +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 : $mumble_conf + +Are you facing an issue, want to improve this app or say thank you? +Please open a new issue in this project: https://github.com/YunoHost-Apps/mumbleserver_ynh +" +send_readme_to_admin $message + #================================================= # GENERIC FINALIZATION #================================================= From 691b1abb774c7b927db4aced766d2e3099a2313a Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Sat, 9 Dec 2017 15:42:01 +0100 Subject: [PATCH 07/13] Add domain so mumble can use the one from domain + tiny fix for mail --- check_process | 1 + conf/mumble-server.ini | 4 ++-- manifest.json | 8 ++++++++ scripts/_common.sh | 18 +++++++++--------- scripts/install | 11 ++++++++++- 5 files changed, 30 insertions(+), 12 deletions(-) diff --git a/check_process b/check_process index eb07c79..ed6a303 100644 --- a/check_process +++ b/check_process @@ -1,6 +1,7 @@ ;; Test complet auto_remove=1 ; Manifest + domain="domain.tld" (DOMAIN) server_login_password="super_secret_password" (PASSWORD) password="super_secret_password" welcometext="Welcome to my mumble server" diff --git a/conf/mumble-server.ini b/conf/mumble-server.ini index e91f299..7111565 100644 --- a/conf/mumble-server.ini +++ b/conf/mumble-server.ini @@ -157,8 +157,8 @@ registerName=__REGISTER__ # If you have a proper SSL certificate, you can provide the filenames here. # Otherwise, Murmur will create it's own certificate automatically. -#sslCert= -#sslKey= +sslCert=/etc/yunohost/certs/__DOMAIN__/crt.pem +sslKey=/etc/yunohost/certs/__DOMAIN__/key.pem # If Murmur is started as root, which user should it switch to? # This option is ignored if Murmur isn't started with root privileges. diff --git a/manifest.json b/manifest.json index 142e335..5928468 100644 --- a/manifest.json +++ b/manifest.json @@ -21,6 +21,14 @@ ], "arguments": { "install" : [ + { + "name": "domain", + "type": "domain", + "ask": { + "en": "Choose a domain (used to select the correct certificate)" + }, + "example": "domain.org" + }, { "name": "server_login_password", "type": "password", diff --git a/scripts/_common.sh b/scripts/_common.sh index b938388..5ec091c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -16,17 +16,17 @@ send_readme_to_admin() { mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!" mail_message=" - This is an automated message from your beloved YunoHost server. +This is an automated message from your beloved YunoHost server. - ----- - Specific information for this application ($app) - ----- - $app_message +----- +Specific information for this application ($app) +----- +$app_message - ----- - Automatic diagnosis data from YunoHost - ----- - $ynh_info +----- +Automatic diagnosis data from YunoHost +----- +$ynh_info " # Email server admin - for ACTION diff --git a/scripts/install b/scripts/install index 321e5e9..890bc6b 100644 --- a/scripts/install +++ b/scripts/install @@ -23,6 +23,7 @@ ynh_abort_if_errors #================================================= # Retrieve arguments +domain=$YNH_APP_ARG_DOMAIN app=$YNH_APP_INSTANCE_NAME server_password=$YNH_APP_ARG_SERVER_LOGIN_PASSWORD su_passwd=$YNH_APP_ARG_PASSWORD @@ -46,6 +47,7 @@ fi #================================================= # Save app settings +ynh_app_setting_set "$app" domain "$domain" ynh_app_setting_set "$app" server_password "$server_password" ynh_app_setting_set "$app" su_passwd "$su_passwd" ynh_app_setting_set "$app" welcometext "$welcometext" @@ -90,6 +92,7 @@ ynh_replace_string "__WELCOME__" "$welcometext" "$mumble_conf" ynh_replace_string "__PORT__" "$port" "$mumble_conf" ynh_replace_string "__SRV_PWD__" "$server_password" "$mumble_conf" ynh_replace_string "__REGISTER__" "$registerName" "$mumble_conf" +ynh_replace_string "__DOMAIN__" "$domain" "$mumble_conf" #================================================= # SETUP SYSTEMD @@ -126,7 +129,7 @@ mumble configuration file : $mumble_conf Are you facing an issue, want to improve this app or say thank you? Please open a new issue in this project: https://github.com/YunoHost-Apps/mumbleserver_ynh " -send_readme_to_admin $message +send_readme_to_admin "$message" #================================================= # GENERIC FINALIZATION @@ -137,6 +140,12 @@ send_readme_to_admin $message chmod -R 770 "$final_path" chown -R :mumble-server "$final_path" +#================================================= +# Add user to ssl-cert so it can read certificates +#================================================= + +usermod --append --groups ssl-cert mumble-server + #================================================= # Disable default server installed by Debian's package #================================================= From eaa6733ca8eabb290dcc901734bbd47bad7c7e46 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Sat, 7 Apr 2018 13:51:22 +0200 Subject: [PATCH 08/13] upgrade ynh_send_readme_to_admin helper --- scripts/_common.sh | 66 ++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 5ec091c..12587b9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,34 +1,50 @@ #!/bin/bash -send_readme_to_admin() { - app_message=$1 +# Send an email to inform the administrator +# +# usage: ynh_send_readme_to_admin app_message [recipients] +# | arg: app_message - The message to send to the administrator. +# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root +# example: "root admin@domain" +# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you +# example: "root admin@domain user1 user2" +ynh_send_readme_to_admin() { + local app_message="${1:-...No specific information...}" + local recipients="${2:-root}" - if [[ -z $app_message ]]; then - ynh_die "Package shoud send basic info to the administrator" - fi + # Retrieve the email of users + find_mails () { + local list_mails="$1" + local mail + local recipients=" " + # Read each mail in argument + for mail in $list_mails + do + # Keep root or a real email address as it is + if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" + then + recipients="$recipients $mail" + else + # But replace an user name without a domain after by its email + if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) + then + recipients="$recipients $mail" + fi + fi + done + echo "$recipients" + } + recipients=$(find_mails "$recipients") - # list domains, select second line and extract the domain - # ynh_domain=$(yunohost domain list | sed -e '1d' -e '2q' | cut -d' ' -f4) - # ynh_admin="admin@$ynh_domain" + local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!" - # list host, kernel, packages and system information - ynh_info=$(yunohost tools diagnosis | grep -B 100 "services:" | sed 's/services://') - - mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!" - mail_message=" -This is an automated message from your beloved YunoHost server. - ------ -Specific information for this application ($app) ------ + local mail_message="This is an automated message from your beloved YunoHost server. +Specific information for the application $app. $app_message - ------ +--- Automatic diagnosis data from YunoHost ------ -$ynh_info - " +$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')" - # Email server admin - for ACTION - echo "$mail_message" | mail -s "$mail_subject" root -u root + # Send the email to the recipients + echo "$mail_message" | mail -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" } From e2a9c9f196577a8a260b63ac984184801055c7e2 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Sat, 7 Apr 2018 15:32:27 +0200 Subject: [PATCH 09/13] Add upgrade process --- check_process | 6 +- manifest.json | 4 +- scripts/install | 12 ++-- scripts/upgrade | 163 +++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 172 insertions(+), 13 deletions(-) diff --git a/check_process b/check_process index ed6a303..f1c9e87 100644 --- a/check_process +++ b/check_process @@ -13,12 +13,14 @@ setup_nourl=1 setup_private=0 setup_public=0 - upgrade=0 + upgrade=1 + # latest published in community.json + upgrade=1 from_commit=c3f4863564b17be1cb8193f6962668bcc0d92072 backup_restore=0 multi_instance=1 wrong_user=0 wrong_path=0 - incorrect_path=1 + incorrect_path=0 port_already_use=0 ;;; Levels Level 1=auto diff --git a/manifest.json b/manifest.json index 5928468..e075202 100644 --- a/manifest.json +++ b/manifest.json @@ -13,9 +13,9 @@ "email": "moul@moul.re" }, "requirements": { - "yunohost": ">> 2.7.0" + "yunohost": ">= 2.7.10" }, - "version": "1.2.8-1", + "version": "1.2.8-2", "multi_instance": true, "services": [ ], diff --git a/scripts/install b/scripts/install index 890bc6b..15c25b0 100644 --- a/scripts/install +++ b/scripts/install @@ -70,7 +70,7 @@ yunohost firewall allow Both "$port" #================================================= # Install Mumble Debian package via apt -ynh_install_app_dependencies mumble-server +ynh_install_app_dependencies mumble-server mailutils #================================================= # SPECIFIC SETUP @@ -94,6 +94,8 @@ ynh_replace_string "__SRV_PWD__" "$server_password" "$mumble_conf" ynh_replace_string "__REGISTER__" "$registerName" "$mumble_conf" ynh_replace_string "__DOMAIN__" "$domain" "$mumble_conf" +ynh_store_file_checksum "$mumble_conf" + #================================================= # SETUP SYSTEMD #================================================= @@ -101,12 +103,6 @@ ynh_replace_string "__DOMAIN__" "$domain" "$mumble_conf" # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# STORE THE CHECKSUM OF THE CONFIG FILE -#================================================= - -ynh_store_file_checksum "$mumble_conf" - #================================================= # Start services #================================================= @@ -129,7 +125,7 @@ mumble configuration file : $mumble_conf Are you facing an issue, want to improve this app or say thank you? Please open a new issue in this project: https://github.com/YunoHost-Apps/mumbleserver_ynh " -send_readme_to_admin "$message" +ynh_send_readme_to_admin "$message" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 27b6b28..c349cd5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -8,6 +8,167 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# LOAD SETTINGS +#================================================= + +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get "$app" domain) +server_password=$(ynh_app_setting_get "$app" server_password) +su_passwd=$(ynh_app_setting_get "$app" su_passwd) +welcometext=$(ynh_app_setting_get "$app" welcometext) +registerName=$(ynh_app_setting_get "$app" registerName) +port=$(ynh_app_setting_get "$app" port) +final_path=$(ynh_app_setting_get "$app" final_path) + +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= + +# If final_path doesn't exist, create it +if [ -z "$final_path" ]; then + final_path=/var/www/$app + ynh_app_setting_set "$app" final_path "$final_path" +fi + +# test old time +if [ -z "$server_password" ]; then + old_mumble_conf="/etc/mumble-server.ini" + + server_password=$(cat "$old_mumble_conf" \ + | grep "serverpassword=" \ + | sed "s/serverpassword=//") + + welcometext=$(cat "$old_mumble_conf" \ + | grep "welcometext=" \ + | sed "s/welcometext=//") + + registerName=$(cat "$old_mumble_conf" \ + | grep "registerName=" \ + | sed "s/registerName=//") + + ynh_app_setting_set "$app" server_password "$server_password" + ynh_app_setting_set "$app" welcometext "$welcometext" + ynh_app_setting_set "$app" registerName "$registerName" + + systemctl stop mumble-server + dpkg-reconfigure mumble-server --frontend=Noninteractiv + systemctl stop mumble-server + systemctl disable mumble-server +fi + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= + +# Backup the current version of the app +# ynh_backup_before_upgrade +# ynh_clean_setup () { + # restore it if the upgrade fails +# ynh_restore_upgradebackup +# } + +# Exit if an error occurs during the execution of the script ynh_abort_if_errors -ynh_die "There is no upgrade yet" +#================================================= +# STANDARD UPGRADE STEPS +#================================================= + +# source and user are provided by debian's package, no web interface + +#================================================= +# INSTALL DEPENDENCIES +#================================================= + +# Install Mumble Debian package via apt +ynh_install_app_dependencies mumble-server mailutils + +#================================================= +# SPECIFIC UPGRADE +#================================================= +# mumble server conf.ini +#================================================= + +mkdir -p $final_path + +# Configuring with given settings +mumble_conf="$final_path/mumble-server.ini" + +cp ../conf/mumble-server.ini "$mumble_conf" + +ynh_replace_string "__FINALPATH__" "$final_path" "$mumble_conf" +ynh_replace_string "__APP__" "$app" "$mumble_conf" +ynh_replace_string "__WELCOME__" "$welcometext" "$mumble_conf" +ynh_replace_string "__PORT__" "$port" "$mumble_conf" +ynh_replace_string "__SRV_PWD__" "$server_password" "$mumble_conf" +ynh_replace_string "__REGISTER__" "$registerName" "$mumble_conf" +ynh_replace_string "__DOMAIN__" "$domain" "$mumble_conf" + +ynh_store_file_checksum "$mumble_conf" + +#================================================= +# SETUP SYSTEMD +#================================================= + +# Create a dedicated systemd config +ynh_add_systemd_config + +#================================================= +# Start services +#================================================= + +mkdir -p /var/run/mumble-server/ +murmurd -ini "$mumble_conf" -supw "$su_passwd" + +#================================================= +# Start services +#================================================= + +message=" +Mumbleserver was updated! + +Port : $port +Password to join server: $server_password +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 : $mumble_conf + +Are you facing an issue, want to improve this app or say thank you? +Please open a new issue in this project: https://github.com/YunoHost-Apps/mumbleserver_ynh +" +ynh_send_readme_to_admin "$message" + +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + +chmod -R 770 "$final_path" +chown -R :mumble-server "$final_path" + +#================================================= +# Add user to ssl-cert so it can read certificates +#================================================= + +usermod --append --groups ssl-cert mumble-server + +#================================================= +# Disable default server installed by Debian's package +#================================================= + +systemctl stop mumble-server +systemctl disable mumble-server + +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +# Add Mumble as a YunoHost service +yunohost service add "$app" -l "/var/log/mumble-server/$app.log" + +systemctl restart "$app" From bc3ea3ad292179026dfce7c6e0e5b748dcb741a1 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Sat, 7 Apr 2018 15:51:07 +0200 Subject: [PATCH 10/13] add backup and restore --- check_process | 2 +- scripts/backup | 45 ++++++++++++++++++++++++ scripts/restore | 91 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 scripts/backup create mode 100644 scripts/restore diff --git a/check_process b/check_process index f1c9e87..13a646a 100644 --- a/check_process +++ b/check_process @@ -16,7 +16,7 @@ upgrade=1 # latest published in community.json upgrade=1 from_commit=c3f4863564b17be1cb8193f6962668bcc0d92072 - backup_restore=0 + backup_restore=1 multi_instance=1 wrong_user=0 wrong_path=0 diff --git a/scripts/backup b/scripts/backup new file mode 100644 index 0000000..bf8bc99 --- /dev/null +++ b/scripts/backup @@ -0,0 +1,45 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +if [ ! -e _common.sh ]; then + # Get the _common.sh file if it's not in the current directory + cp ../settings/scripts/_common.sh ./_common.sh + chmod a+rx _common.sh +fi +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + + +#================================================= +# LOAD SETTINGS +#================================================= + +app=$YNH_APP_INSTANCE_NAME + +final_path=$(ynh_app_setting_get $app final_path) + +#================================================= +# STANDARD BACKUP STEPS +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= + +ynh_backup "$final_path" + +#================================================= +# BACKUP SYSTEMD +#================================================= + +ynh_backup "/etc/systemd/system/$app.service" diff --git a/scripts/restore b/scripts/restore new file mode 100644 index 0000000..414c8c6 --- /dev/null +++ b/scripts/restore @@ -0,0 +1,91 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +if [ ! -e _common.sh ]; then + # Get the _common.sh file if it's not in the current directory + cp ../settings/scripts/_common.sh ./_common.sh + chmod a+rx _common.sh +fi +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= + +app=$YNH_APP_INSTANCE_NAME + +final_path=$(ynh_app_setting_get "$app" final_path) + +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= + +test ! -d "$final_path" \ + || ynh_die "There is already a directory: $final_path " + +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= + +ynh_restore_file "$final_path" + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= + +# Define and install dependencies +ynh_install_app_dependencies mumble-server mailutils + +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions on app files +chmod -R 770 "$final_path" +chown -R :mumble-server "$final_path" + +#================================================= +# Add user to ssl-cert so it can read certificates +#================================================= + +usermod --append --groups ssl-cert mumble-server + +#================================================= +# Disable default server installed by Debian's package +#================================================= + +systemctl stop mumble-server +systemctl disable mumble-server + +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +# Add Mumble as a YunoHost service +yunohost service add "$app" -l "/var/log/mumble-server/$app.log" + +#================================================= +# RESTORE SYSTEMD +#================================================= + +ynh_restore_file "/etc/systemd/system/$app.service" +systemctl enable "$app.service" + +systemctl restart "$app" From 2d9dec070c03521167b423e8b01af15ecd227ed0 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Sat, 7 Apr 2018 16:01:19 +0200 Subject: [PATCH 11/13] Remove password from manifest (generated) --- check_process | 2 -- manifest.json | 18 ------------------ scripts/install | 12 ++++-------- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/check_process b/check_process index 13a646a..f19ea2e 100644 --- a/check_process +++ b/check_process @@ -2,8 +2,6 @@ auto_remove=1 ; Manifest domain="domain.tld" (DOMAIN) - server_login_password="super_secret_password" (PASSWORD) - password="super_secret_password" welcometext="Welcome to my mumble server" registername="Root" ; Checks diff --git a/manifest.json b/manifest.json index e075202..a4adaba 100644 --- a/manifest.json +++ b/manifest.json @@ -29,24 +29,6 @@ }, "example": "domain.org" }, - { - "name": "server_login_password", - "type": "password", - "ask": { - "en": "Choose a password for your mumble server. This password is given to persons who want to join", - "fr": "Choisissez un mot de passe pour votre serveur Mumble. Ce mot de passe sera donné aux personnes qui veulent rejoindre le serveur" - }, - "example": "super_secret_password" - }, - { - "name": "password", - "type": "password", - "ask": { - "en": "Choose a password for the SuperUser. This is different from the server password and allows you to create the first admin.", - "fr": "Choisissez un mot de passe pour le SuperUser. Il est différent du mot de passe du serveur et permet de créer le premier Administrateur." - }, - "example": "super_secret_password" - }, { "name": "welcometext", "ask": { diff --git a/scripts/install b/scripts/install index 15c25b0..b9d0d28 100644 --- a/scripts/install +++ b/scripts/install @@ -25,11 +25,12 @@ ynh_abort_if_errors # Retrieve arguments domain=$YNH_APP_ARG_DOMAIN app=$YNH_APP_INSTANCE_NAME -server_password=$YNH_APP_ARG_SERVER_LOGIN_PASSWORD -su_passwd=$YNH_APP_ARG_PASSWORD welcometext=$YNH_APP_ARG_WELCOMETEXT registerName=$YNH_APP_ARG_REGISTERNAME +server_password=$(ynh_string_random) +su_passwd=$(ynh_string_random) + #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= @@ -37,17 +38,12 @@ registerName=$YNH_APP_ARG_REGISTERNAME final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" -# Check if su_password is not empty -if [[ -z "$su_passwd" ]]; then - ynh_die "Password is not set" -fi - #================================================= # STORE SETTINGS FROM MANIFEST #================================================= # Save app settings -ynh_app_setting_set "$app" domain "$domain" +ynh_app_setting_set "$app" domain "$domain" ynh_app_setting_set "$app" server_password "$server_password" ynh_app_setting_set "$app" su_passwd "$su_passwd" ynh_app_setting_set "$app" welcometext "$welcometext" From df3ad75d978ae56cbf0b250327eff3e9878609bc Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Sat, 7 Apr 2018 18:24:20 +0200 Subject: [PATCH 12/13] Change maintainer and improve readme --- README.md | 13 ++++++++++++- manifest.json | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c209948..4ad74d3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,18 @@ # Mumble server package for YunoHost -It install the Debian package and configures it with given settings. +It installs the Debian package and configures it with given settings. + +Password and other usefull information will be sent to you after installation. #### Setup - [Add the admin](http://wiki.mumble.info/wiki/Murmurguide#Connecting_to_Murmur_Server) + +#### Maintainers & history +---------------- + +2014: Package creation was maid by [matlink]](https://github.com/Matlink) + +2016: improved and maintained by [Moul](https://github.com/M5oul) + +2018: full rewrote and now maintained by [Jibec](https://github.com/Jibec) diff --git a/manifest.json b/manifest.json index a4adaba..44c9e28 100644 --- a/manifest.json +++ b/manifest.json @@ -9,8 +9,8 @@ "url": "https://mumble.info", "license": "BSD-3-Clause", "maintainer": { - "name": "Moul", - "email": "moul@moul.re" + "name": "jibec", + "email": "jean-baptiste@holcroft.fr" }, "requirements": { "yunohost": ">= 2.7.10" From 20d6d3d72c719a2540d881115ff2f94b1d6db163 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Sat, 7 Apr 2018 19:20:18 +0200 Subject: [PATCH 13/13] Fix domain and superuser password after upgrade --- scripts/upgrade | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index c349cd5..016b4ad 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -48,12 +48,22 @@ if [ -z "$server_password" ]; then | grep "registerName=" \ | sed "s/registerName=//") + # we don't know what the previous password was, let's regenerate it + su_passwd=$(ynh_string_random) + + domain=$(yunohost domain list \ + | grep "\- " \ + | head -1 \ + | sed -r "s/.* (([a-z])*\.([a-z])*).*/\1/g") + ynh_app_setting_set "$app" server_password "$server_password" ynh_app_setting_set "$app" welcometext "$welcometext" ynh_app_setting_set "$app" registerName "$registerName" + ynh_app_setting_set "$app" su_passwd "$su_passwd" + ynh_app_setting_set "$app" domain "$domain" systemctl stop mumble-server - dpkg-reconfigure mumble-server --frontend=Noninteractiv + dpkg-reconfigure mumble-server --frontend=Noninteractive systemctl stop mumble-server systemctl disable mumble-server fi