diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8b11887 --- /dev/null +++ b/LICENSE @@ -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. + diff --git a/README.md b/README.md index 0b52dea..567a8f8 100644 --- a/README.md +++ b/README.md @@ -27,15 +27,43 @@ From command line: 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. +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 ----- - - 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 + +``` \ No newline at end of file diff --git a/conf/install.exp b/conf/install.exp index e753adc..bcbc98d 100644 --- a/conf/install.exp +++ b/conf/install.exp @@ -7,7 +7,7 @@ set seafile_data [lindex $argv 2] set fileserver_port [lindex $argv 3] 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" send "\r"; diff --git a/conf/upgrade_5.0.3.exp b/conf/upgrade_5.0.3.exp new file mode 100644 index 0000000..370cb72 --- /dev/null +++ b/conf/upgrade_5.0.3.exp @@ -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 \ No newline at end of file diff --git a/manifest.json b/manifest.json index 3827153..7a32eea 100644 --- a/manifest.json +++ b/manifest.json @@ -6,11 +6,14 @@ "fr": "Stockage Cloud Open Source" }, "developer": { - "name": "", - "email": "", - "url": "" + "name": "mbugeia", + "email": "maxime@max.privy.place" }, "multi_instance": "false", + "services": [ + "nginx", + "mysql" + ], "arguments": { "install": [ { diff --git a/scripts/backup b/scripts/backup new file mode 100644 index 0000000..063808b --- /dev/null +++ b/scripts/backup @@ -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" \ No newline at end of file diff --git a/scripts/install b/scripts/install index f0bcaf5..ed4a0f1 100644 --- a/scripts/install +++ b/scripts/install @@ -1,4 +1,7 @@ #!/bin/bash + +app=seafile + # Retrieve arguments domain=$1 path=$2 @@ -7,9 +10,9 @@ admin=$4 admin_password=$5 is_public=$6 architecture=$7 -final_path=/var/www/seafile +final_path=/var/www/$app seafile_data=/home/yunohost.app/seafile-data -seafile_version=4.4.3 +seafile_version=5.0.3 # Retrieve admin email admin_email=$(sudo yunohost user info $admin | grep mail: | sed "s/mail: //g") @@ -29,12 +32,11 @@ findPort () { } # Check domain/path availability -sudo yunohost app checkurl $domain$path -a seafile -if [[ ! $? -eq 0 ]]; then - exit 1 -fi +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 @@ -43,9 +45,9 @@ 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' +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' $final_path/installed +sudo mv ../sources/'seafile-server_'$seafile_version'_'$architecture'.tar.gz' $final_path/installed # Find available ports findPort 8000 @@ -56,16 +58,16 @@ findPort 8080 webdav_port=$port # store config in yunohost -sudo yunohost app setting seafile seahub_port -v $seahub_port -sudo yunohost app setting seafile fileserver_port -v $fileserver_port -sudo yunohost app setting seafile webdav_port -v $webdav_port -sudo yunohost app setting seafile is_public -v $is_public -sudo yunohost app setting seafile architecture -v $architecture -sudo yunohost app setting seafile installed_version -v $seafile_version +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 # init databases -db_user=seafile -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_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 @@ -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 # Update seafile config -sudo sed -i "s@http://@https://@g" $final_path/ccnet/ccnet.conf -sudo sed -i "s@:8000@$path@g" $final_path/ccnet/ccnet.conf -echo 'FILE_SERVER_ROOT = "https://'$domain'/seafhttp"' | sudo tee -a $final_path/seahub_settings.py -echo 'SITE_ROOT = "'$path'/"' | sudo tee -a $final_path/seahub_settings.py -echo 'SERVE_STATIC = False' | sudo tee -a $final_path/seahub_settings.py -echo 'MEDIA_URL = "'$path'/media/"' | sudo tee -a $final_path/seahub_settings.py -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 +sudo sed -i "s@http://@https://@g" $final_path/conf/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/conf/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/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 # Email configuration -echo 'EMAIL_USE_TLS = False' | sudo tee -a $final_path/seahub_settings.py -echo 'EMAIL_HOST = "localhost"' | sudo tee -a $final_path/seahub_settings.py -echo 'EMAIL_HOST_USER = "seafile@'$domain'"' | sudo tee -a $final_path/seahub_settings.py -echo 'EMAIL_HOST_PASSWORD = ""' | sudo tee -a $final_path/seahub_settings.py -echo 'EMAIL_PORT = "25"' | sudo tee -a $final_path/seahub_settings.py -echo 'DEFAULT_FROM_EMAIL = "seafile@'$domain'"' | sudo tee -a $final_path/seahub_settings.py -echo 'SERVER_EMAIL = "seafile@'$domain'"' | 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/conf/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/conf/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/conf/seahub_settings.py +echo 'SERVER_EMAIL = "seafile@'$domain'"' | sudo tee -a $final_path/conf/seahub_settings.py # LDAP configuration -echo '[LDAP]' | sudo tee -a $final_path/ccnet/ccnet.conf -echo 'HOST = ldap://localhost:389' | sudo tee -a $final_path/ccnet/ccnet.conf -echo 'BASE = ou=users,dc=yunohost,dc=org' | sudo tee -a $final_path/ccnet/ccnet.conf -echo 'LOGIN_ATTR = mail' | 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/conf/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/conf/ccnet.conf # Add Seafile Server to startup sudo cp ../conf/seafile-server /etc/init.d diff --git a/scripts/restore b/scripts/restore new file mode 100644 index 0000000..f97272f --- /dev/null +++ b/scripts/restore @@ -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 \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index 4dd8934..928fae5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,18 +1,19 @@ #!/bin/bash + 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) -seafile_version=4.4.3 +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' +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' $final_path/installed +sudo mv ../sources/'seafile-server_'$seafile_version'_'$architecture'.tar.gz' $final_path/installed # stop seafile server 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.3.2.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.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 # do the upgrade case $installed_version in @@ -44,6 +47,10 @@ case $installed_version in # Update seafile by script 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 ## Install webdav and logrotate if not installed @@ -108,7 +115,7 @@ sudo rm -r /tmp/seahub_cache 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/installed/seafile-server_$installed_version_$architecture.tar* sudo rm -f $final_path/seafile-server_$installed_version_$architecture # store new installed version diff --git a/sources/seafile-server_4.4.3_rpi.tar b/sources/seafile-server_5.0.3_i386.tar.gz similarity index 68% rename from sources/seafile-server_4.4.3_rpi.tar rename to sources/seafile-server_5.0.3_i386.tar.gz index 38803ad..601f5fe 100644 Binary files a/sources/seafile-server_4.4.3_rpi.tar and b/sources/seafile-server_5.0.3_i386.tar.gz differ diff --git a/sources/seafile-server_4.4.3_i386.tar b/sources/seafile-server_5.0.3_rpi.tar.gz similarity index 67% rename from sources/seafile-server_4.4.3_i386.tar rename to sources/seafile-server_5.0.3_rpi.tar.gz index 6a24a05..dc83ddf 100644 Binary files a/sources/seafile-server_4.4.3_i386.tar and b/sources/seafile-server_5.0.3_rpi.tar.gz differ diff --git a/sources/seafile-server_4.4.3_x86-64.tar b/sources/seafile-server_5.0.3_x86-64.tar.gz similarity index 69% rename from sources/seafile-server_4.4.3_x86-64.tar rename to sources/seafile-server_5.0.3_x86-64.tar.gz index c2866ea..452bfdd 100644 Binary files a/sources/seafile-server_4.4.3_x86-64.tar and b/sources/seafile-server_5.0.3_x86-64.tar.gz differ