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

99 lines
3.6 KiB
Text
Raw Permalink Normal View History

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
#=================================================
# RESTORE THE APP MAIN DIR
2019-04-12 16:58:46 +02:00
#=================================================
ynh_script_progression "Restoring the app main directory..."
2019-04-12 16:58:46 +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
#=================================================
ynh_script_progression "Restoring the data directory..."
ynh_restore "$data_dir/" || true
2023-03-31 13:19:41 +02:00
mkdir -p $data_dir/data
mkdir -p $data_dir/data/{static,media,music}
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/"
2022-10-04 00:13:33 +02:00
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression "Restoring the NGINX web server configuration..."
2022-10-04 00:13:33 +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
#=================================================
ynh_script_progression "Restoring the PostgreSQL database..."
2018-05-11 21:38:56 +02:00
ynh_psql_db_shell < "./db.sql"
2018-05-11 21:38:56 +02:00
#=================================================
# LOGROTATE
#=================================================
ynh_script_progression "Configuring logrotate to manage application logfiles"
ynh_config_add_logrotate
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
#=================================================
ynh_script_progression "Restoring $app's systemd service..."
2018-05-11 21:38:56 +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
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
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression "Integrating service in YunoHost..."
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"
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"
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
#=================================================
ynh_script_progression "Starting $app's systemd service..."
2019-04-03 14:35:09 +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
#=================================================
ynh_script_progression "Reloading NGINX web server..."
2019-04-12 15:47:49 +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
#=================================================
ynh_script_progression "Restoration completed for $app"