1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/zwave-js-ui_ynh.git synced 2024-09-03 18:06:00 +02:00
zwave-js-ui_ynh/scripts/restore

90 lines
3.1 KiB
Text
Raw Normal View History

2022-11-13 11:25:39 +01:00
#!/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
2022-11-26 18:26:31 +01:00
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
2022-11-25 11:15:42 +01:00
#=================================================
# INSTALL EXTRA DEPENDENCIES
#=================================================
2023-02-24 00:06:37 +01:00
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=15
2022-11-25 11:15:42 +01:00
2023-05-07 15:08:57 +02:00
#ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
#ynh_use_nodejs
#ynh_exec_warn_less $ynh_npm install ---global yarn
2022-11-25 11:15:42 +01:00
2022-11-13 11:25:39 +01:00
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
2023-02-24 00:06:37 +01:00
ynh_restore_file --origin_path="$install_dir"
2022-11-13 11:25:39 +01:00
# FIXME: this should be managed by the core in the future
# Here, as a packager, you may have to tweak the ownerhsip/permissions
# such that the appropriate users (e.g. maybe www-data) can access
# files in some cases.
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
# this will be treated as a security issue.
2023-02-24 00:06:37 +01:00
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app: "$install_dir"
2022-11-13 11:25:39 +01:00
2023-02-24 00:06:37 +01:00
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
2022-11-13 11:25:39 +01:00
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"
2022-11-19 17:37:14 +01:00
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"
2022-11-13 11:25:39 +01:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
2022-11-25 23:21:29 +01:00
ynh_systemd_action --service_name=$app --action="start" --line_match="Listening on port" -t 30 --log_path="/var/log/$app/$app.log"
2022-11-13 11:25:39 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
2022-11-13 11:25:39 +01:00
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last