2018-05-11 21:38:56 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
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
|
|
|
#=================================================
|
2024-09-01 22:25:43 +02:00
|
|
|
ynh_script_progression "Restoring the app main directory..."
|
2019-04-12 16:58:46 +02:00
|
|
|
|
2024-09-01 22:25:43 +02:00
|
|
|
ynh_restore "$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
|
|
|
#=================================================
|
2024-09-01 22:25:43 +02:00
|
|
|
ynh_script_progression "Restoring the data directory..."
|
2021-04-16 14:14:27 +02:00
|
|
|
|
2024-09-01 22:25:43 +02:00
|
|
|
ynh_restore "$data_dir/" || true
|
2021-04-16 14:14:27 +02:00
|
|
|
|
2023-03-31 13:19:41 +02:00
|
|
|
mkdir -p $data_dir/data
|
2023-06-20 10:44:18 +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 -R o-rwx "$data_dir/"
|
2023-06-20 18:27:53 +02:00
|
|
|
chown -R $app:www-data "$data_dir/"
|
2021-04-16 14:14:27 +02:00
|
|
|
|
2022-10-04 00:13:33 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2024-09-01 22:25:43 +02:00
|
|
|
ynh_script_progression "Restoring the NGINX web server configuration..."
|
2022-10-04 00:13:33 +02:00
|
|
|
|
2024-09-01 22:25:43 +02:00
|
|
|
ynh_restore "/etc/nginx/conf.d/$domain.d"
|
2022-10-04 00:13:33 +02:00
|
|
|
|
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
|
|
|
#=================================================
|
2024-09-01 22:25:43 +02:00
|
|
|
ynh_script_progression "Restoring the PostgreSQL database..."
|
2018-05-11 21:38:56 +02:00
|
|
|
|
2024-09-01 22:25:43 +02:00
|
|
|
ynh_psql_db_shell < "./db.sql"
|
2018-05-11 21:38:56 +02:00
|
|
|
|
2023-06-20 10:44:18 +02:00
|
|
|
#=================================================
|
|
|
|
# LOGROTATE
|
|
|
|
#=================================================
|
2024-09-01 22:25:43 +02:00
|
|
|
ynh_script_progression "Configuring logrotate to manage application logfiles"
|
|
|
|
|
|
|
|
ynh_config_add_logrotate
|
2023-06-20 10:44:18 +02:00
|
|
|
|
|
|
|
touch /var/log/$app/${app}-server.log
|
|
|
|
touch /var/log/$app/${app}-worker.log
|
|
|
|
touch /var/log/$app/${app}-beat.log
|
|
|
|
|
2018-05-11 21:38:56 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE SYSTEMD
|
|
|
|
#=================================================
|
2024-09-01 22:25:43 +02:00
|
|
|
ynh_script_progression "Restoring $app's systemd service..."
|
2018-05-11 21:38:56 +02:00
|
|
|
|
2024-09-01 22:25:43 +02:00
|
|
|
ynh_restore "/etc/systemd/system/${app}-beat.service"
|
|
|
|
ynh_restore "/etc/systemd/system/${app}-server.service"
|
|
|
|
ynh_restore "/etc/systemd/system/${app}-worker.service"
|
|
|
|
ynh_restore "/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
|
|
|
#=================================================
|
2024-09-01 22:25:43 +02:00
|
|
|
ynh_script_progression "Integrating service in YunoHost..."
|
2019-02-17 08:06:04 +01:00
|
|
|
|
2024-09-01 22:25:43 +02:00
|
|
|
ynh_config_add_systemd --service="${app}-server" --template="funkwhale-server.service"
|
|
|
|
ynh_config_add_systemd --service="${app}-worker" --template="funkwhale-worker.service"
|
|
|
|
ynh_config_add_systemd --service="${app}-beat" --template="funkwhale-beat.service"
|
2023-06-20 10:44:18 +02:00
|
|
|
|
|
|
|
yunohost service add "${app}-beat" --description="${app} celery beat process" --log="/var/log/$app/${app}-beat.log"
|
|
|
|
yunohost service add "${app}-server" --description="${app} application server" --log="/var/log/$app/${app}-server.log"
|
|
|
|
yunohost service add "${app}-worker" --description="${app} celery worker" --log="/var/log/$app/${app}-worker.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
|
|
|
#=================================================
|
2024-09-01 22:25:43 +02:00
|
|
|
ynh_script_progression "Starting $app's systemd service..."
|
2019-04-03 14:35:09 +02:00
|
|
|
|
2024-09-01 22:25:43 +02:00
|
|
|
ynh_systemctl --service="${app}-beat" --action="start" --log_path="systemd"
|
|
|
|
ynh_systemctl --service="${app}-server" --action="start" --log_path="systemd" --wait_until="Application startup complete"
|
|
|
|
ynh_systemctl --service="${app}-worker" --action="start" --log_path="systemd" --wait_until="ready"
|
2019-04-03 14:35:09 +02:00
|
|
|
|
2019-05-14 22:55:26 +02:00
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
2019-04-12 15:47:49 +02:00
|
|
|
#=================================================
|
2024-09-01 22:25:43 +02:00
|
|
|
ynh_script_progression "Reloading NGINX web server..."
|
2019-04-12 15:47:49 +02:00
|
|
|
|
2024-09-01 22:25:43 +02:00
|
|
|
ynh_systemctl --service=nginx --action=reload
|
2019-04-12 15:47:49 +02:00
|
|
|
|
2019-04-03 14:35:09 +02:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2024-09-01 22:25:43 +02:00
|
|
|
ynh_script_progression "Restoration completed for $app"
|