1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/forgejo_ynh.git synced 2024-09-03 18:36:26 +02:00
forgejo_ynh/scripts/restore

103 lines
3.8 KiB
Text
Raw Normal View History

2023-01-05 14:48:22 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2023-01-05 14:48:22 +01:00
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
2023-01-05 14:48:22 +01:00
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
2023-01-05 14:48:22 +01:00
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring $app main directory..." --weight=10
2023-01-05 14:48:22 +01:00
2023-03-10 17:13:54 +01:00
ynh_restore_file --origin_path="$install_dir"
2023-01-05 14:48:22 +01:00
2023-03-10 17:13:54 +01:00
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
2023-01-05 14:48:22 +01:00
#=================================================
# RESTORE THE DATA DIRECTORY
2023-01-05 14:48:22 +01:00
#=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1
2023-01-05 14:48:22 +01:00
2023-03-10 17:13:54 +01:00
ynh_restore_file --origin_path="$data_dir" --not_mandatory
2023-01-05 14:48:22 +01:00
2023-03-10 17:13:54 +01:00
chown -R $app:$app "$data_dir"
2023-01-05 14:48:22 +01:00
#=================================================
# RESTORE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=1
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban
#=================================================
# RESTORE THE DATABASE
#=================================================
ynh_script_progression --message="Restoring the database..." --weight=6
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=5
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
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
ynh_restore_file --origin_path="/var/log/$app"
chown -R $app:$app "/var/log/$app"
chmod u=rwX,g=rX,o= "/var/log/$app"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Forgejo" --log="/var/log/$app/forgejo.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=3
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/forgejo.log" --line_match="Starting new Web server: tcp:127.0.0.1:"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
2023-01-05 14:48:22 +01:00
ynh_script_progression --message="Restoration completed for $app" --last