2018-05-11 21:38:56 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2021-04-16 14:14:27 +02:00
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
2019-04-03 14:35:09 +02:00
|
|
|
source ../settings/scripts/_common.sh
|
2018-05-11 21:38:56 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2019-04-12 16:58:46 +02:00
|
|
|
#=================================================
|
2021-04-16 14:14:27 +02:00
|
|
|
# RESTORE THE APP MAIN DIR
|
2019-04-12 16:58:46 +02:00
|
|
|
#=================================================
|
2022-10-04 00:13:33 +02:00
|
|
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
2019-04-12 16:58:46 +02:00
|
|
|
|
2023-03-24 12:21:19 +01:00
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
2019-04-12 16:58:46 +02:00
|
|
|
|
2023-03-24 12:21:19 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
2023-06-19 18:45:03 +02:00
|
|
|
chown -R $app:$app "$install_dir"
|
2019-04-12 16:58:46 +02:00
|
|
|
|
2018-05-11 21:38:56 +02:00
|
|
|
#=================================================
|
2021-08-04 23:53:34 +02:00
|
|
|
# RESTORE THE DATA DIRECTORY
|
2021-04-16 14:14:27 +02:00
|
|
|
#=================================================
|
2022-10-04 00:13:33 +02:00
|
|
|
ynh_script_progression --message="Restoring the data directory..." --weight=1
|
2021-04-16 14:14:27 +02:00
|
|
|
|
2023-03-30 22:54:26 +02:00
|
|
|
ynh_restore_file --origin_path="$data_dir/" --not_mandatory
|
2021-04-16 14:14:27 +02:00
|
|
|
|
2023-03-31 13:19:41 +02:00
|
|
|
mkdir -p $data_dir/data
|
2023-06-19 19:00:07 +02:00
|
|
|
mkdir -p $data_dir/data/{static,media,music}
|
2021-04-16 14:14:27 +02:00
|
|
|
|
2023-03-30 22:54:26 +02:00
|
|
|
chmod 750 "$data_dir/"
|
|
|
|
chmod -R o-rwx "$data_dir/"
|
2023-06-19 18:45:03 +02:00
|
|
|
chown -R $app:$app "$data_dir/"
|
2021-04-16 14:14:27 +02:00
|
|
|
|
2022-10-04 00:13:33 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
2018-05-11 21:38:56 +02:00
|
|
|
#=================================================
|
2019-04-03 14:35:09 +02:00
|
|
|
# RESTORE THE POSTGRESQL DATABASE
|
2018-05-11 21:38:56 +02:00
|
|
|
#=================================================
|
2023-03-24 12:31:51 +01:00
|
|
|
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
|
2018-05-11 21:38:56 +02:00
|
|
|
|
2021-04-16 14:14:27 +02:00
|
|
|
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
|
2018-05-11 21:38:56 +02:00
|
|
|
|
2023-06-19 20:29:40 +02:00
|
|
|
#=================================================
|
|
|
|
# LOGROTATE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring logrotate to manage application logfiles" --weight=1
|
|
|
|
|
|
|
|
# Use logrotate to manage application logfile(s)
|
|
|
|
ynh_use_logrotate --specific_user=$app
|
|
|
|
touch /var/log/$app/${app}-server.log
|
|
|
|
touch /var/log/$app/${app}-worker.log
|
|
|
|
touch /var/log/$app/${app}-beat.log
|
|
|
|
chown -R $app:$app /var/log/$app/
|
|
|
|
|
2018-05-11 21:38:56 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE SYSTEMD
|
|
|
|
#=================================================
|
2022-10-04 00:13:33 +02:00
|
|
|
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
2018-05-11 21:38:56 +02:00
|
|
|
|
2021-04-16 14:14:27 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/${app}-beat.service"
|
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/${app}-server.service"
|
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/${app}-worker.service"
|
2019-05-14 22:55:26 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.target"
|
2018-05-11 21:38:56 +02:00
|
|
|
|
2021-04-16 14:14:27 +02:00
|
|
|
systemctl enable "${app}-beat.service" --quiet
|
|
|
|
systemctl enable "${app}-server.service" --quiet
|
|
|
|
systemctl enable "${app}-worker.service" --quiet
|
2018-05-11 21:38:56 +02:00
|
|
|
|
2019-02-17 08:06:04 +01:00
|
|
|
#=================================================
|
2021-04-16 14:14:27 +02:00
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
2019-02-17 08:06:04 +01:00
|
|
|
#=================================================
|
2022-10-04 00:13:33 +02:00
|
|
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
2019-02-17 08:06:04 +01:00
|
|
|
|
2023-06-19 20:42:36 +02:00
|
|
|
ynh_add_systemd_config --service="${app}-server" --template="funkwhale-server.service" --log="/var/log/__APP__/__APP__-server.log"
|
|
|
|
ynh_add_systemd_config --service="${app}-worker" --template="funkwhale-worker.service" --log="/var/log/__APP__/__APP__-worker.log"
|
|
|
|
ynh_add_systemd_config --service="${app}-beat" --template="funkwhale-beat.service" --log="/var/log/__APP__/__APP__-beat.log"
|
2019-02-17 08:06:04 +01:00
|
|
|
|
2018-05-11 21:38:56 +02:00
|
|
|
#=================================================
|
2019-05-14 22:55:26 +02:00
|
|
|
# START SYSTEMD SERVICE
|
2018-05-11 21:38:56 +02:00
|
|
|
#=================================================
|
2022-10-04 00:13:33 +02:00
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
2019-04-03 14:35:09 +02:00
|
|
|
|
2022-04-28 01:15:33 +02:00
|
|
|
ynh_systemd_action --service_name="${app}-beat" --action="start" --log_path="systemd" --line_match="Started"
|
2021-04-16 14:14:27 +02:00
|
|
|
ynh_systemd_action --service_name="${app}-server" --action="start" --log_path="systemd" --line_match="Application startup complete"
|
2022-04-28 01:15:33 +02:00
|
|
|
ynh_systemd_action --service_name="${app}-worker" --action="start" --log_path="systemd" --line_match="ready"
|
2019-04-03 14:35:09 +02:00
|
|
|
|
2019-04-12 15:47:49 +02:00
|
|
|
#=================================================
|
2019-05-14 22:55:26 +02:00
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
2019-04-12 15:47:49 +02:00
|
|
|
#=================================================
|
2022-10-04 00:13:33 +02:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
2019-04-12 15:47:49 +02:00
|
|
|
|
2019-05-14 22:55:26 +02:00
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
2019-04-12 15:47:49 +02:00
|
|
|
|
2019-04-03 14:35:09 +02:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2022-10-04 00:13:33 +02:00
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|