2018-02-25 21:45:24 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
|
2020-11-17 23:33:50 +01:00
|
|
|
# Load common variables and helpers
|
|
|
|
source ../settings/scripts/_common.sh
|
2018-02-25 21:45:24 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2023-09-09 11:17:52 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE APP MAIN DIR
|
|
|
|
#=================================================
|
2024-08-30 22:57:28 +02:00
|
|
|
ynh_script_progression "Restoring the app files..."
|
|
|
|
ynh_restore_everything
|
2023-11-29 10:58:11 +01:00
|
|
|
_set_permissions
|
2018-02-25 21:45:24 +01:00
|
|
|
|
|
|
|
#=================================================
|
2023-09-09 11:17:52 +02:00
|
|
|
# RESTORE THE MYSQL DATABASE
|
2018-02-25 21:45:24 +01:00
|
|
|
#=================================================
|
2024-08-30 22:57:28 +02:00
|
|
|
ynh_script_progression "Restoring the MySQL database..."
|
2018-02-25 21:45:24 +01:00
|
|
|
|
2024-08-30 22:57:28 +02:00
|
|
|
ynh_mysql_db_shell < ./db.sql
|
2018-02-25 21:45:24 +01:00
|
|
|
|
2023-09-09 11:17:52 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE SYSTEM CONFIGURATIONS
|
|
|
|
#=================================================
|
2024-08-30 22:57:28 +02:00
|
|
|
ynh_script_progression "Restoring system configurations related to $app..."
|
2018-02-25 21:45:24 +01:00
|
|
|
|
|
|
|
systemctl daemon-reload
|
2020-12-08 22:06:19 +01:00
|
|
|
systemctl enable "$app".service --quiet
|
2018-02-25 21:45:24 +01:00
|
|
|
|
2023-09-09 11:17:52 +02:00
|
|
|
yunohost service add "$app" --log="/var/log/$app/gitea.log"
|
|
|
|
|
2019-02-03 15:05:38 +01:00
|
|
|
# SETUP FAIL2BAN
|
2024-08-30 22:57:28 +02:00
|
|
|
ynh_script_progression "Configuring fail2ban..."
|
|
|
|
ynh_config_add_fail2ban --logpath="/var/log/$app/gitea.log" --failregex=".*Failed authentication attempt for .* from <HOST>"
|
2019-02-03 15:05:38 +01:00
|
|
|
|
2024-08-31 09:56:13 +02:00
|
|
|
mkdir -p /var/log/"$app"
|
|
|
|
ynh_config_add_logrotate
|
|
|
|
|
2018-02-25 21:45:24 +01:00
|
|
|
#=================================================
|
2023-09-09 11:17:52 +02:00
|
|
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
|
|
|
#=================================================
|
2024-08-30 22:57:28 +02:00
|
|
|
ynh_script_progression "Reloading NGINX web server and $app's service..."
|
2018-02-25 21:45:24 +01:00
|
|
|
|
2023-09-09 11:17:52 +02:00
|
|
|
# Typically you only have either $app or php-fpm but not both at the same time...
|
2024-08-30 22:57:28 +02:00
|
|
|
ynh_systemctl --service="$app" --action=start --log_path="/var/log/$app/gitea.log" --wait_until="$systemd_match_start_line"
|
2018-02-25 21:45:24 +01:00
|
|
|
|
2024-08-30 22:57:28 +02:00
|
|
|
ynh_systemctl --service=nginx --action=reload
|
2018-02-25 21:45:24 +01:00
|
|
|
|
2023-09-09 11:17:52 +02:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2019-10-27 14:54:35 +01:00
|
|
|
|
2024-08-30 22:57:28 +02:00
|
|
|
ynh_script_progression "Restoration completed for $app"
|