2015-03-25 19:14:18 +01:00
|
|
|
#!/bin/bash
|
2015-10-28 16:04:51 +01:00
|
|
|
|
2015-03-25 19:14:18 +01:00
|
|
|
app=seafile
|
|
|
|
|
|
|
|
# Retrieve settings
|
|
|
|
installed_version=$(sudo yunohost app setting $app installed_version)
|
|
|
|
architecture=$(sudo yunohost app setting $app architecture)
|
|
|
|
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
2015-12-26 13:44:45 +01:00
|
|
|
seafile_version=5.0.3
|
2015-03-25 19:14:18 +01:00
|
|
|
final_path=/var/www/$app
|
|
|
|
|
|
|
|
# extract new version
|
|
|
|
sudo mkdir -p $final_path/seafile-server-$seafile_version
|
|
|
|
sudo tar xzf ../sources/'seafile-server_'$seafile_version'_'$architecture'.tar'
|
|
|
|
sudo mv seafile-server-$seafile_version/* $final_path/seafile-server-$seafile_version
|
|
|
|
sudo mv ../sources/'seafile-server_'$seafile_version'_'$architecture'.tar' $final_path/installed
|
|
|
|
|
|
|
|
# stop seafile server
|
|
|
|
sudo service seafile-server stop
|
|
|
|
|
|
|
|
# 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
|
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
|
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
|
|
|
|
sudo ../conf/upgrade_4.1.1.exp $root_pwd
|
|
|
|
sudo ../conf/upgrade_4.2.1.exp $root_pwd
|
2015-08-29 13:25:04 +02:00
|
|
|
sudo ../conf/upgrade_4.3.2.exp $root_pwd
|
2015-08-24 20:45:36 +02:00
|
|
|
;;
|
|
|
|
"4.1."* )
|
|
|
|
# Update seafile by script
|
|
|
|
sudo ../conf/upgrade_4.2.1.exp $root_pwd
|
2015-08-29 13:25:04 +02:00
|
|
|
sudo ../conf/upgrade_4.3.2.exp $root_pwd
|
2015-08-24 20:45:36 +02:00
|
|
|
;;
|
2015-10-22 22:38:59 +02:00
|
|
|
"4.3."* )
|
|
|
|
# Update seafile by script
|
|
|
|
sudo ../conf/upgrade_4.4.3.exp $root_pwd
|
|
|
|
;;
|
2015-12-26 13:44:45 +01:00
|
|
|
"4.4."* )
|
|
|
|
# Update seafile by script
|
|
|
|
sudo ../conf/upgrade_5.0.3.exp $root_pwd
|
|
|
|
;;
|
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
|
2015-08-29 13:25:04 +02:00
|
|
|
sudo yunohost app setting seafile webdav_port -v $webdav_port
|
2015-08-24 20:45:36 +02:00
|
|
|
|
|
|
|
# Disallow port that was used by old seafile client
|
|
|
|
ccnet_port=$(sudo yunohost app setting $app ccnet_port)
|
|
|
|
seafile_port=$(sudo yunohost app setting $app seafile_port)
|
|
|
|
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
|
|
|
|
domain=$(sudo yunohost app setting seafile domain)
|
|
|
|
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
|
|
|
|
echo 'COMPRESS_URL = MEDIA_URL' | sudo tee -a $final_path/seahub_settings.py
|
|
|
|
echo "STATIC_URL = MEDIA_URL + 'assets/'" | sudo tee -a $final_path/seahub_settings.py
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
# restore correct permissions
|
|
|
|
sudo chown -R www-data:www-data $final_path
|
|
|
|
|
2015-08-29 13:25:04 +02:00
|
|
|
# delete seafile cache
|
|
|
|
sudo rm -r /tmp/seahub_cache
|
|
|
|
|
2015-03-25 19:14:18 +01:00
|
|
|
# restart seafile server
|
|
|
|
sudo service seafile-server start
|
|
|
|
|
|
|
|
# remove old version files
|
|
|
|
sudo rm -f $final_path/installed/seafile-server_$installed_version_$architecture.tar
|
|
|
|
sudo rm -f $final_path/seafile-server_$installed_version_$architecture
|
|
|
|
|
|
|
|
# store new installed version
|
|
|
|
sudo yunohost app setting seafile installed_version -v $seafile_version
|
|
|
|
|
|
|
|
# Reload Nginx and regenerate SSOwat conf
|
|
|
|
sudo service nginx reload
|
|
|
|
sudo yunohost app ssowatconf
|