88 lines
2.9 KiB
Bash
Executable file
88 lines
2.9 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
|
source ../settings/scripts/_common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# RESTORE THE CONFIG DIR
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring the config directory..." --weight=1
|
|
|
|
ynh_restore_file --origin_path="$config_path"
|
|
|
|
mkdir -p $config_path
|
|
mkdir -p $config_path/{certs,conf.avail,conf.d}
|
|
|
|
#ln -s $config_path/conf.avail/localhost.cfg.lua $config_path/conf.d/
|
|
|
|
chown root:root "$config_path"
|
|
chmod 755 "$config_path"
|
|
|
|
chown root:$app "$config_path/conf.d"
|
|
chmod 754 "$config_path/conf.d"
|
|
|
|
chown root:$app "$config_path/conf.avail"
|
|
chmod 754 "$config_path/conf.avail"
|
|
|
|
chown root:$app "$config_path/certs"
|
|
chmod 750 "$config_path/certs"
|
|
|
|
#=================================================
|
|
# RESTORE THE DATA DIRECTORY
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring the data directory..." --weight=1
|
|
|
|
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
|
ynh_restore_file --origin_path="/var/lib/$app" --not_mandatory
|
|
|
|
chown -R $app:$app "$data_dir"
|
|
chown -R $app:$app "/var/lib/$app"
|
|
|
|
#=================================================
|
|
# RESTORE SYSTEMD
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
|
systemctl enable $app.service --quiet
|
|
|
|
#=================================================
|
|
# RESTORE THE LOGROTATE CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
|
|
|
|
mkdir -p "/var/log/$app"
|
|
chmod 750 "/var/log/$app"
|
|
chmod -R o-rwx "/var/log/$app"
|
|
chown -R $app:adm "/var/log/$app"
|
|
|
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
|
|
|
#=================================================
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
#=================================================
|
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
|
|
|
yunohost service add $app --log="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|