mirror of
https://github.com/YunoHost-Apps/zwave-js-ui_ynh.git
synced 2024-09-03 18:06:00 +02:00
75 lines
2.4 KiB
Bash
Executable file
75 lines
2.4 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
|
|
|
|
|
|
#=================================================
|
|
# RECREATE THE DEDICATED USER
|
|
#=================================================
|
|
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
|
|
|
if grep dialout -q < /etc/group; then
|
|
usermod -a -G dialout "$app"
|
|
fi
|
|
if grep i2c -q < /etc/group; then
|
|
usermod -a -G i2c "$app"
|
|
fi
|
|
if grep gpio -q < /etc/group; then
|
|
usermod -a -G gpio "$app"
|
|
fi
|
|
|
|
|
|
#=================================================
|
|
# RESTORE THE APP MAIN DIR
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
|
|
|
chmod 750 "$install_dir"
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app: "$install_dir"
|
|
|
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
|
systemctl enable $app.service --quiet
|
|
|
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
|
|
|
mkdir -p /var/log/$app
|
|
chown -R $app:$app /var/log/$app
|
|
|
|
yunohost service add $app --description="Zwave integration in domoticz" --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" --line_match="Listening on port" -t 30 --log_path="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
# RELOAD NGINX AND PHP-FPM
|
|
#=================================================
|
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|