#!/bin/bash #================================================= # GENERIC START #================================================= # Import common cmd source ../settings/scripts/experimental_helper.sh source ../settings/scripts/_common.sh # Source YunoHost helpers source /usr/share/yunohost/helpers ynh_script_progression --message="Loading settings..." # Retrieve arguments seafile_version=$(ynh_app_upstream_version) #================================================= # STANDARD RESTORATION STEPS #================================================= # Restore all config and data ynh_script_progression --message="Restoring files..." --weight=10 ynh_restore # Restore dependencies install_dependance # Restore mysql dump ynh_script_progression --message="Restoring database..." --weight=3 ynh_mysql_setup_db --db_user $db_user --db_name ccnetdb --db_pwd "$db_pwd" ynh_mysql_setup_db --db_user $db_user --db_name seafiledb --db_pwd "$db_pwd" ynh_mysql_setup_db --db_user $db_user --db_name seahubdb --db_pwd "$db_pwd" su -c "mysql -u ${app} -p$db_pwd ccnetdb < ${YNH_CWD}/ccnetdb.dmp" su -c "mysql -u ${app} -p$db_pwd seafiledb < ${YNH_CWD}/seafiledb.dmp" su -c "mysql -u ${app} -p$db_pwd seahubdb < ${YNH_CWD}/seahubdb.dmp" #================================================= # GENERIC FINALIZATION #================================================= # Add logrotate ynh_script_progression --message="Configuring log rotation..." ynh_use_logrotate --logfile $install_dir/logs ln -s $install_dir/logs /var/log/seafile # Set all permissions ynh_script_progression --message="Protecting directory..." set_permission # Enable service and start seafile ynh_script_progression --message="Reconfiguring application..." systemctl daemon-reload systemctl enable seafile --quiet systemctl enable seahub --quiet # Add Seafile to YunoHost's monitored services ynh_script_progression --message="Register seafile service..." yunohost service add seafile yunohost service add seahub ynh_script_progression --message="Reloading services..." # Reload nginx systemctl reload nginx.service # Reload fail2ban ynh_systemd_action --service_name=fail2ban --action=reload # Avoid the current effect sleep 5 # Restart service ynh_script_progression --message="Starting seafile services..." --weight=3 ynh_systemd_action --service_name seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log ynh_systemd_action --service_name seahub -l "Started Seafile hub." -p "systemd" sleep 2 ynh_script_progression --message="Restoration completed for $app" --last