Merge pull request #9 from mbugeia/Dev

Update to Seafile 5.0.3
This commit is contained in:
tostaki 2016-01-02 18:33:11 +01:00
commit be32ffb163
12 changed files with 208 additions and 47 deletions

22
LICENSE Normal file
View file

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 tostaki
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -27,15 +27,43 @@ From command line:
Infos Infos
----- -----
Seafile server v4.4.3 Seafile server v5.0.3
Available for x64, i386, and Raspberry architecture but only tested for x64 (feedback are welcome) Available for x64, i386, and Raspberry Pi architecture but only tested for x64 (feedback are welcome)
Seafile no longer supports armhf architectures AFAIK. Seafile no longer distribute binary for generic armhf architectures but rpi binary could work.
/!\ To login use your yunohost email not your username. /!\ To login use your yunohost email not your username.
License
-------
Seafile server and its desktop clients are published under GPLv2.
Mobile clients are published under the GPLv3.
The Seafile server's web end, i.e. Seahub, is published under the Apache License.
This package is published under MIT License
TODO TODO
----- -----
- Auto login/logout - Auto login/logout, see #1
- Test of backup/restore script
Developper infos
----------------
Please do your pull request to the Dev branch.
Test or upgrade to dev version:
```
su - admin
git clone -b Dev https://github.com/mbugeia/seafile_ynh
# to install
sudo yunohost app install -l Seafile /home/admin/seafile_ynh
# to upgrade
sudo yunohost app upgrade -f /home/admin/seafile_ynh seafile
```

View file

@ -7,7 +7,7 @@ set seafile_data [lindex $argv 2]
set fileserver_port [lindex $argv 3] set fileserver_port [lindex $argv 3]
set db_pwd [lindex $argv 4] set db_pwd [lindex $argv 4]
spawn /var/www/seafile/seafile-server-4.4.3/setup-seafile-mysql.sh spawn /var/www/seafile/seafile-server-5.0.3/setup-seafile-mysql.sh
expect "Press ENTER to continue" expect "Press ENTER to continue"
send "\r"; send "\r";

11
conf/upgrade_5.0.3.exp Normal file
View file

@ -0,0 +1,11 @@
#!/usr/bin/expect
set timeout 5
set mysql_password [lindex $argv 0]
spawn /var/www/seafile/seafile-server-5.0.3/upgrade/upgrade_4.4_5.0.sh
expect "to contiune"
send "\r";
interact

View file

