1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mumbleserver_ynh.git synced 2024-09-03 19:46:03 +02:00
mumbleserver_ynh/scripts/upgrade
2023-12-28 15:27:48 +01:00

142 lines
4.7 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/mumble-server/$app.log"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# 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=//")
# 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=$app --key=server_password --value=$server_password
ynh_app_setting_set --app=$app --key=welcometext --value=$welcometext
ynh_app_setting_set --app=$app --key=registername --value=$registername
ynh_app_setting_set --app=$app --key=su_passwd --value=$su_passwd
systemctl stop mumble-server
dpkg-reconfigure mumble-server --frontend=Noninteractive
systemctl stop mumble-server
systemctl disable mumble-server --quiet
fi
# Fix SSO issue
# https://github.com/YunoHost-Apps/mumbleserver_ynh/issues/19
if [ -z "${no_sso:-}" ]; then
ynh_app_setting_set --app="$app" --key=no_sso --value="true"
fi
# Fix multi installation
if [ -z "${instance_id:-}" ]; then
instance_id=$YNH_APP_INSTANCE_NUMBER
ynh_app_setting_set --app="$app" instance_id --value="$instance_id"
fi
if [ -z "${registername:-}" ]; then
registername=$(ynh_app_setting_get "$app" registerName)
ynh_app_setting_set --app="$app" --key=registername --value="$registername"
ynh_app_setting_delete "$app" registerName
fi
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1
mkdir -p $install_dir
ynh_add_config --template="mumble-server.ini" --destination="$install_dir/mumble-server.ini"
chmod -R 770 "$install_dir"
chown -R :mumble-server "$install_dir"
#=================================================
# Add user to ssl-cert so it can read certificates
#=================================================
usermod --append --groups ssl-cert mumble-server
#=================================================
# Set SuperUser password
#=================================================
# || true temporarily to ignore a bug in murmurd 1.3.0
# https://github.com/mumble-voip/mumble/issues/3911
#murmurd -ini "$install_dir/mumble-server.ini" -supw "$su_passwd" "$instance_id" || true
#=================================================
# Disable default server installed by Debian's package
#=================================================
systemctl stop mumble-server
systemctl disable mumble-server --quiet
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
# Create a dedicated systemd config
ynh_add_systemd_config
# Add Mumble as a YunoHost service
yunohost service add $app --description="Mumble server" --log="/var/log/mumble-server/$app.log" --needs_exposed_ports="$port"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=3
ynh_systemd_action --service_name=$app --action=restart --log_path="/var/log/mumble-server/$app.log"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last