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

66 lines
2.7 KiB
Text
Raw Normal View History

2022-02-28 23:39:48 +01:00
#!/bin/bash
2022-03-02 04:02:38 +01:00
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2022-02-28 23:39:48 +01:00
2022-03-02 04:02:38 +01:00
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
2022-02-28 23:39:48 +01:00
2022-03-02 04:02:38 +01:00
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..."
2024-01-10 12:50:39 +01:00
ynh_restore_file --origin_path="$install_dir"
2022-03-02 04:02:38 +01:00
2024-01-10 12:50:39 +01:00
chmod -R o-rwx "$install_dir"
2024-03-22 15:16:28 +01:00
chown -R "$app:www-data" "$install_dir"
2022-03-02 04:02:38 +01:00
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
2024-01-10 12:50:39 +01:00
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
2022-03-02 04:02:38 +01:00
2024-03-22 17:45:41 +01:00
# ynh_psql_execute_as_root --sql="CREATE DATABASE ${db_name} WITH OWNER ${db_user} TEMPLATE template0 ENCODING 'UTF8';"
ynh_psql_execute_as_root --sql="CREATE DATABASE ${db_name}olap WITH OWNER ${db_user} TEMPLATE template0 ENCODING 'UTF8';"
ynh_psql_execute_as_root --sql="CREATE DATABASE ${db_name}tenant WITH OWNER ${db_user} TEMPLATE template0 ENCODING 'UTF8';"
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="${db_name}" < ./db.sql
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="${db_name}olap" < ./dbolap.sql
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="${db_name}tenant" < ./dbtenant.sql
2022-03-02 04:02:38 +01:00
#=================================================
2024-03-22 15:16:28 +01:00
# RESTORE SYSTEM CONFIGURATIONS
2022-03-02 04:02:38 +01:00
#=================================================
2024-03-22 15:16:28 +01:00
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
2022-03-02 04:02:38 +01:00
2024-01-10 12:50:39 +01:00
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
2022-03-02 04:02:38 +01:00
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
2024-03-22 15:16:28 +01:00
systemctl enable "$app.service" --quiet
yunohost service add "$app" --log="/var/log/$app/$app.log"
2022-03-02 04:02:38 +01:00
2024-03-22 15:16:28 +01:00
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
2022-03-02 04:02:38 +01:00
#=================================================
2024-03-22 15:16:28 +01:00
# RESTORE VARIOUS FILES
#=================================================
ynh_restore_file --origin_path="/var/log/$app/"
2022-03-02 04:02:38 +01:00
#=================================================
2024-01-10 12:50:39 +01:00
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
2022-03-02 04:02:38 +01:00
#=================================================
2024-01-10 12:50:39 +01:00
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
2024-03-22 15:16:28 +01:00
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" --line_match="is started and ready"
2022-03-02 04:02:38 +01:00
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app"