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
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring the app files..." --weight=1
|
|
|
|
ynh_restore
|
2018-02-25 21:45:24 +01:00
|
|
|
|
2023-09-09 11:17:52 +02:00
|
|
|
# Also sets the permissions
|
|
|
|
_gitea_mkdirs
|
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
|
|
|
#=================================================
|
2023-09-09 11:17:52 +02:00
|
|
|
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
|
2018-02-25 21:45:24 +01:00
|
|
|
|
2023-09-09 11:17:52 +02:00
|
|
|
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
|
2018-02-25 21:45:24 +01:00
|
|
|
|
2023-09-09 11:17:52 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE SYSTEM CONFIGURATIONS
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
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
|
2019-09-10 22:43:45 +02:00
|
|
|
ynh_script_progression --message="Configuring fail2ban..."
|
2019-09-07 11:05:06 +02:00
|
|
|
ynh_add_fail2ban_config --logpath "/var/log/$app/gitea.log" --failregex ".*Failed authentication attempt for .* from <HOST>" --max_retry 5
|
2019-02-03 15:05:38 +01:00
|
|
|
|
2018-02-25 21:45:24 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
2023-09-09 11:17:52 +02:00
|
|
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
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...
|
|
|
|
ynh_systemd_action -l "Starting new Web server: tcp:127.0.0.1:" -t 10
|
2018-02-25 21:45:24 +01:00
|
|
|
|
2023-09-09 11:17:52 +02:00
|
|
|
ynh_systemd_action --service_name=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
|
|
|
|
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|