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

add backup and restore

This commit is contained in:
Jean-Baptiste Holcroft 2018-04-07 15:51:07 +02:00
parent e2a9c9f196
commit bc3ea3ad29
3 changed files with 137 additions and 1 deletions

View file

@ -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

45
scripts/backup Normal file
View file

@ -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"

91
scripts/restore Normal file
View file

@ -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"