seafile_ynh/scripts/restore
2017-07-21 14:56:41 +02:00

73 lines
2.1 KiB
Bash

#!/bin/bash
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Stop script if errors
ynh_abort_if_errors
# Import common cmd
source ../settings/scripts/_common.sh
# Init get Final path
get_configuration
# Retrieve arguments
domain=$(ynh_app_setting_get $app domain)
path=$(ynh_normalize_url_path $(ynh_app_setting_get $app path))
db_pwd=$(ynh_app_setting_get ${app} mysqlpwd)
final_path=/var/www/$app
seafile_user=www-data
BACKUP_DIR=$1
# Check domain/path availability
ynh_webpath_available $domain $path || ynh_die "$domain/$path is not available, please use an other domain or path."
# Restore dependencies
install_dependance
# # Restore app files
# final_path=$final_path
# mkdir -p $final_path
# cp -a "${BACKUP_DIR}/www/." $final_path
# chown -R $seafile_user:$seafile_user $final_path
#
# # Restore conf files
# cp -a "${BACKUP_DIR}/conf/${app}.conf" /etc/nginx/conf.d/$domain.d/${app}.conf
# cp -a "${BACKUP_DIR}/conf/${app}" /etc/logrotate.d/${app}
# cp -a "${BACKUP_DIR}/conf/seafile-server" /etc/init.d/seafile-server
# chmod +x /etc/init.d/seafile-server
#
# # Restore data
# seafile_data=/home/yunohost.app/seafile-data
# mkdir -p $seafile_data
# cp -a "${BACKUP_DIR}/data/." /home/yunohost.app/seafile-data/.
# chown -R $seafile_user:$seafile_user $seafile_data
# Restore all config and data
ynh_restore
# Restore mysql dump
dbuser=seafile
ynh_mysql_create_db ccnetdb "$dbuser" "$db_pwd"
ynh_mysql_create_db seafiledb "$dbuser" "$db_pwd"
ynh_mysql_create_db seahubdb "$dbuser" "$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"
# Restore sso persistent config
python $final_path/add_sso_conf.py
# Add logrotate
ynh_use_logrotate $final_path/logs/seaf-server.log
ynh_use_logrotate $final_path/logs/ccnet.log
# Add Seafile to YunoHost's monitored services
yunohost service add seafile-server
# Reload nginx
systemctl reload nginx.service
# start seafile
systemctl start seafile-server.service