mirror of
https://github.com/YunoHost-Apps/seafile_ynh.git
synced 2024-09-03 20:26:01 +02:00
184 lines
5.7 KiB
Bash
184 lines
5.7 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 ./experimental_helper.sh
|
|
source ./_common.sh
|
|
|
|
# Init get Final path
|
|
get_configuration
|
|
|
|
# Retrieve arguments
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
path_url=$(ynh_normalize_url_path $(ynh_app_setting_get $app path))
|
|
installed_version=$(ynh_app_setting_get $app installed_version)
|
|
seahub_port=$(ynh_app_setting_get $app seahub_port)
|
|
fileserver_port=$(ynh_app_setting_get $app fileserver_port)
|
|
webdav_port=$(ynh_app_setting_get $app webdav_port)
|
|
root_pwd=$(cat /etc/yunohost/mysql)
|
|
|
|
# Get configuration for user and final path
|
|
get_configuration
|
|
|
|
# stop seafile server
|
|
systemctl stop seafile-server.service
|
|
sleep 2
|
|
pkill -f seafile-controller || true
|
|
pkill -f seaf-server || true
|
|
pkill -f ccnet-server || true
|
|
pkill -f seahub || true
|
|
|
|
#=================================================
|
|
# MIGRATION FROM OLD VERSION
|
|
#=================================================
|
|
|
|
# extract new version
|
|
test -e $final_path/seafile-server-$seafile_version && ynh_secure_remove "$final_path/seafile-server-$seafile_version"
|
|
install_source
|
|
|
|
# permission to execute update script and expect helper
|
|
chmod +x expect_scripts/upgrade_*.exp
|
|
chmod +x expect_scripts/minor-upgrade.exp
|
|
chmod +x $final_path/seafile-server-$seafile_version/upgrade/upgrade_*.sh
|
|
chmod +x $final_path/seafile-server-$seafile_version/upgrade/minor-upgrade.sh
|
|
|
|
# do the upgrade ( the ";&" syntax mean when it go in the frist cas how are true it do the next case)
|
|
case $installed_version in
|
|
"4.0."* )
|
|
# Update seafile by script
|
|
expect_scripts/upgrade_4.1.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
;&
|
|
"4.1."* )
|
|
# Update seafile by script
|
|
expect_scripts/upgrade_4.2.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
;&
|
|
"4.3."* )
|
|
# Update seafile by script
|
|
expect_scripts/upgrade_4.4.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
;&
|
|
"4.4."* )
|
|
# Update seafile by script
|
|
expect_scripts/upgrade_5.0.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
;&
|
|
"5.0."* )
|
|
# Update seafile by script
|
|
expect_scripts/upgrade_5.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
;&
|
|
"5.1."* )
|
|
# Update seafile by script
|
|
expect_scripts/upgrade_6.0.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
;&
|
|
"6.0."* )
|
|
python3 ../conf/update_sso_conf.py || true
|
|
install_dependance
|
|
|
|
# Update seafile by script
|
|
expect_scripts/upgrade_6.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
# Enable manually wiki
|
|
echo 'ENABLE_WIKI = True' | tee -a $final_path/conf/seahub_settings.py
|
|
;&
|
|
"6.1."* )
|
|
# Update seafile by script
|
|
expect_scripts/upgrade_6.2.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
;&
|
|
"6.2."* )
|
|
# Update seafile by script
|
|
expect_scripts/upgrade_6.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
# Update logrotate to have the last version
|
|
ynh_use_logrotate $final_path/logs --non-append
|
|
;&
|
|
esac
|
|
|
|
expect_scripts/minor-upgrade.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
## Install webdav and logrotate if not installed
|
|
if [[ $installed_version = "4.0."* ]] || [[ $installed_version = "4.1."* ]]
|
|
then
|
|
webdav_port=$(ynh_find_port 8080)
|
|
ynh_app_setting_set seafile webdav_port $webdav_port
|
|
|
|
# Disallow port that was used by old seafile client
|
|
ccnet_port=$(ynh_app_setting_get $app ccnet_port)
|
|
seafile_port=$(ynh_app_setting_get $app seafile_port)
|
|
yunohost firewall disallow Both $ccnet_port
|
|
yunohost firewall disallow Both $seafile_port
|
|
|
|
# Add webdav config
|
|
cp ../conf/seafdav.conf $final_path/conf/seafdav.conf
|
|
ynh_replace_string WEBDAV_PORT $webdav_port $final_path/conf/seafdav.conf
|
|
|
|
# Add sso config to unprotect domain.tld/seafdav in /etc/ssowat/conf.json.persistent
|
|
cp ../conf/add_sso_conf.py $final_path
|
|
cp ../conf/add_sso_conf_webdav.py $final_path
|
|
cp ../conf/remove_sso_conf.py $final_path
|
|
python3 $final_path/add_sso_conf_webdav.py
|
|
|
|
# Update seafile config
|
|
echo 'COMPRESS_URL = MEDIA_URL' | tee -a $final_path/conf/seahub_settings.py
|
|
echo "STATIC_URL = MEDIA_URL + 'assets/'" | tee -a $final_path/conf/seahub_settings.py
|
|
|
|
# Add logrotate
|
|
ynh_use_logrotate $final_path/logs
|
|
fi
|
|
|
|
# Update seahub config for old version to version 5.0.4
|
|
if [[ $(grep -c "LOGIN_URL" $final_path/conf/seahub_settings.py) == 0 ]]
|
|
then
|
|
echo "LOGIN_URL = '$path_url/accounts/login/'" | tee -a $final_path/conf/seahub_settings.py
|
|
fi
|
|
|
|
# Fix local warning
|
|
ynh_replace_string en_US.UTF-8 $LANG $final_path/seafile-server-$seafile_version/seahub.sh
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
|
|
# Config nginx
|
|
config_nginx
|
|
|
|
# Update init file
|
|
cp ../conf/seafile-server /etc/init.d
|
|
ynh_replace_string SEAHUB_PORT $seahub_port /etc/init.d/seafile-server
|
|
ynh_replace_string SEAFILE_DIR $final_path /etc/init.d/seafile-server
|
|
ynh_replace_string SEAFILE_USER $seafile_user /etc/init.d/seafile-server
|
|
chmod +x /etc/init.d/seafile-server
|
|
systemctl daemon-reload
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
|
|
# restore correct permissions
|
|
chown -R $seafile_user:$seafile_user $final_path
|
|
|
|
# delete seafile cache
|
|
ynh_secure_remove /tmp/seahub_cache
|
|
|
|
# restart seafile server
|
|
sleep 5
|
|
system_reload seafile-server start
|
|
|
|
# remove old version files
|
|
ls $final_path | grep "seafile-server-" | egrep -v "(${seafile_version//./\\.})|(latest)" | \
|
|
while read f
|
|
do
|
|
ynh_secure_remove $final_path/$f
|
|
done
|
|
|
|
# store new installed version
|
|
ynh_app_setting_set $app installed_version $seafile_version
|
|
|
|
# Reload nginx
|
|
systemctl reload nginx.service
|