mirror of
https://github.com/YunoHost-Apps/seafile_ynh.git
synced 2024-09-03 20:26:01 +02:00
75 lines
No EOL
2.2 KiB
Bash
75 lines
No EOL
2.2 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
|
|
# Source YunoHost helpers
|
|
source /usr/share/yunohost/helpers
|
|
|
|
# Stop script if errors
|
|
ynh_abort_if_errors
|
|
|
|
# Import common cmd
|
|
source ../settings/scripts/experimental_helper.sh
|
|
source ../settings/scripts/_common.sh
|
|
|
|
# Retrieve arguments
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
path_url=$(ynh_normalize_url_path $(ynh_app_setting_get $app path))
|
|
db_pwd=$(ynh_app_setting_get ${app} mysqlpwd)
|
|
seafile_data=/home/yunohost.app/seafile-data
|
|
|
|
# Check domain/path availability
|
|
ynh_webpath_available $domain $path_url || ynh_die "$domain/$path_url is not available, please use an other domain or path."
|
|
|
|
#=================================================
|
|
# STANDARD RESTORATION STEPS
|
|
#=================================================
|
|
|
|
# Restore dependencies
|
|
install_dependance
|
|
|
|
# Restore all config and data
|
|
ynh_restore
|
|
|
|
# Get configuration for user and final path
|
|
get_configuration
|
|
|
|
# Create user if it need
|
|
[[ $seafile_user = "seafile" ]] && ynh_system_user_create $seafile_user $final_path
|
|
|
|
# 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"
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
|
|
# Restore sso persistent config
|
|
python3 $final_path/add_sso_conf.py
|
|
|
|
# Add logrotate
|
|
ynh_use_logrotate $final_path/logs
|
|
ln -s $final_path/logs /var/log/seafile
|
|
|
|
# Set permissions to seafile directory
|
|
chown -R $seafile_user:$seafile_user $final_path
|
|
chown -R $seafile_user:$seafile_user $seafile_data
|
|
|
|
# Add Seafile to YunoHost's monitored services
|
|
yunohost service add seafile-server
|
|
|
|
# Reload nginx
|
|
systemctl reload nginx.service
|
|
|
|
# Enable service and start seafile
|
|
systemctl daemon-reload
|
|
update-rc.d seafile-server defaults
|
|
ynh_system_reload seafile-server start |