2015-03-25 19:14:18 +01:00
|
|
|
#!/bin/bash
|
2015-10-28 16:04:51 +01:00
|
|
|
|
2018-02-11 01:20:58 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
|
2017-07-21 14:56:41 +02:00
|
|
|
# Source YunoHost helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
# Stop script if errors
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
2017-01-05 23:24:32 +01:00
|
|
|
# Import common cmd
|
2018-02-11 01:20:58 +01:00
|
|
|
source ./experimental_helper.sh
|
2017-01-05 23:24:32 +01:00
|
|
|
source ./_common.sh
|
|
|
|
|
2017-07-21 14:56:41 +02:00
|
|
|
# Init get Final path
|
|
|
|
get_configuration
|
2015-03-25 19:14:18 +01:00
|
|
|
|
2017-07-21 14:56:41 +02:00
|
|
|
# Retrieve arguments
|
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
2018-05-09 16:13:36 +02:00
|
|
|
path_url=$(ynh_normalize_url_path $(ynh_app_setting_get $app path))
|
2016-12-27 10:44:40 +01:00
|
|
|
installed_version=$(ynh_app_setting_get $app installed_version)
|
2017-09-30 15:07:56 +02:00
|
|
|
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)
|
2017-07-21 14:56:41 +02:00
|
|
|
root_pwd=$(cat /etc/yunohost/mysql)
|
2016-12-27 10:44:40 +01:00
|
|
|
|
2017-07-21 14:56:41 +02:00
|
|
|
# Get configuration for user and final path
|
|
|
|
get_configuration
|
2016-12-27 10:44:40 +01:00
|
|
|
|
2017-01-05 23:24:32 +01:00
|
|
|
# stop seafile server
|
2017-07-21 14:56:41 +02:00
|
|
|
systemctl stop seafile-server.service
|
2018-06-07 21:20:50 +02:00
|
|
|
sleep 2
|
|
|
|
pkill -f seafile-controller || true
|
|
|
|
pkill -f seaf-server || true
|
|
|
|
pkill -f ccnet-server || true
|
|
|
|
pkill -f seahub || true
|
2017-01-05 23:24:32 +01:00
|
|
|
|
2018-02-11 01:20:58 +01:00
|
|
|
#=================================================
|
|
|
|
# MIGRATION FROM OLD VERSION
|
|
|
|
#=================================================
|
|
|
|
|
2015-03-25 19:14:18 +01:00
|
|
|
# extract new version
|
2018-01-19 20:55:44 +01:00
|
|
|
test -e $final_path/seafile-server-$seafile_version && ynh_secure_remove "$final_path/seafile-server-$seafile_version"
|
|
|
|
install_source
|
2015-03-25 19:14:18 +01:00
|
|
|
|
2019-05-09 11:18:17 +02:00
|
|
|
# Upgrade dependances
|
|
|
|
install_dependance
|
|
|
|
|
2015-03-25 19:14:18 +01:00
|
|
|
# permission to execute update script and expect helper
|
2018-07-06 10:28:14 +02:00
|
|
|
chmod +x expect_scripts/upgrade_*.exp
|
|
|
|
chmod +x expect_scripts/minor-upgrade.exp
|
2017-07-21 14:56:41 +02:00
|
|
|
chmod +x $final_path/seafile-server-$seafile_version/upgrade/upgrade_*.sh
|
|
|
|
chmod +x $final_path/seafile-server-$seafile_version/upgrade/minor-upgrade.sh
|
2017-05-05 15:43:32 +02:00
|
|
|
|
|
|
|
# do the upgrade ( the ";&" syntax mean when it go in the frist cas how are true it do the next case)
|
2015-08-24 20:45:36 +02:00
|
|
|
case $installed_version in
|
|
|
|
"4.0."* )
|
|
|
|
# Update seafile by script
|
2018-07-06 10:28:14 +02:00
|
|
|
expect_scripts/upgrade_4.1.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
2017-05-05 15:43:32 +02:00
|
|
|
;&
|
2015-08-24 20:45:36 +02:00
|
|
|
"4.1."* )
|
|
|
|
# Update seafile by script
|
2018-07-06 10:28:14 +02:00
|
|
|
expect_scripts/upgrade_4.2.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
2017-05-05 15:43:32 +02:00
|
|
|
;&
|
2015-10-22 22:38:59 +02:00
|
|
|
"4.3."* )
|
|
|
|
# Update seafile by script
|
2018-07-06 10:28:14 +02:00
|
|
|
expect_scripts/upgrade_4.4.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
2017-05-05 15:43:32 +02:00
|
|
|
;&
|
2015-12-26 13:44:45 +01:00
|
|
|
"4.4."* )
|
|
|
|
# Update seafile by script
|
2018-07-06 10:28:14 +02:00
|
|
|
expect_scripts/upgrade_5.0.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
2017-05-05 15:43:32 +02:00
|
|
|
;&
|
2016-12-27 10:44:40 +01:00
|
|
|
"5.0."* )
|
|
|
|
# Update seafile by script
|
2018-07-06 10:28:14 +02:00
|
|
|
expect_scripts/upgrade_5.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
2017-05-05 15:43:32 +02:00
|
|
|
;&
|
2016-12-27 10:44:40 +01:00
|
|
|
"5.1."* )
|
|
|
|
# Update seafile by script
|
2018-07-06 10:28:14 +02:00
|
|
|
expect_scripts/upgrade_6.0.exp $final_path/seafile-server-$seafile_version $root_pwd
|
2017-07-21 14:56:41 +02:00
|
|
|
;&
|
|
|
|
"6.0."* )
|
2018-03-09 20:37:26 +01:00
|
|
|
python3 ../conf/update_sso_conf.py || true
|
2017-07-21 14:56:41 +02:00
|
|
|
|
|
|
|
# Update seafile by script
|
2018-07-06 10:28:14 +02:00
|
|
|
expect_scripts/upgrade_6.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
2017-08-09 15:34:10 +02:00
|
|
|
|
|
|
|
# Enable manually wiki
|
|
|
|
echo 'ENABLE_WIKI = True' | tee -a $final_path/conf/seahub_settings.py
|
2017-05-05 15:43:32 +02:00
|
|
|
;&
|
2017-09-30 15:07:56 +02:00
|
|
|
"6.1."* )
|
|
|
|
# Update seafile by script
|
2018-07-06 10:28:14 +02:00
|
|
|
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
|
2017-09-30 15:07:56 +02:00
|
|
|
;&
|
2015-08-24 20:45:36 +02:00
|
|
|
esac
|
|
|
|
|
2018-07-06 10:28:14 +02:00
|
|
|
expect_scripts/minor-upgrade.exp $final_path/seafile-server-$seafile_version $root_pwd
|
2017-05-05 15:43:32 +02:00
|
|
|
|
2015-08-24 20:45:36 +02:00
|
|
|
## Install webdav and logrotate if not installed
|
|
|
|
if [[ $installed_version = "4.0."* ]] || [[ $installed_version = "4.1."* ]]
|
|
|
|
then
|
2017-07-21 14:56:41 +02:00
|
|
|
webdav_port=$(ynh_find_port 8080)
|
2016-12-27 10:44:40 +01:00
|
|
|
ynh_app_setting_set seafile webdav_port $webdav_port
|
2015-08-24 20:45:36 +02:00
|
|
|
|
|
|
|
# Disallow port that was used by old seafile client
|
2016-12-27 10:44:40 +01:00
|
|
|
ccnet_port=$(ynh_app_setting_get $app ccnet_port)
|
|
|
|
seafile_port=$(ynh_app_setting_get $app seafile_port)
|
2017-07-21 14:56:41 +02:00
|
|
|
yunohost firewall disallow Both $ccnet_port
|
|
|
|
yunohost firewall disallow Both $seafile_port
|
2015-08-24 20:45:36 +02:00
|
|
|
|
|
|
|
# Add webdav config
|
2017-07-21 14:56:41 +02:00
|
|
|
cp ../conf/seafdav.conf $final_path/conf/seafdav.conf
|
|
|
|
ynh_replace_string WEBDAV_PORT $webdav_port $final_path/conf/seafdav.conf
|
2015-08-24 20:45:36 +02:00
|
|
|
|
|
|
|
# Add sso config to unprotect domain.tld/seafdav in /etc/ssowat/conf.json.persistent
|
2017-07-21 14:56:41 +02:00
|
|
|
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
|
2018-03-09 20:37:26 +01:00
|
|
|
python3 $final_path/add_sso_conf_webdav.py
|
2015-08-24 20:45:36 +02:00
|
|
|
|
|
|
|
# Update seafile config
|
2017-07-21 14:56:41 +02:00
|
|
|
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
|
2015-08-24 20:45:36 +02:00
|
|
|
|
|
|
|
# Add logrotate
|
2017-12-10 10:45:51 +01:00
|
|
|
ynh_use_logrotate $final_path/logs
|
2015-08-24 20:45:36 +02:00
|
|
|
fi
|
2015-03-25 19:14:18 +01:00
|
|
|
|
2017-01-05 23:24:32 +01:00
|
|
|
# Update seahub config for old version to version 5.0.4
|
2017-07-21 14:56:41 +02:00
|
|
|
if [[ $(grep -c "LOGIN_URL" $final_path/conf/seahub_settings.py) == 0 ]]
|
2017-01-05 23:24:32 +01:00
|
|
|
then
|
2018-05-09 16:13:36 +02:00
|
|
|
echo "LOGIN_URL = '$path_url/accounts/login/'" | tee -a $final_path/conf/seahub_settings.py
|
2017-01-05 23:24:32 +01:00
|
|
|
fi
|
|
|
|
|
2017-07-21 14:56:41 +02:00
|
|
|
# Fix local warning
|
|
|
|
ynh_replace_string en_US.UTF-8 $LANG $final_path/seafile-server-$seafile_version/seahub.sh
|
|
|
|
|
2018-08-03 22:24:07 +02:00
|
|
|
# Update gunicorn config
|
|
|
|
sed --in-place -r "s@bind = \"0\.0\.0\.0:[[:digit:]]+\"@bind = \"0.0.0.0:$seahub_port\"@g" $final_path/conf/gunicorn.conf
|
|
|
|
|
2018-02-11 01:20:58 +01:00
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
|
2017-09-30 15:07:56 +02:00
|
|
|
# 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
|
2017-09-30 18:14:22 +02:00
|
|
|
ynh_replace_string SEAFILE_USER $seafile_user /etc/init.d/seafile-server
|
2017-09-30 15:07:56 +02:00
|
|
|
chmod +x /etc/init.d/seafile-server
|
|
|
|
systemctl daemon-reload
|
|
|
|
|
2018-02-11 01:20:58 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
|
2015-03-25 19:14:18 +01:00
|
|
|
# restore correct permissions
|
2017-07-21 14:56:41 +02:00
|
|
|
chown -R $seafile_user:$seafile_user $final_path
|
2015-03-25 19:14:18 +01:00
|
|
|
|
2015-08-29 13:25:04 +02:00
|
|
|
# delete seafile cache
|
2018-01-19 20:55:44 +01:00
|
|
|
ynh_secure_remove /tmp/seahub_cache
|
2015-08-29 13:25:04 +02:00
|
|
|
|
2015-03-25 19:14:18 +01:00
|
|
|
# restart seafile server
|
2018-06-06 19:22:00 +02:00
|
|
|
sleep 5
|
2018-06-07 21:20:50 +02:00
|
|
|
system_reload seafile-server start
|
2015-03-25 19:14:18 +01:00
|
|
|
|
|
|
|
# remove old version files
|
2018-02-12 17:14:08 +01:00
|
|
|
ls $final_path | grep "seafile-server-" | egrep -v "(${seafile_version//./\\.})|(latest)" | \
|
|
|
|
while read f
|
|
|
|
do
|
|
|
|
ynh_secure_remove $final_path/$f
|
|
|
|
done
|
2015-03-25 19:14:18 +01:00
|
|
|
|
|
|
|
# store new installed version
|
2017-01-05 23:24:32 +01:00
|
|
|
ynh_app_setting_set $app installed_version $seafile_version
|
2015-03-25 19:14:18 +01:00
|
|
|
|
2017-07-21 14:56:41 +02:00
|
|
|
# Reload nginx
|
|
|
|
systemctl reload nginx.service
|