mirror of
https://github.com/YunoHost-Apps/seafile_ynh.git
synced 2024-09-03 20:26:01 +02:00
66 lines
2 KiB
Bash
66 lines
2 KiB
Bash
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
# Import common cmd
|
|
source ./_common.sh
|
|
|
|
# Set configuration for user and final path
|
|
set_configuration
|
|
|
|
# The parameter $1 is the backup directory location dedicated to the app
|
|
BACKUP_DIR=$1
|
|
|
|
# The parameter $2 is the id of the app instance ex: strut__2
|
|
APP=$2
|
|
|
|
# retrieve useful param
|
|
domain=$(ynh_app_setting_get ${APP} domain)
|
|
db_pwd=$(ynh_app_setting_get ${APP} db_pwd)
|
|
path=$(ynh_app_setting_get ${APP} path)
|
|
|
|
# Check domain/path availability
|
|
sudo yunohost app checkurl $domain$path -a ${APP} \
|
|
|| (echo "Path not available: $domain$path" && ynh_die "Error : path not available")
|
|
|
|
# Restore dependencies
|
|
sudo apt-get update
|
|
sudo apt-get install -qq python2.7 python-setuptools python-simplejson python-imaging python-mysqldb python-flup expect
|
|
|
|
# Restore app files
|
|
final_path=$final_path
|
|
sudo mkdir -p $final_path
|
|
sudo cp -a "${BACKUP_DIR}/www/." $final_path
|
|
sudo chown -R $seafile_user:$seafile_user $final_path
|
|
|
|
# Restore conf files
|
|
sudo cp -a "${BACKUP_DIR}/conf/${APP}.conf" /etc/nginx/conf.d/$domain.d/${APP}.conf
|
|
sudo cp -a "${BACKUP_DIR}/conf/${APP}" /etc/logrotate.d/${APP}
|
|
sudo cp -a "${BACKUP_DIR}/conf/seafile-server" /etc/init.d/seafile-server
|
|
sudo chmod +x /etc/init.d/seafile-server
|
|
|
|
# Restore data
|
|
seafile_data=/home/yunohost.app/seafile-data
|
|
mkdir -p $seafile_data
|
|
sudo cp -a "${BACKUP_DIR}/data/." /home/yunohost.app/seafile-data/.
|
|
sudo chown -R $seafile_user:$seafile_user $seafile_data
|
|
|
|
# Restore mysql dump
|
|
sudo su -c "mysql -u ${APP} -p$db_pwd ccnetdb < ${BACKUP_DIR}/ccnetdb.dmp"
|
|
sudo su -c "mysql -u ${APP} -p$db_pwd seafiledb < ${BACKUP_DIR}/seafiledb.dmp"
|
|
sudo su -c "mysql -u ${APP} -p$db_pwd seahubdb < ${BACKUP_DIR}/seahubdb.dmp"
|
|
|
|
# Restore sso persistent config
|
|
sudo python $final_path/add_sso_conf.py
|
|
|
|
# Add Seafile to YunoHost's monitored services
|
|
sudo yunohost service add seafile-server
|
|
|
|
# Reload/restart services
|
|
sudo update-rc.d seafile-server defaults
|
|
sudo service rsyslog restart
|
|
sudo service nginx reload
|
|
sudo yunohost app ssowatconf
|
|
|
|
# start seafile
|
|
sudo service seafile-server start
|