[mod] backup script rewritten (inspired and adpated from example_ynh).
Currently neither backup nor restore are useful but are safe enough to not break the upgrade script. That's what matters for now.
This commit is contained in:
parent
76eacf55fa
commit
681fe2b58c
@ -6,6 +6,20 @@
|
|||||||
pkg_dependencies="php5-fpm sipcalc dnsutils openvpn curl fake-hwclock"
|
pkg_dependencies="php5-fpm sipcalc dnsutils openvpn curl fake-hwclock"
|
||||||
|
|
||||||
|
|
||||||
|
# Experimental helpers
|
||||||
|
# Cf. https://github.com/YunoHost-Apps/Experimental_helpers/blob/72b0bc77c68d4a4a2bf4e95663dbc05e4a762a0a/ynh_read_manifest/ynh_read_manifest
|
||||||
|
read_json () {
|
||||||
|
sudo python3 -c "import sys, json;print(json.load(open('$1'))['$2'])"
|
||||||
|
}
|
||||||
|
read_manifest () {
|
||||||
|
if [ -f '../manifest.json' ] ; then
|
||||||
|
read_json '../manifest.json' "$1"
|
||||||
|
else
|
||||||
|
read_json '../settings/manifest.json' "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Helper to start/stop/.. a systemd service from a yunohost context,
|
# Helper to start/stop/.. a systemd service from a yunohost context,
|
||||||
# *and* the systemd service itself needs to be able to run yunohost
|
# *and* the systemd service itself needs to be able to run yunohost
|
||||||
# commands.
|
# commands.
|
||||||
|
@ -1,16 +1,61 @@
|
|||||||
#!/bin/bash
|
#!/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
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_abort_if_errors # Stop script if an error is detected
|
ynh_abort_if_errors # Stop script if an error is detected
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
backup_dir="${1}/apps/vpnclient"
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
mkdir -p "${backup_dir}/"
|
|
||||||
|
|
||||||
sudo cp -a /etc/openvpn/keys/ "${backup_dir}/"
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
sudo cp -a /etc/openvpn/client.conf.tpl "${backup_dir}/"
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD BACKUP STEPS
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup "$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup "/etc/nginx/conf.d/$domain.d/${app}.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE PHP-FPM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC BACKUP
|
||||||
|
#=================================================
|
||||||
|
# BACKUP SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup "/etc/systemd/system/ynh-$app.service" # XXX maybe hard-coding the full name would be better
|
||||||
|
ynh_backup "/etc/systemd/system/ynh-$app-checker.service" # XXX maybe hard-coding the full name would be better
|
||||||
|
ynh_backup "/etc/systemd/system/ynh-$app-checker.timer" # XXX maybe hard-coding the full name would be better
|
||||||
|
|
||||||
|
@ -38,6 +38,13 @@ if [ -f /etc/php5/fpm/pool.d/vpnadmin.conf ]; then
|
|||||||
fi
|
fi
|
||||||
test -d /var/www/vpnadmin && mv /var/www/vpnadmin /var/www/${app}
|
test -d /var/www/vpnadmin && mv /var/www/vpnadmin /var/www/${app}
|
||||||
|
|
||||||
|
# Versions known to have a buggy backup script
|
||||||
|
buggy_versions="1.0.0 1.0.1 1.1.0"
|
||||||
|
curr_version=$(read_manifest version)
|
||||||
|
if echo $buggy_versions | grep -w $curr_version > /dev/null; then
|
||||||
|
echo "Your current version of ${app} is very old: ${curr_version}. Please ignore the next warning." >&2
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
Loading…
x
Reference in New Issue
Block a user