Merge pull request #16 from Josue-T/master

Full update app
This commit is contained in:
Josue-T 2017-02-16 23:12:57 +01:00 committed by GitHub
commit 30c522ae32
14 changed files with 395 additions and 121 deletions

1
.gitignore vendored
View file

@ -221,3 +221,4 @@ pip-log.txt
# From kateproject
.kateproject
.kateproject.d
.directory

View file

@ -27,7 +27,7 @@ From command line:
Infos
-----
Seafile server v5.0.3
Seafile server v6.0.6
Available for x64, i386, and Raspberry Pi architecture but only tested for x64 (feedback are welcome)
@ -52,6 +52,37 @@ TODO
- Auto login/logout, see #1
- Test of backup/restore script
Use a spial user and put seafile binary in /opt dir :
--------------------------------------
With this new package for a better security, it's possible to run seafile with a special user (seafile) put all seafile file in /opt/yunohost dir.
To do this open a console and do this command :
```
# stop seafile server
sudo service seafile-server stop
# Move all data to opt and change user
sudo mv /var/www/seafile /opt/yunohost/seafile
sudo addgroup seafile --system --quiet
sudo adduser seafile --disabled-login --ingroup seafile --system --quiet --shell /bin/bash --home /opt/yunohost/seafile
# Adapt configuration
sudo sed -i "s@user=www-data@user=seafile@g" /etc/init.d/seafile-server
sudo sed -i "s@seafile_dir=/var/www/seafile@seafile_dir=/opt/yunohost/seafile@g" /etc/init.d/seafile-server
sudo sed -i "s@alias /var/www/seafile/@alias /opt/yunohost/seafile/@g" /etc/nginx/conf.d/$(sudo yunohost app setting seafile domain).d/seafile.conf
# Set the good user for seafile
sudo chown seafile:seafile -R /opt/yunohost/seafile
sudo chown seafile:seafile -R /home/yunohost.app/seafile-data/
# Restart services
sudo rm -rf /tmp/seahub_cache
sudo systemctl daemon-reload
sudo service nginx reload
sudo service seafile-server start
```
Developper infos
----------------

12
conf/upgrade_5.1.exp Normal file
View file

@ -0,0 +1,12 @@
#!/usr/bin/expect
set timeout 5
set seafile_dir [lindex $argv 0]
set mysql_password [lindex $argv 1]
spawn $seafile_dir/upgrade/upgrade_5.0_5.1.sh
expect "to contiune"
send "\r";
interact

12
conf/upgrade_6.0.exp Normal file
View file

@ -0,0 +1,12 @@
#!/usr/bin/expect
set timeout 5
set seafile_dir [lindex $argv 0]
set mysql_password [lindex $argv 1]
spawn $seafile_dir/upgrade/upgrade_5.1_6.0.sh
expect "to contiune"
send "\r";
interact

View file

