2015-03-25 19:14:18 +01:00
|
|
|
#!/bin/bash
|
2015-10-28 16:04:51 +01:00
|
|
|
|
2017-01-05 23:24:32 +01:00
|
|
|
# Import common cmd
|
|
|
|
source ./_common.sh
|
|
|
|
|
|
|
|
# Init script
|
|
|
|
init_script
|
2015-03-25 19:14:18 +01:00
|
|
|
|
|
|
|
# Retrieve settings
|
2016-12-27 10:44:40 +01:00
|
|
|
installed_version=$(ynh_app_setting_get $app installed_version)
|
2017-01-05 23:24:32 +01:00
|
|
|
path=$(ynh_app_setting_get "$app" path)
|
2016-12-27 10:44:40 +01:00
|
|
|
architecture=$(ynh_app_setting_get $app architecture)
|
2015-03-25 19:14:18 +01:00
|
|
|
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
2016-12-27 10:44:40 +01:00
|
|
|
|
2017-01-05 23:24:32 +01:00
|
|
|
# Correct path if it is not correct
|
|
|
|
correct_path
|
2016-12-27 10:44:40 +01:00
|
|
|
|
|
|
|
# Set configuration for user and final path
|
|
|
|
set_configuration
|
|
|
|
|
|
|
|
# Download new version from sources
|
|
|
|
get_source $architecture $seafile_version
|
2015-03-25 19:14:18 +01:00
|
|
|
|
2017-01-05 23:24:32 +01:00
|
|
|
# stop seafile server
|
|
|
|
sudo service seafile-server stop
|
|
|
|
|
2015-03-25 19:14:18 +01:00
|
|
|
# extract new version
|
2017-01-05 23:24:32 +01:00
|
|
|
test -e $final_path/seafile-server-$seafile_version && sudo rm -rf "$final_path/seafile-server-$seafile_version"
|
2015-03-25 19:14:18 +01:00
|
|
|
sudo mkdir -p $final_path/seafile-server-$seafile_version
|
2016-12-27 10:44:40 +01:00
|
|
|
sudo tar xzf '/tmp/seafile_src.tar.gz'
|
2015-03-25 19:14:18 +01:00
|
|
|
sudo mv seafile-server-$seafile_version/* $final_path/seafile-server-$seafile_version
|
2017-01-05 23:24:32 +01:00
|
|
|
sudo mv '/tmp/seafile_src.tar.gz' $final_path/installed/seafile-server_${seafile_version}.tar.gz
|
2015-03-25 19:14:18 +01:00
|
|
|
|
|
|
|
# permission to execute update script and expect helper
|
|
|
|
sudo chmod +x ../conf/upgrade_4.1.1.exp
|
2015-08-24 20:45:36 +02:00
|
|
|
sudo chmod +x ../conf/upgrade_4.2.1.exp
|
2015-08-29 13:25:04 +02:00
|
|
|
sudo chmod +x ../conf/upgrade_4.3.2.exp
|
2015-10-22 22:38:59 +02:00
|
|
|
sudo chmod +x ../conf/upgrade_4.4.3.exp
|
2015-12-26 13:44:45 +01:00
|
|
|
sudo chmod +x ../conf/upgrade_5.0.3.exp
|
2016-12-27 10:44:40 +01:00
|
|
|
sudo chmod +x ../conf/upgrade_5.1.exp
|
|
|
|
sudo chmod +x ../conf/upgrade_6.0.exp
|
2015-03-25 19:14:18 +01:00
|
|
|
sudo chmod +x $final_path/seafile-server-$seafile_version/upgrade/upgrade_4.0_4.1.sh
|
2015-08-24 20:45:36 +02:00
|
|
|
sudo chmod +x $final_path/seafile-server-$seafile_version/upgrade/upgrade_4.1_4.2.sh
|
|
|
|
sudo chmod +x $final_path/seafile-server-$seafile_version/upgrade/upgrade_4.2_4.3.sh
|
2015-10-22 22:38:59 +02:00
|
|
|
sudo chmod +x $final_path/seafile-server-$seafile_version/upgrade/upgrade_4.3_4.4.sh
|
2015-12-26 13:44:45 +01:00
|
|
|
sudo chmod +x $final_path/seafile-server-$seafile_version/upgrade/upgrade_4.4_5.0.sh
|
2016-12-27 10:44:40 +01:00
|
|
|
sudo chmod +x $final_path/seafile-server-$seafile_version/upgrade/upgrade_5.0_5.1.sh
|
|
|
|
sudo chmod +x $final_path/seafile-server-$seafile_version/upgrade/upgrade_5.1_6.0.sh
|
2015-03-25 19:14:18 +01:00
|
|
|
# do the upgrade
|
2015-08-24 20:45:36 +02:00
|
|
|
case $installed_version in
|
|
|
|
"4.0."* )
|
|
|
|
# Update seafile by script
|
2016-01-07 21:44:33 +01:00
|
|
|
sudo ../conf/upgrade_4.1.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
sudo ../conf/upgrade_4.2.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
sudo ../conf/upgrade_4.3.2.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
sudo ../conf/upgrade_4.4.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
sudo ../conf/upgrade_5.0.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
2016-12-27 10:44:40 +01:00
|
|
|
sudo ../conf/upgrade_5.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
sudo ../conf/upgrade_6.0.exp $final_path/seafile-server-$seafile_version $root_pwd
|
2015-08-24 20:45:36 +02:00
|
|
|
;;
|
|
|
|
"4.1."* )
|
|
|
|
# Update seafile by script
|
2016-01-07 21:44:33 +01:00
|
|
|
sudo ../conf/upgrade_4.2.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
sudo ../conf/upgrade_4.3.2.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
sudo ../conf/upgrade_4.4.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
sudo ../conf/upgrade_5.0.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
2016-12-27 10:44:40 +01:00
|
|
|
sudo ../conf/upgrade_5.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
sudo ../conf/upgrade_6.0.exp $final_path/seafile-server-$seafile_version $root_pwd
|
2015-08-24 20:45:36 +02:00
|
|
|
;;
|
2015-10-22 22:38:59 +02:00
|
|
|
"4.3."* )
|
|
|
|
# Update seafile by script
|
2016-01-07 21:44:33 +01:00
|
|
|
sudo ../conf/upgrade_4.4.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
sudo ../conf/upgrade_5.0.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
2016-12-27 10:44:40 +01:00
|
|
|
sudo ../conf/upgrade_5.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
sudo ../conf/upgrade_6.0.exp $final_path/seafile-server-$seafile_version $root_pwd
|
2015-10-22 22:38:59 +02:00
|
|
|
;;
|
2015-12-26 13:44:45 +01:00
|
|
|
"4.4."* )
|
|
|
|
# Update seafile by script
|
2016-01-07 21:44:33 +01:00
|
|
|
sudo ../conf/upgrade_5.0.3.exp $final_path/seafile-server-$seafile_version $root_pwd
|
2016-12-27 10:44:40 +01:00
|
|
|
sudo ../conf/upgrade_5.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
sudo ../conf/upgrade_6.0.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
;;
|
|
|
|
"5.0."* )
|
|
|
|
# Update seafile by script
|
|
|
|
sudo ../conf/upgrade_5.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
sudo ../conf/upgrade_6.0.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
;;
|
|
|
|
"5.1."* )
|
|
|
|
# Update seafile by script
|
|
|
|
sudo ../conf/upgrade_5.1.exp $final_path/seafile-server-$seafile_version $root_pwd
|
|
|
|
sudo ../conf/upgrade_6.0.exp $final_path/seafile-server-$seafile_version $root_pwd
|
2015-12-26 13:44:45 +01:00
|
|
|
;;
|
2015-08-24 20:45:36 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
## Install webdav and logrotate if not installed
|
|
|
|
if [[ $installed_version = "4.0."* ]] || [[ $installed_version = "4.1."* ]]
|
|
|
|
then
|
|
|
|
# findPort
|
|
|
|
findPort () {
|
|
|
|
port=$1
|
|
|
|
|
|
|
|
sudo yunohost app checkport $port
|
|
|
|
while [[ ! $? -eq 0 ]]
|
|
|
|
do
|
|
|
|
port=$(($port + 1))
|
|
|
|
sudo yunohost app checkport $port
|
|
|
|
done
|
|
|
|
|
|
|
|
return $port
|
|
|
|
}
|
|
|
|
|
|
|
|
findPort 8080
|
|
|
|
webdav_port=$port
|
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)
|
2015-08-24 20:45:36 +02:00
|
|
|
sudo yunohost firewall disallow Both $ccnet_port
|
|
|
|
sudo yunohost firewall disallow Both $seafile_port
|
|
|
|
|
|
|
|
# Add webdav to nginx config
|
|
|
|
sed -i "s@WEBDAV_PORT@$webdav_port@g" ../conf/nginx_add_webdav
|
2016-12-27 10:44:40 +01:00
|
|
|
domain=$(ynh_app_setting_get seafile domain)
|
2015-08-24 20:45:36 +02:00
|
|
|
echo $(cat ../conf/nginx_add_webdav) | sudo tee -a /etc/nginx/conf.d/$domain.d/seafile.conf
|
|
|
|
|
|
|
|
# Add webdav config
|
|
|
|
sudo cp ../conf/seafdav.conf $final_path/conf/seafdav.conf
|
2015-08-29 13:25:04 +02:00
|
|
|
sudo sed -i "s@WEBDAV_PORT@$webdav_port@g" $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
|
|
|
|
sudo cp ../conf/add_sso_conf.py $final_path
|
|
|
|
sudo cp ../conf/add_sso_conf_webdav.py $final_path
|
|
|
|
sudo cp ../conf/remove_sso_conf.py $final_path
|
|
|
|
sudo python $final_path/add_sso_conf_webdav.py
|
|
|
|
|
|
|
|
# Update seafile config
|
2017-01-05 23:24:32 +01:00
|
|
|
echo 'COMPRESS_URL = MEDIA_URL' | sudo tee -a $final_path/conf/seahub_settings.py
|
|
|
|
echo "STATIC_URL = MEDIA_URL + 'assets/'" | sudo tee -a $final_path/conf/seahub_settings.py
|
2015-08-24 20:45:36 +02:00
|
|
|
|
|
|
|
# Add logrotate
|
|
|
|
sudo cp ../conf/logrotate /etc/logrotate.d/seafile
|
|
|
|
sudo sed -i "s@SEAFILE_DIR@$final_path@g" /etc/logrotate.d/seafile
|
|
|
|
sudo service rsyslog restart
|
|
|
|
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
|
|
|
|
if [[ $(sudo grep -c "LOGIN_URL" $final_path/conf/seahub_settings.py) == 0 ]]
|
|
|
|
then
|
|
|
|
echo "LOGIN_URL = '"$path"/accounts/login/'" | sudo tee -a $final_path/conf/seahub_settings.py
|
|
|
|
fi
|
|
|
|
|
2015-03-25 19:14:18 +01:00
|
|
|
# restore correct permissions
|
2016-12-27 10:44:40 +01:00
|
|
|
sudo 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
|
2017-01-05 23:24:32 +01:00
|
|
|
sudo rm -rf /tmp/seahub_cache
|
2015-08-29 13:25:04 +02:00
|
|
|
|
2015-03-25 19:14:18 +01:00
|
|
|
# restart seafile server
|
|
|
|
sudo service seafile-server start
|
|
|
|
|
|
|
|
# remove old version files
|
2017-01-05 23:24:32 +01:00
|
|
|
sudo rm -f $final_path/installed/seafile-server_${installed_version}*.tar*
|
|
|
|
sudo rm -f $final_path/seafile-server_${installed_version}_$architecture
|
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
|
|
|
|
|
|
|
# Reload Nginx and regenerate SSOwat conf
|
|
|
|
sudo service nginx reload
|
|
|
|
sudo yunohost app ssowatconf
|