1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mumbleserver_ynh.git synced 2024-09-03 19:46:03 +02:00

Add upgrade process

This commit is contained in:
Jean-Baptiste Holcroft 2018-04-07 15:32:27 +02:00
parent eaa6733ca8
commit e2a9c9f196
4 changed files with 172 additions and 13 deletions

View file

@ -13,12 +13,14 @@
setup_nourl=1 setup_nourl=1
setup_private=0 setup_private=0
setup_public=0 setup_public=0
upgrade=0 upgrade=1
# latest published in community.json
upgrade=1 from_commit=c3f4863564b17be1cb8193f6962668bcc0d92072
backup_restore=0 backup_restore=0
multi_instance=1 multi_instance=1
wrong_user=0 wrong_user=0
wrong_path=0 wrong_path=0
incorrect_path=1 incorrect_path=0
port_already_use=0 port_already_use=0
;;; Levels ;;; Levels
Level 1=auto Level 1=auto

View file

@ -13,9 +13,9 @@
"email": "moul@moul.re" "email": "moul@moul.re"
}, },
"requirements": { "requirements": {
"yunohost": ">> 2.7.0" "yunohost": ">= 2.7.10"
}, },
"version": "1.2.8-1", "version": "1.2.8-2",
"multi_instance": true, "multi_instance": true,
"services": [ "services": [
], ],

View file

@ -70,7 +70,7 @@ yunohost firewall allow Both "$port"
#================================================= #=================================================
# Install Mumble Debian package via apt # Install Mumble Debian package via apt
ynh_install_app_dependencies mumble-server ynh_install_app_dependencies mumble-server mailutils
#================================================= #=================================================
# SPECIFIC SETUP # 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 "__REGISTER__" "$registerName" "$mumble_conf"
ynh_replace_string "__DOMAIN__" "$domain" "$mumble_conf" ynh_replace_string "__DOMAIN__" "$domain" "$mumble_conf"
ynh_store_file_checksum "$mumble_conf"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
@ -101,12 +103,6 @@ ynh_replace_string "__DOMAIN__" "$domain" "$mumble_conf"
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================
ynh_store_file_checksum "$mumble_conf"
#================================================= #=================================================
# Start services # 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? 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 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 # GENERIC FINALIZATION

View file

@ -8,6 +8,167 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers 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_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"