mirror of
https://github.com/YunoHost-Apps/funkwhale_ynh.git
synced 2024-09-03 18:36:24 +02:00
2372f1f4e9
* [autopatch] Automatic patch attempt for helpers 2.1 (#270) * [autopatch] Automatic patch attempt for helpers 2.1 * Cleaning * cleaning --------- Co-authored-by: Yunohost-Bot <> Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> * Auto-update READMEs * Update manifest.toml --------- Co-authored-by: YunoHost Bot <yunohost-bot@users.noreply.github.com> Co-authored-by: yunohost-bot <yunohost@yunohost.org>
98 lines
3.6 KiB
Bash
98 lines
3.6 KiB
Bash
#!/bin/bash
|
|
|
|
source ../settings/scripts/_common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# RESTORE THE APP MAIN DIR
|
|
#=================================================
|
|
ynh_script_progression "Restoring the app main directory..."
|
|
|
|
ynh_restore "$install_dir"
|
|
|
|
#=================================================
|
|
# RESTORE THE DATA DIRECTORY
|
|
#=================================================
|
|
ynh_script_progression "Restoring the data directory..."
|
|
|
|
ynh_restore "$data_dir/" || true
|
|
|
|
mkdir -p $data_dir/data
|
|
mkdir -p $data_dir/data/{static,media,music}
|
|
|
|
chmod -R o-rwx "$data_dir/"
|
|
chown -R $app:www-data "$data_dir/"
|
|
|
|
#=================================================
|
|
# RESTORE THE NGINX CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression "Restoring the NGINX web server configuration..."
|
|
|
|
ynh_restore "/etc/nginx/conf.d/$domain.d"
|
|
|
|
#=================================================
|
|
# RESTORE THE POSTGRESQL DATABASE
|
|
#=================================================
|
|
ynh_script_progression "Restoring the PostgreSQL database..."
|
|
|
|
ynh_psql_db_shell < "./db.sql"
|
|
|
|
#=================================================
|
|
# 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
|
|
|
|
#=================================================
|
|
# RESTORE SYSTEMD
|
|
#=================================================
|
|
ynh_script_progression "Restoring $app's systemd service..."
|
|
|
|
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"
|
|
|
|
systemctl enable "${app}-beat.service" --quiet
|
|
systemctl enable "${app}-server.service" --quiet
|
|
systemctl enable "${app}-worker.service" --quiet
|
|
|
|
#=================================================
|
|
# 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"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression "Starting $app's systemd service..."
|
|
|
|
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"
|
|
|
|
#=================================================
|
|
# RELOAD NGINX
|
|
#=================================================
|
|
ynh_script_progression "Reloading NGINX web server..."
|
|
|
|
ynh_systemctl --service=nginx --action=reload
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression "Restoration completed for $app"
|