@ -6,11 +6,14 @@
"fr": "Stockage Cloud Open Source" "fr": "Stockage Cloud Open Source"
}, },
"developer": { "developer": {
"name": "", "name": "mbugeia",
"email": "", "email": "maxime@max.privy.place"
"url": ""
}, },
"multi_instance": "false", "multi_instance": "false",
"services": [
"nginx",
"mysql"
],
"arguments": { "arguments": {
"install": [ "install": [
{ {

32
scripts/backup Normal file
View file

@ -0,0 +1,32 @@
#!/bin/bash
set -e
# 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 mysqlpwd)
# Backup app files
sudo mkdir -p "${BACKUP_DIR}/www"
sudo cp -a /var/www/$app/. "${BACKUP_DIR}/www"
# Backup conf files
sudo mkdir -p "${BACKUP_DIR}/conf"
sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf "${BACKUP_DIR}/conf/${app}.conf"
sudo cp -a /etc/logrotate.d/seafile "${BACKUP_DIR}/conf/seafile"
sudo cp -a /etc/init.d/seafile-server "${BACKUP_DIR}/conf/seafile-server"
# Backup data
sudo mkdir -p "${BACKUP_DIR}/data"
sudo cp -a /home/yunohost.app/seafile-data/. "${BACKUP_DIR}/data"
# Backup mysql
sudo mysqldump -u $app -p$db_pwd ccnetdb > "${BACKUP_DIR}/ccnetdb.dmp"
sudo mysqldump -u $app -p$db_pwd seafiledb > "${BACKUP_DIR}/seafiledb.dmp"
sudo mysqldump -u $app -p$db_pwd seahubdb > "${BACKUP_DIR}/seahubdb.dmp"

View file

@ -1,4 +1,7 @@
#!/bin/bash #!/bin/bash
app=seafile
# Retrieve arguments # Retrieve arguments
domain=$1 domain=$1
path=$2 path=$2
@ -7,9 +10,9 @@ admin=$4
admin_password=$5 admin_password=$5
is_public=$6 is_public=$6
architecture=$7 architecture=$7
final_path=/var/www/seafile final_path=/var/www/$app
seafile_data=/home/yunohost.app/seafile-data seafile_data=/home/yunohost.app/seafile-data
seafile_version=4.4.3 seafile_version=5.0.3
# Retrieve admin email # Retrieve admin email
admin_email=$(sudo yunohost user info $admin | grep mail: | sed "s/mail: //g") admin_email=$(sudo yunohost user info $admin | grep mail: | sed "s/mail: //g")
@ -29,12 +32,11 @@ findPort () {
} }
# Check domain/path availability # Check domain/path availability
sudo yunohost app checkurl $domain$path -a seafile sudo yunohost app checkurl $domain$path -a $app \
if [[ ! $? -eq 0 ]]; then || (echo "Path not available: $domain$path" && exit 1)
exit 1
fi
# Check dependencies # Check dependencies
sudo apt-get update
sudo apt-get install -qq python2.7 python-setuptools python-simplejson python-imaging python-mysqldb python-flup expect sudo apt-get install -qq python2.7 python-setuptools python-simplejson python-imaging python-mysqldb python-flup expect
# Copy files to the right place # Copy files to the right place
@ -43,9 +45,9 @@ sudo mkdir -p $final_path/installed
sudo mkdir -p $final_path/logs sudo mkdir -p $final_path/logs
sudo mkdir -p $final_path/seafile-data sudo mkdir -p $final_path/seafile-data
sudo mkdir -p $final_path/seafile-server-$seafile_version sudo mkdir -p $final_path/seafile-server-$seafile_version
sudo tar xzf ../sources/'seafile-server_'$seafile_version'_'$architecture'.tar' 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 seafile-server-$seafile_version/* $final_path/seafile-server-$seafile_version
sudo mv ../sources/'seafile-server_'$seafile_version'_'$architecture'.tar' $final_path/installed sudo mv ../sources/'seafile-server_'$seafile_version'_'$architecture'.tar.gz' $final_path/installed
# Find available ports # Find available ports
findPort 8000 findPort 8000
@ -56,16 +58,16 @@ findPort 8080
webdav_port=$port webdav_port=$port
# store config in yunohost # store config in yunohost
sudo yunohost app setting seafile seahub_port -v $seahub_port sudo yunohost app setting $app seahub_port -v $seahub_port
sudo yunohost app setting seafile fileserver_port -v $fileserver_port sudo yunohost app setting $app fileserver_port -v $fileserver_port
sudo yunohost app setting seafile webdav_port -v $webdav_port sudo yunohost app setting $app webdav_port -v $webdav_port
sudo yunohost app setting seafile is_public -v $is_public sudo yunohost app setting $app is_public -v $is_public
sudo yunohost app setting seafile architecture -v $architecture sudo yunohost app setting $app architecture -v $architecture
sudo yunohost app setting seafile installed_version -v $seafile_version sudo yunohost app setting $app installed_version -v $seafile_version
# init databases # init databases
db_user=seafile db_user=$app
db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p') db_pwd=$(openssl rand -hex 15)
sudo yunohost app initdb -d ccnetdb -p $db_pwd $db_user 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 seafiledb -p $db_pwd $db_user
sudo yunohost app initdb -d seahubdb -p $db_pwd $db_user sudo yunohost app initdb -d seahubdb -p $db_pwd $db_user
@ -77,29 +79,29 @@ sudo chmod +x $final_path/seafile-server-$seafile_version/setup-seafile-mysql.sh
sudo ../conf/install.exp $server_name $domain $seafile_data $fileserver_port $db_pwd sudo ../conf/install.exp $server_name $domain $seafile_data $fileserver_port $db_pwd
# Update seafile config # Update seafile config
sudo sed -i "s@http://@https://@g" $final_path/ccnet/ccnet.conf sudo sed -i "s@http://@https://@g" $final_path/conf/ccnet.conf
sudo sed -i "s@:8000@$path@g" $final_path/ccnet/ccnet.conf sudo sed -i "s@:8000@$path@g" $final_path/conf/ccnet.conf
echo 'FILE_SERVER_ROOT = "https://'$domain'/seafhttp"' | sudo tee -a $final_path/seahub_settings.py echo 'FILE_SERVER_ROOT = "https://'$domain'/seafhttp"' | sudo tee -a $final_path/conf/seahub_settings.py
echo 'SITE_ROOT = "'$path'/"' | sudo tee -a $final_path/seahub_settings.py echo 'SITE_ROOT = "'$path'/"' | sudo tee -a $final_path/conf/seahub_settings.py
echo 'SERVE_STATIC = False' | sudo tee -a $final_path/seahub_settings.py echo 'SERVE_STATIC = False' | sudo tee -a $final_path/conf/seahub_settings.py
echo 'MEDIA_URL = "'$path'/media/"' | sudo tee -a $final_path/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/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/seahub_settings.py echo "STATIC_URL = MEDIA_URL + 'assets/'" | sudo tee -a $final_path/conf/seahub_settings.py
# Email configuration # Email configuration
echo 'EMAIL_USE_TLS = False' | sudo tee -a $final_path/seahub_settings.py echo 'EMAIL_USE_TLS = False' | sudo tee -a $final_path/conf/seahub_settings.py
echo 'EMAIL_HOST = "localhost"' | sudo tee -a $final_path/seahub_settings.py echo 'EMAIL_HOST = "localhost"' | sudo tee -a $final_path/conf/seahub_settings.py
echo 'EMAIL_HOST_USER = "seafile@'$domain'"' | sudo tee -a $final_path/seahub_settings.py echo 'EMAIL_HOST_USER = "seafile@'$domain'"' | sudo tee -a $final_path/conf/seahub_settings.py
echo 'EMAIL_HOST_PASSWORD = ""' | sudo tee -a $final_path/seahub_settings.py echo 'EMAIL_HOST_PASSWORD = ""' | sudo tee -a $final_path/conf/seahub_settings.py
echo 'EMAIL_PORT = "25"' | sudo tee -a $final_path/seahub_settings.py echo 'EMAIL_PORT = "25"' | sudo tee -a $final_path/conf/seahub_settings.py
echo 'DEFAULT_FROM_EMAIL = "seafile@'$domain'"' | sudo tee -a $final_path/seahub_settings.py echo 'DEFAULT_FROM_EMAIL = "seafile@'$domain'"' | sudo tee -a $final_path/conf/seahub_settings.py
echo 'SERVER_EMAIL = "seafile@'$domain'"' | sudo tee -a $final_path/seahub_settings.py echo 'SERVER_EMAIL = "seafile@'$domain'"' | sudo tee -a $final_path/conf/seahub_settings.py
# LDAP configuration # LDAP configuration
echo '[LDAP]' | sudo tee -a $final_path/ccnet/ccnet.conf echo '[LDAP]' | sudo tee -a $final_path/conf/ccnet.conf
echo 'HOST = ldap://localhost:389' | sudo tee -a $final_path/ccnet/ccnet.conf echo 'HOST = ldap://localhost:389' | sudo tee -a $final_path/conf/ccnet.conf
echo 'BASE = ou=users,dc=yunohost,dc=org' | sudo tee -a $final_path/ccnet/ccnet.conf echo 'BASE = ou=users,dc=yunohost,dc=org' | sudo tee -a $final_path/conf/ccnet.conf
echo 'LOGIN_ATTR = mail' | sudo tee -a $final_path/ccnet/ccnet.conf echo 'LOGIN_ATTR = mail' | sudo tee -a $final_path/conf/ccnet.conf
# Add Seafile Server to startup # Add Seafile Server to startup
sudo cp ../conf/seafile-server /etc/init.d sudo cp ../conf/seafile-server /etc/init.d

56
scripts/restore Normal file
View file

@ -0,0 +1,56 @@
#!/bin/bash
set -e
# 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
domain=$(sudo yunohost app setting $app domain)
path=$(sudo yunohost app setting $app path)
db_pwd=$(sudo yunohost app setting $app mysqlpwd)
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a $app \
|| (echo "Path not available: $domain$path" && exit 1)
# 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
sudo mkdir -p $final_path
sudo cp -a "${BACKUP_DIR}/www/." $final_path
sudo chown -R www-data:www-data $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/seafile" /etc/logrotate.d/seafile
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 cp -a "${BACKUP_DIR}/data/." /home/yunohost.app/seafile-data/.
sudo chown -R www-data:www-data $seafile_data
# Restore mysql dump
sudo mysql -u $app -p$db_pwd ccnetdb < "${BACKUP_DIR}/ccnetdb.dmp"
sudo mysql -u $app -p$db_pwd seafiledb < "${BACKUP_DIR}/seafiledb.dmp"
sudo mysql -u $app -p$db_pwd seahubdb < "${BACKUP_DIR}/seahubdb.dmp"
# Add Seafile to YunoHost's monitored services
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
# start seafile
sudo service seafile-server start

View file

@ -1,18 +1,19 @@
#!/bin/bash #!/bin/bash
app=seafile app=seafile
# Retrieve settings # Retrieve settings
installed_version=$(sudo yunohost app setting $app installed_version) installed_version=$(sudo yunohost app setting $app installed_version)
architecture=$(sudo yunohost app setting $app architecture) architecture=$(sudo yunohost app setting $app architecture)
root_pwd=$(sudo cat /etc/yunohost/mysql) root_pwd=$(sudo cat /etc/yunohost/mysql)
seafile_version=4.4.3 seafile_version=5.0.3
final_path=/var/www/$app final_path=/var/www/$app
# extract new version # extract new version
sudo mkdir -p $final_path/seafile-server-$seafile_version sudo mkdir -p $final_path/seafile-server-$seafile_version
sudo tar xzf ../sources/'seafile-server_'$seafile_version'_'$architecture'.tar' 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 seafile-server-$seafile_version/* $final_path/seafile-server-$seafile_version
sudo mv ../sources/'seafile-server_'$seafile_version'_'$architecture'.tar' $final_path/installed sudo mv ../sources/'seafile-server_'$seafile_version'_'$architecture'.tar.gz' $final_path/installed
# stop seafile server # stop seafile server
sudo service seafile-server stop sudo service seafile-server stop
@ -22,10 +23,12 @@ sudo chmod +x ../conf/upgrade_4.1.1.exp
sudo chmod +x ../conf/upgrade_4.2.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.3.2.exp
sudo chmod +x ../conf/upgrade_4.4.3.exp sudo chmod +x ../conf/upgrade_4.4.3.exp
sudo chmod +x ../conf/upgrade_5.0.3.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.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.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.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.3_4.4.sh
sudo chmod +x $final_path/seafile-server-$seafile_version/upgrade/upgrade_4.4_5.0.sh
# do the upgrade # do the upgrade
case $installed_version in case $installed_version in
@ -44,6 +47,10 @@ case $installed_version in
# Update seafile by script # Update seafile by script
sudo ../conf/upgrade_4.4.3.exp $root_pwd sudo ../conf/upgrade_4.4.3.exp $root_pwd
;; ;;
"4.4."* )
# Update seafile by script
sudo ../conf/upgrade_5.0.3.exp $root_pwd
;;
esac esac
## Install webdav and logrotate if not installed ## Install webdav and logrotate if not installed
@ -108,7 +115,7 @@ sudo rm -r /tmp/seahub_cache
sudo service seafile-server start sudo service seafile-server start
# remove old version files # remove old version files
sudo rm -f $final_path/installed/seafile-server_$installed_version_$architecture.tar 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/seafile-server_$installed_version_$architecture
# store new installed version # store new installed version