2015-12-26 14:14:31 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-02-11 01:20:58 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
|
2020-11-17 23:49:06 +01:00
|
|
|
# Import common cmd
|
|
|
|
source ../settings/scripts/experimental_helper.sh
|
|
|
|
source ../settings/scripts/_common.sh
|
|
|
|
|
2017-07-21 14:56:41 +02:00
|
|
|
# Source YunoHost helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
2017-01-28 18:51:23 +01:00
|
|
|
|
2024-04-26 23:35:14 +02:00
|
|
|
seafile_version="$(ynh_app_upstream_version)"
|
2024-05-30 23:22:07 +02:00
|
|
|
seafile_code="$install_dir/seafile_image/opt/seafile/seafile-server-$seafile_version"
|
2024-04-12 22:19:27 +02:00
|
|
|
|
2024-08-31 02:59:12 +02:00
|
|
|
ynh_script_progression "Loading settings..."
|
2019-06-11 22:28:26 +02:00
|
|
|
|
2018-02-11 01:20:58 +01:00
|
|
|
#=================================================
|
|
|
|
# STANDARD RESTORATION STEPS
|
|
|
|
#=================================================
|
|
|
|
|
2017-07-21 14:56:41 +02:00
|
|
|
# Restore all config and data
|
2024-08-31 02:59:12 +02:00
|
|
|
ynh_script_progression "Restoring files..."
|
|
|
|
ynh_restore_everything
|
2015-12-26 14:14:31 +01:00
|
|
|
# Restore mysql dump
|
2024-08-31 02:59:12 +02:00
|
|
|
ynh_script_progression "Restoring database..."
|
2023-09-27 19:26:58 +02:00
|
|
|
db_helper=ynh_"mysql"_setup_db
|
2024-04-21 01:58:30 +02:00
|
|
|
$db_helper --db_user "$db_user" --db_name ccnetdb --db_pwd "$db_pwd"
|
|
|
|
$db_helper --db_user "$db_user" --db_name seahubdb --db_pwd "$db_pwd"
|
2023-09-27 23:04:06 +02:00
|
|
|
su -c "mysql -u ${app} -p$db_pwd $db_name < ${YNH_CWD}/seafiledb.dmp"
|
2017-07-21 14:56:41 +02:00
|
|
|
su -c "mysql -u ${app} -p$db_pwd ccnetdb < ${YNH_CWD}/ccnetdb.dmp"
|
|
|
|
su -c "mysql -u ${app} -p$db_pwd seahubdb < ${YNH_CWD}/seahubdb.dmp"
|
2016-02-08 02:06:58 +01:00
|
|
|
|
2018-02-11 01:20:58 +01:00
|
|
|
#=================================================
|
|
|
|
|
2017-07-21 14:56:41 +02:00
|
|
|
# Add logrotate
|
2024-08-31 02:59:12 +02:00
|
|
|
ynh_script_progression "Configuring log rotation..."
|
2024-04-21 01:58:30 +02:00
|
|
|
mkdir -p /var/log/"$app"
|
2024-08-31 02:59:12 +02:00
|
|
|
ynh_config_add_logrotate "$install_dir"/logs
|
2017-12-15 23:12:34 +01:00
|
|
|
|
2019-06-11 22:28:26 +02:00
|
|
|
# Set all permissions
|
2024-08-31 02:59:12 +02:00
|
|
|
ynh_script_progression "Protecting directory..."
|
2019-06-11 22:28:26 +02:00
|
|
|
set_permission
|
2015-12-26 14:14:31 +01:00
|
|
|
|
2019-06-12 22:56:50 +02:00
|
|
|
# Enable service and start seafile
|
2024-08-31 02:59:12 +02:00
|
|
|
ynh_script_progression "Reconfiguring application..."
|
2019-06-12 22:56:50 +02:00
|
|
|
systemctl daemon-reload
|
2020-12-12 15:03:12 +01:00
|
|
|
systemctl enable seafile --quiet
|
|
|
|
systemctl enable seahub --quiet
|
2019-06-12 22:56:50 +02:00
|
|
|
|
2015-12-26 14:14:31 +01:00
|
|
|
# Add Seafile to YunoHost's monitored services
|
2024-08-31 02:59:12 +02:00
|
|
|
ynh_script_progression "Register seafile service..."
|
2024-02-20 21:28:59 +01:00
|
|
|
yunohost service add seafile --description 'Main service for seafile server.'
|
|
|
|
yunohost service add seahub --description 'Seafile server web interface.'
|
2015-12-26 14:14:31 +01:00
|
|
|
|
2024-08-31 02:59:12 +02:00
|
|
|
ynh_script_progression "Reloading services..."
|
2019-06-12 22:56:50 +02:00
|
|
|
|
2017-07-21 14:56:41 +02:00
|
|
|
# Reload nginx
|
|
|
|
systemctl reload nginx.service
|
2015-12-26 14:14:31 +01:00
|
|
|
|
2019-06-12 22:56:50 +02:00
|
|
|
# Reload fail2ban
|
2024-08-31 02:59:12 +02:00
|
|
|
ynh_systemctl --service=fail2ban --action=reload
|
2018-06-16 13:56:22 +02:00
|
|
|
|
|
|
|
# Avoid the current effect
|
|
|
|
sleep 5
|
|
|
|
|
|
|
|
# Restart service
|
2024-08-31 02:59:12 +02:00
|
|
|
ynh_script_progression "Starting seafile services..."
|
|
|
|
ynh_systemctl --service=seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log
|
|
|
|
ynh_systemctl --service=seahub -l "Started Seafile hub." -p "systemd"
|
2019-09-10 22:51:15 +02:00
|
|
|
sleep 2
|
2019-06-11 22:28:26 +02:00
|
|
|
|
2024-08-31 02:59:12 +02:00
|
|
|
ynh_script_progression "Restoration completed for $app"
|