@ -1,23 +1,30 @@
{
"name": "Seafile",
"id": "seafile",
"packaging_format": 1,
"license": "free",
"url": "https://www.seafile.com",
"description": {
"en": "Open Source Cloud Storage",
"fr": "Stockage Cloud Open Source"
},
"developer": {
"maintainer": {
"name": "mbugeia",
"email": "maxime@max.privy.place"
},
"multi_instance": "false",
"multi_instance": false,
"services": [
"nginx",
"mysql"
],
"requirements": {
"yunohost": ">= 2.4.0"
},
"arguments": {
"install": [
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain for Seafile",
"fr": "Choisissez un domaine pour Seafile"
@ -26,6 +33,7 @@
},
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for Seafile",
"fr": "Choisissez un chemin pour Seafile"
@ -44,6 +52,7 @@
},
{
"name": "admin",
"type": "user",
"ask": {
"en": "Choose the admin user for Seafile",
"fr": "Choisissez l'administrateur de Seafile"
@ -52,6 +61,7 @@
},
{
"name": "admin_password",
"type": "password",
"ask": {
"en": "Enter a password for the administrator",
"fr": "Entrez un mot de passe pour l'administrateur"
@ -60,12 +70,12 @@
},
{
"name": "public_site",
"type": "boolean",
"ask": {
"en": "Is it a public site ? If you want to use a desktop client or the smartphone app, make Seafile public.",
"fr": "Est-ce un site public ? Pour utiliser un client sur PC ou l'application mobile, Seafile doit être public"
},
"choices": ["Yes", "No"],
"default": "Yes"
"default": "1"
},
{
"name": "architecture",

91
scripts/_common.sh Normal file
View file

@ -0,0 +1,91 @@
#!/bin/bash
seafile_version=6.0.7
## Adapt md5sum while you update app
x86_64sum="4ca3c1fc93e5b786eb5d3509f4a3b01a"
i386sum="743565be00189698318c8def0fbdaac0"
armsum="ee3ef5330a51498faf861594e0fe744a"
init_script() {
# Exit on command errors and treat unset variables as an error
set -eu
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
}
set_configuration() {
if [[ -e /var/www/$app ]]
then
final_path=/var/www/$app
seafile_user=www-data
elif [[ -e /opt/yunohost/$app ]]
then
final_path=/opt/yunohost/$app
seafile_user=seafile
else
ynh_die "Error : can't find seafile path"
fi
}
get_source() {
if [[ $1 == 'arm' ]]
then
wget -q -O '/tmp/seafile_src.tar.gz' 'https://github.com/haiwen/seafile-rpi/releases/download/v'$2'/seafile-server_'$2'_stable_pi.tar.gz'
md5sum=$armsum
elif [[ $1 == 'x86-64' ]]
then
wget -q -O '/tmp/seafile_src.tar.gz' 'https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_'$2'_x86-64.tar.gz'
md5sum=$x86_64sum
else
wget -q -O '/tmp/seafile_src.tar.gz' 'https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_'$2'_i386.tar.gz'
md5sum=$i386sum
fi
if [[ ! -e '/tmp/seafile_src.tar.gz' ]] || [[ $(md5sum '/tmp/seafile_src.tar.gz' | cut -d' ' -f1) != $md5sum ]]
then
ynh_die "Error : can't get seafile source"
fi
}
CHECK_VAR () { # Vérifie que la variable n'est pas vide.
# $1 = Variable à vérifier
# $2 = Texte à afficher en cas d'erreur
test -n "$1" || (echo "$2" >&2 && false)
}
# Ignore the yunohost-cli log to prevent errors with conditionals commands
# usage: NO_LOG COMMAND
# Simply duplicate the log, execute the yunohost command and replace the log without the result of this command
# It's a very badly hack...
# Petite copie perso à mon usage ;)
NO_LOG () {
ynh_cli_log=/var/log/yunohost/yunohost-cli.log
sudo cp -a ${ynh_cli_log} ${ynh_cli_log}-move
eval $@
exit_code=$?
sudo mv ${ynh_cli_log}-move ${ynh_cli_log}
return $?
}
CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence à la fin.
if [ "${path:0:1}" != "/" ]; then # Si le premier caractère n'est pas un /
path="/$path" # Ajoute un / en début de path
fi
if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then # Si le dernier caractère est un / et que ce n'est pas le seul caractère.
path="${path:0:${#path}-1}" # Supprime le dernier caractère
fi
}
FIND_PORT () { # Cherche un port libre.
# $1 = Numéro de port pour débuter la recherche.
port=$1
while ! sudo yunohost app checkport $port ; do
port=$((port+1))
done
CHECK_VAR "$port" "port empty"
}

View file

@ -1,6 +1,44 @@
#!/bin/bash
set -e
######## Actually we cant use common script in backup / restore script see this issue for more informations : https://dev.yunohost.org/issues/621
# # Import common cmd
# source ./_common.sh
#
######## We implement manually this fonctions
init_script() {
# Exit on command errors and treat unset variables as an error
set -eu
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
}
set_configuration() {
if [[ -e /var/www/$app ]]
then
final_path=/var/www/$app
seafile_user=www-data
elif [[ -e /opt/yunohost/$app ]]
then
final_path=/opt/yunohost/$app
seafile_user=seafile
else
ynh_die "Error : can't find seafile path"
fi
}
######## End of common fonctions
# Init script
init_script
# Set configuration for user and final path
set_configuration
# The parameter $1 is the backup directory location dedicated to the app
BACKUP_DIR=$1
@ -9,12 +47,12 @@ BACKUP_DIR=$1
APP=$2
# retrieve useful param
domain=$(sudo yunohost app setting ${APP} domain)
db_pwd=$(sudo yunohost app setting ${APP} db_pwd)
domain=$(ynh_app_setting_get ${APP} domain)
db_pwd=$(ynh_app_setting_get ${APP} mysqlpwd)
# Backup app files
sudo mkdir -p "${BACKUP_DIR}/www"
sudo cp -a /var/www/${APP}/. "${BACKUP_DIR}/www"
sudo cp -a $final_path/. "${BACKUP_DIR}/www"
# Backup conf files
sudo mkdir -p "${BACKUP_DIR}/conf"
@ -30,5 +68,3 @@ sudo cp -a /home/yunohost.app/seafile-data/. "${BACKUP_DIR}/data"
mysqldump -u ${APP} -p$db_pwd ccnetdb | sudo dd of=${BACKUP_DIR}/ccnetdb.dmp
mysqldump -u ${APP} -p$db_pwd seafiledb | sudo dd of=${BACKUP_DIR}/seafiledb.dmp
mysqldump -u ${APP} -p$db_pwd seahubdb | sudo dd of=${BACKUP_DIR}/seahubdb.dmp
exit 0

View file

@ -1,77 +1,75 @@
#!/bin/bash
app=seafile
# Import common cmd
source ./_common.sh
# Init script
init_script
# Retrieve arguments
domain=$1
path=$2
server_name=$3
admin=$4
admin_password=$5
is_public=$6
architecture=$7
final_path=/var/www/$app
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
server_name=$YNH_APP_ARG_SERVER_NAME
admin=$YNH_APP_ARG_ADMIN
admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
is_public=$YNH_APP_ARG_PUBLIC_SITE
architecture=$YNH_APP_ARG_ARCHITECTURE
seafile_data=/home/yunohost.app/seafile-data
seafile_version=5.0.3
final_path=/var/www/$app
seafile_user=www-data
# Correct path if it is not correct
CHECK_PATH
# Check domain/path availability
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|| ynh_die "Path not available: ${domain}${path}"
# Download new version from sources
get_source $architecture $seafile_version
# Retrieve admin email
admin_email=$(sudo yunohost user info $admin | grep mail: | sed "s/mail: //g")
port=''
findPort () {
port=$1
sudo yunohost app checkport $port
while [[ ! $? -eq 0 ]]
do
port=$(($port + 1))
sudo yunohost app checkport $port
done
return $port
}
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a $app \
|| (echo "Path not available: $domain$path" && exit 1)
# Check dependencies
sudo apt-get update
sudo apt-get install -qq python2.7 python-setuptools python-simplejson python-imaging python-mysqldb python-flup expect
# Copy files to the right place
test -e $final_path && sudo rm -rf "$final_path"
test -e $seafile_data && sudo rm -rf "$seafile_data"
sudo mkdir -p $final_path
sudo mkdir -p $final_path/installed
sudo mkdir -p $final_path/logs
sudo mkdir -p $final_path/seafile-data
sudo mkdir -p $final_path/seafile-server-$seafile_version
sudo tar xzf ../sources/'seafile-server_'$seafile_version'_'$architecture'.tar.gz'
sudo tar xzf '/tmp/seafile_src.tar.gz'
sudo mv seafile-server-$seafile_version/* $final_path/seafile-server-$seafile_version
sudo mv ../sources/'seafile-server_'$seafile_version'_'$architecture'.tar.gz' $final_path/installed
sudo mv '/tmp/seafile_src.tar.gz' $final_path/installed/seafile-server_${seafile_version}.tar.gz
# Find available ports
findPort 8000
NO_LOG FIND_PORT 8000
seahub_port=$port
findPort 8082
NO_LOG FIND_PORT 8082
fileserver_port=$port
findPort 8080
NO_LOG FIND_PORT 8080
webdav_port=$port
# store config in yunohost
sudo yunohost app setting $app seahub_port -v $seahub_port
sudo yunohost app setting $app fileserver_port -v $fileserver_port
sudo yunohost app setting $app webdav_port -v $webdav_port
sudo yunohost app setting $app is_public -v $is_public
sudo yunohost app setting $app architecture -v $architecture
sudo yunohost app setting $app installed_version -v $seafile_version
ynh_app_setting_set $app seahub_port $seahub_port
ynh_app_setting_set $app fileserver_port $fileserver_port
ynh_app_setting_set $app webdav_port $webdav_port
ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set $app architecture $architecture
ynh_app_setting_set $app installed_version $seafile_version
# init databases
db_user=$app
db_pwd=$(openssl rand -hex 15)
sudo yunohost app initdb -d ccnetdb -p $db_pwd $db_user
sudo yunohost app initdb -d seafiledb -p $db_pwd $db_user
sudo yunohost app initdb -d seahubdb -p $db_pwd $db_user
sudo yunohost app setting seafile db_pwd -v $db_pwd
dbuser=seafile
db_pwd=$(ynh_string_random 15)
ynh_app_setting_set "$app" mysqlpwd "$db_pwd"
ynh_mysql_create_db ccnetdb "$dbuser" "$db_pwd"
ynh_mysql_create_db seafiledb "$dbuser" "$db_pwd"
ynh_mysql_create_db seahubdb "$dbuser" "$db_pwd"
# Run install script
sudo chmod +x ../conf/install.exp
@ -87,6 +85,7 @@ echo 'SERVE_STATIC = False' | sudo tee -a $final_path/conf/seahub_settings.py
echo 'MEDIA_URL = "'$path'/media/"' | sudo tee -a $final_path/conf/seahub_settings.py
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
echo "LOGIN_URL = '"$path"/accounts/login/'" | sudo tee -a $final_path/conf/seahub_settings.py
# Email configuration
echo 'EMAIL_USE_TLS = False' | sudo tee -a $final_path/conf/seahub_settings.py
@ -127,12 +126,12 @@ sudo cp ../conf/first_launch.exp $final_path
sudo chmod +x $final_path/first_launch.exp
# Set permissions to seafile directory
sudo chown -R www-data:www-data $final_path
sudo chown -R www-data:www-data $seafile_data
sudo chown -R $seafile_user:$seafile_user $final_path
sudo chown -R $seafile_user:$seafile_user $seafile_data
# Start seafile, seahub and populate admin account
sudo su - www-data -s /bin/bash -c "/var/www/seafile/seafile-server-$seafile_version/seafile.sh start"
sudo su - www-data -s /bin/bash -c "$final_path/first_launch.exp $final_path/seafile-server-$seafile_version $admin_email $admin_password"
sudo su - $seafile_user -s /bin/bash -c "$final_path/seafile-server-$seafile_version/seafile.sh start"
sudo su - $seafile_user -s /bin/bash -c "$final_path/first_launch.exp $final_path/seafile-server-$seafile_version $admin_email $admin_password"
# Add sso config to unprotect domain.tld/seafhttp + domain.tld/seafdav do in /etc/ssowat/conf.json.persistent
sudo cp ../conf/add_sso_conf.py $final_path
@ -140,13 +139,13 @@ sudo cp ../conf/remove_sso_conf.py $final_path
sudo python $final_path/add_sso_conf.py
# unprotect media
sudo yunohost app setting seafile unprotected_uris -v "/media"
ynh_app_setting_set seafile unprotected_uris "/media"
if [ "$is_public" = "No" ]
if [ "$is_public" = "0" ]
then
sudo yunohost app setting seafile unprotected_uris -d
ynh_app_setting_delete seafile unprotected_uris
else
sudo yunohost app setting seafile unprotected_uris -v "/"
ynh_app_setting_set seafile unprotected_uris "/"
fi
# Add logrotate
@ -162,6 +161,6 @@ sudo service nginx reload
sudo yunohost app ssowatconf
# Restart seafile
sudo su - www-data -s /bin/bash -c "/var/www/seafile/seafile-server-latest/seahub.sh stop"
sudo su - $seafile_user -s /bin/bash -c "$final_path/seafile-server-latest/seahub.sh stop"
sudo service seafile-server stop
sudo service seafile-server start

View file

@ -1,20 +1,29 @@
#!/bin/bash
domain=$(sudo yunohost app setting seafile domain)
root_pwd=$(sudo cat /etc/yunohost/mysql)
sudo service seafile-server stop
# Import common cmd
source ./_common.sh
# Init script
init_script
sudo service seafile-server stop || true
# remove sso config to unprotect domain.tld/seafhttp in /etc/ssowat/conf.json.persistent
sudo python /var/www/seafile/remove_sso_conf.py
sudo rm -rf /var/www/seafile
sudo rm -f /etc/nginx/conf.d/$domain.d/seafile.conf
test -e /var/www/$app/remove_sso_conf.py && sudo python /var/www/$app/remove_sso_conf.py
test -e /opt/yunohost/$app/remove_sso_conf.py && sudo python /opt/yunohost/$app/remove_sso_conf.py
sudo rm -rf /var/www/$app
sudo rm -rf /opt/yunohost/$app
sudo rm -f /etc/init.d/seafile-server
sudo rm -rf /home/yunohost.app/seafile-data
sudo rm -r /tmp/seahub_cache
sudo rm -rf /tmp/seahub_cache
# Remove databases
mysql -u root -p$root_pwd -e "DROP DATABASE ccnetdb ; DROP DATABASE seafiledb ; DROP DATABASE seahubdb ; DROP USER seafile@localhost ;"
root_pwd=$(sudo cat /etc/yunohost/mysql)
mysql -u root -p$root_pwd -e "DROP DATABASE ccnetdb ; DROP DATABASE seafiledb ; DROP DATABASE seahubdb ; DROP USER seafile@localhost ;" || true
# Remove domain config
domain=$(ynh_app_setting_get seafile domain)
sudo rm -f /etc/nginx/conf.d/$domain.d/seafile.conf
sudo yunohost service remove seafile-server

View file

@ -1,48 +1,86 @@
#!/bin/bash
set -e
######## Actually we cant use common script in backup / restore script see this issue for more informations : https://dev.yunohost.org/issues/621
# # Import common cmd
# source ./_common.sh
#
######## We implement manually this fonctions
init_script() {
# Exit on command errors and treat unset variables as an error
set -eu
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
}
CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence à la fin.
if [ "${path:0:1}" != "/" ]; then # Si le premier caractère n'est pas un /
path="/$path" # Ajoute un / en début de path
fi
if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then # Si le dernier caractère est un / et que ce n'est pas le seul caractère.
path="${path:0:${#path}-1}" # Supprime le dernier caractère
fi
}
######## End of common fonctions
# Init script
init_script
# Retrieve arguments
final_path=/var/www/$app
seafile_user=www-data
# The parameter $1 is the backup directory location dedicated to the app
BACKUP_DIR=$1
# The parameter $2 is the id of the app instance ex: strut__2
APP=$2
# retrieve useful param
domain=$(sudo yunohost app setting ${APP} domain)
db_pwd=$(sudo yunohost app setting ${APP} db_pwd)
path=$(sudo yunohost app setting ${APP} path)
domain=$(ynh_app_setting_get ${app} domain)
db_pwd=$(ynh_app_setting_get ${app} mysqlpwd)
path=$(ynh_app_setting_get ${app} path)
# Correct path if it is not correct
CHECK_PATH
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a ${APP} \
|| (echo "Path not available: $domain$path" && exit 1)
sudo yunohost app checkurl $domain$path -a ${app} \
|| (echo "Path not available: $domain$path" && ynh_die "Error : path not available")
# Restore dependencies
sudo apt-get update
sudo apt-get install -qq python2.7 python-setuptools python-simplejson python-imaging python-mysqldb python-flup expect
# Restore app files
final_path=/var/www/${APP}
final_path=$final_path
sudo mkdir -p $final_path
sudo cp -a "${BACKUP_DIR}/www/." $final_path
sudo chown -R www-data:www-data $final_path
sudo chown -R $seafile_user:$seafile_user $final_path
# Restore conf files
sudo cp -a "${BACKUP_DIR}/conf/${APP}.conf" /etc/nginx/conf.d/$domain.d/${APP}.conf
sudo cp -a "${BACKUP_DIR}/conf/${APP}" /etc/logrotate.d/${APP}
sudo cp -a "${BACKUP_DIR}/conf/${app}.conf" /etc/nginx/conf.d/$domain.d/${app}.conf
sudo cp -a "${BACKUP_DIR}/conf/${app}" /etc/logrotate.d/${app}
sudo cp -a "${BACKUP_DIR}/conf/seafile-server" /etc/init.d/seafile-server
sudo chmod +x /etc/init.d/seafile-server
# Restore data
seafile_data=/home/yunohost.app/seafile-data
mkdir -p $seafile_data
sudo mkdir -p $seafile_data
sudo cp -a "${BACKUP_DIR}/data/." /home/yunohost.app/seafile-data/.
sudo chown -R www-data:www-data $seafile_data
sudo chown -R $seafile_user:$seafile_user $seafile_data
# Restore mysql dump
sudo su -c "mysql -u ${APP} -p$db_pwd ccnetdb < ${BACKUP_DIR}/ccnetdb.dmp"
sudo su -c "mysql -u ${APP} -p$db_pwd seafiledb < ${BACKUP_DIR}/seafiledb.dmp"
sudo su -c "mysql -u ${APP} -p$db_pwd seahubdb < ${BACKUP_DIR}/seahubdb.dmp"
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"
sudo su -c "mysql -u ${app} -p$db_pwd ccnetdb < ${BACKUP_DIR}/ccnetdb.dmp"
sudo su -c "mysql -u ${app} -p$db_pwd seafiledb < ${BACKUP_DIR}/seafiledb.dmp"
sudo su -c "mysql -u ${app} -p$db_pwd seahubdb < ${BACKUP_DIR}/seahubdb.dmp"
# Restore sso persistent config
sudo python $final_path/add_sso_conf.py
@ -53,10 +91,8 @@ sudo yunohost service add seafile-server
# Reload/restart services
sudo update-rc.d seafile-server defaults
sudo service rsyslog restart
sudo service nginx reload
sudo yunohost app ssowatconf
sudo service nginx reload
# start seafile
sudo service seafile-server start
exit 0

View file

@ -1,35 +1,48 @@
#!/bin/bash
app=seafile
# Import common cmd
source ./_common.sh
# Init script
init_script
# Retrieve settings
installed_version=$(sudo yunohost app setting $app installed_version)
architecture=$(sudo yunohost app setting $app architecture)
installed_version=$(ynh_app_setting_get $app installed_version)
architecture=$(ynh_app_setting_get $app architecture)
path=$(ynh_app_setting_get $app path)
root_pwd=$(sudo cat /etc/yunohost/mysql)
seafile_version=5.0.3
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.gz'
sudo mv seafile-server-$seafile_version/* $final_path/seafile-server-$seafile_version
sudo mv ../sources/'seafile-server_'$seafile_version'_'$architecture'.tar.gz' $final_path/installed
# Set configuration for user and final path
set_configuration
# Download new version from sources
get_source $architecture $seafile_version
# stop seafile server
sudo service seafile-server stop
# extract new version
test -e $final_path/seafile-server-$seafile_version && sudo rm -rf "$final_path/seafile-server-$seafile_version"
sudo mkdir -p $final_path/seafile-server-$seafile_version
sudo tar xzf '/tmp/seafile_src.tar.gz'
sudo mv seafile-server-$seafile_version/* $final_path/seafile-server-$seafile_version
sudo mv '/tmp/seafile_src.tar.gz' $final_path/installed/seafile-server_${seafile_version}.tar.gz
# permission to execute update script and expect helper
sudo chmod +x ../conf/upgrade_4.1.1.exp
sudo chmod +x ../conf/upgrade_4.2.1.exp
sudo chmod +x ../conf/upgrade_4.3.2.exp
sudo chmod +x ../conf/upgrade_4.4.3.exp
sudo chmod +x ../conf/upgrade_5.0.3.exp
sudo chmod +x ../conf/upgrade_5.1.exp
sudo chmod +x ../conf/upgrade_6.0.exp
sudo chmod +x $final_path/seafile-server-$seafile_version/upgrade/upgrade_4.0_4.1.sh
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
sudo chmod +x $final_path/seafile-server-$seafile_version/upgrade/upgrade_4.3_4.4.sh
sudo chmod +x $final_path/seafile-server-$seafile_version/upgrade/upgrade_4.4_5.0.sh
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
# do the upgrade
case $installed_version in
"4.0."* )
@ -39,6 +52,8 @@ case $installed_version in
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
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
;;
"4.1."* )
# Update seafile by script
@ -46,15 +61,31 @@ case $installed_version in
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
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
;;
"4.3."* )
# Update seafile by script
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
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
;;
"4.4."* )
# Update seafile by script
sudo ../conf/upgrade_5.0.3.exp $final_path/seafile-server-$seafile_version $root_pwd
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
;;
esac
@ -77,17 +108,17 @@ then
findPort 8080
webdav_port=$port
sudo yunohost app setting seafile webdav_port -v $webdav_port
ynh_app_setting_set seafile webdav_port $webdav_port
# 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)
ccnet_port=$(ynh_app_setting_get $app ccnet_port)
seafile_port=$(ynh_app_setting_get $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)
domain=$(ynh_app_setting_get seafile domain)
echo $(cat ../conf/nginx_add_webdav) | sudo tee -a /etc/nginx/conf.d/$domain.d/seafile.conf
# Add webdav config
@ -101,8 +132,8 @@ then
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
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
# Add logrotate
sudo cp ../conf/logrotate /etc/logrotate.d/seafile
@ -110,21 +141,27 @@ then
sudo service rsyslog restart
fi
# 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
# restore correct permissions
sudo chown -R www-data:www-data $final_path
sudo chown -R $seafile_user:$seafile_user $final_path
# delete seafile cache
sudo rm -r /tmp/seahub_cache
sudo rm -rf /tmp/seahub_cache
# 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
sudo rm -f $final_path/installed/seafile-server_${installed_version}*.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
ynh_app_setting_set $app installed_version $seafile_version
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload