diff --git a/README.md b/README.md index c489e63..c164048 100644 --- a/README.md +++ b/README.md @@ -24,18 +24,16 @@ From command line: `sudo yunohost app upgrade -l Seafile https://github.com/mbugeia/seafile_ynh seafile` -This will install Seafile v4.1.1 with HTTPS Sync only. /!\Not available on ARM for now /!\ +This will install Seafile v4.3.1 with HTTPS Sync only. Infos ----- -Seafile server v4.0.6 +Seafile server v4.3.1 -Available for x64, i386 and arm (Raspberry) architecture but only tested for x64 (feedback are welcome) +Available for x64, i386, armhf and Raspberry architecture but only tested for x64 (feedback are welcome) TODO ----- - - Webdav configuration - - Auto login/logout - - logrotate configuration \ No newline at end of file + - Auto login/logout \ No newline at end of file diff --git a/conf/add_sso_conf.py b/conf/add_sso_conf.py index 5c43e4f..09e9666 100644 --- a/conf/add_sso_conf.py +++ b/conf/add_sso_conf.py @@ -6,6 +6,7 @@ with open("/etc/ssowat/conf.json.persistent", "r") as jsonFile: data["unprotected_urls"].append("/seafhttp") else: data["unprotected_urls"] = ["/seafhttp"] + data["unprotected_urls"].append("/seafdav") with open("/etc/ssowat/conf.json.persistent", "w") as jsonFile: jsonFile.write(json.dumps(data, indent=4, sort_keys=True)) \ No newline at end of file diff --git a/conf/add_sso_conf_webdav.py b/conf/add_sso_conf_webdav.py new file mode 100644 index 0000000..e5570d8 --- /dev/null +++ b/conf/add_sso_conf_webdav.py @@ -0,0 +1,8 @@ +import json + +with open("/etc/ssowat/conf.json.persistent", "r") as jsonFile: + data = json.load(jsonFile) + data["unprotected_urls"].append("/seafdav") + +with open("/etc/ssowat/conf.json.persistent", "w") as jsonFile: + jsonFile.write(json.dumps(data, indent=4, sort_keys=True)) \ No newline at end of file diff --git a/conf/first_launch.exp b/conf/first_launch.exp index ebb633a..91687ea 100644 --- a/conf/first_launch.exp +++ b/conf/first_launch.exp @@ -4,7 +4,7 @@ set timeout 10 set admin_email [lindex $argv 0] set admin_password [lindex $argv 1] -spawn /var/www/seafile/seafile-server-4.0.6/seahub.sh start-fastcgi +spawn /var/www/seafile/seafile-server-latest/seahub.sh start-fastcgi expect "for the admin account?" send "$admin_email\r"; diff --git a/conf/install.exp b/conf/install.exp index 49f9470..fafcd4a 100644 --- a/conf/install.exp +++ b/conf/install.exp @@ -3,13 +3,11 @@ set timeout 10 set server_name [lindex $argv 0] set domain [lindex $argv 1] -set ccnet_port [lindex $argv 2] -set seafile_data [lindex $argv 3] -set seafile_port [lindex $argv 4] -set fileserver_port [lindex $argv 5] -set db_pwd [lindex $argv 6] +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.0.6/setup-seafile-mysql.sh +spawn /var/www/seafile/seafile-server-4.3.1/setup-seafile-mysql.sh expect "Press ENTER to continue" send "\r"; @@ -20,15 +18,9 @@ send "$server_name\r"; expect "What is the ip or domain of the server?" send "$domain\r"; -expect "Which port do you want to use for the ccnet server?" -send "$ccnet_port\r"; - expect "Where do you want to put your seafile data?" send "$seafile_data\r"; -expect "Which port do you want to use for the seafile server?" -send "$seafile_port\r"; - expect "Which port do you want to use for the seafile fileserver?" send "$fileserver_port\r"; diff --git a/conf/logrotate b/conf/logrotate new file mode 100644 index 0000000..59942a2 --- /dev/null +++ b/conf/logrotate @@ -0,0 +1,28 @@ +SEAFILE_DIR/logs/seaf-server.log +{ + daily + missingok + rotate 52 + compress + delaycompress + notifempty + sharedscripts + postrotate + [ ! -f SEAFILE_DIR/pids/seaf-server.pid ] || kill -USR1 `cat SEAFILE_DIR/pids/seaf-server.pid` + endscript +} + +SEAFILE_DIR/logs/ccnet.log +{ + daily + missingok + rotate 52 + compress + delaycompress + notifempty + sharedscripts + postrotate + [ ! -f SEAFILE_DIR/pids/ccnet.pid ] || kill -USR1 `cat SEAFILE_DIR/pids/ccnet.pid` + endscript +} + diff --git a/conf/nginx.conf b/conf/nginx.conf index 67cbd85..2a5efd0 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -33,9 +33,31 @@ location /seafhttp/ { client_max_body_size 0; proxy_connect_timeout 36000s; proxy_read_timeout 36000s; - } +} location PATHTOCHANGE/media { alias ALIASTOCHANGEseafile-server-latest/seahub/media; - } +} + +location /seafdav { + fastcgi_pass 127.0.0.1:WEBDAV_PORT; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_script_name; + + fastcgi_param SERVER_PROTOCOL $server_protocol; + fastcgi_param QUERY_STRING $query_string; + fastcgi_param REQUEST_METHOD $request_method; + fastcgi_param CONTENT_TYPE $content_type; + fastcgi_param CONTENT_LENGTH $content_length; + fastcgi_param SERVER_ADDR $server_addr; + fastcgi_param SERVER_PORT $server_port; + fastcgi_param SERVER_NAME $server_name; + + fastcgi_param HTTPS on; + + client_max_body_size 0; + + access_log /var/log/nginx/seafdav.access.log; + error_log /var/log/nginx/seafdav.error.log; +} \ No newline at end of file diff --git a/conf/nginx_add_webdav b/conf/nginx_add_webdav new file mode 100644 index 0000000..d3e9091 --- /dev/null +++ b/conf/nginx_add_webdav @@ -0,0 +1,21 @@ +location /seafdav { + fastcgi_pass 127.0.0.1:WEBDAV_PORT; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_script_name; + + fastcgi_param SERVER_PROTOCOL $server_protocol; + fastcgi_param QUERY_STRING $query_string; + fastcgi_param REQUEST_METHOD $request_method; + fastcgi_param CONTENT_TYPE $content_type; + fastcgi_param CONTENT_LENGTH $content_length; + fastcgi_param SERVER_ADDR $server_addr; + fastcgi_param SERVER_PORT $server_port; + fastcgi_param SERVER_NAME $server_name; + + fastcgi_param HTTPS on; + + client_max_body_size 0; + + access_log /var/log/nginx/seafdav.access.log; + error_log /var/log/nginx/seafdav.error.log; +} \ No newline at end of file diff --git a/conf/remove_sso_conf.py b/conf/remove_sso_conf.py index a29c367..ff59377 100644 --- a/conf/remove_sso_conf.py +++ b/conf/remove_sso_conf.py @@ -3,6 +3,7 @@ import json with open("/etc/ssowat/conf.json.persistent", "r") as jsonFile: data = json.load(jsonFile) data["unprotected_urls"].remove("/seafhttp") + data["unprotected_urls"].remove("/seafdav") with open("/etc/ssowat/conf.json.persistent", "w") as jsonFile: jsonFile.write(json.dumps(data, indent=4, sort_keys=True)) \ No newline at end of file diff --git a/conf/seafdav.conf b/conf/seafdav.conf new file mode 100644 index 0000000..68fe00b --- /dev/null +++ b/conf/seafdav.conf @@ -0,0 +1,5 @@ +[WEBDAV] +enabled = true +port = WEBDAV_PORT +fastcgi = true +share_name = /seafdav \ No newline at end of file diff --git a/conf/upgrade_4.1.1.exp b/conf/upgrade_4.1.1.exp index 67b2fa2..d1ec85f 100644 --- a/conf/upgrade_4.1.1.exp +++ b/conf/upgrade_4.1.1.exp @@ -3,7 +3,7 @@ set timeout 5 set mysql_password [lindex $argv 0] -spawn /var/www/seafile/seafile-server-4.1.1/upgrade/upgrade_4.0_4.1.sh +spawn /var/www/seafile/seafile-server-4.3.1/upgrade/upgrade_4.0_4.1.sh expect "to contiune" send "\r"; diff --git a/conf/upgrade_4.2.1.exp b/conf/upgrade_4.2.1.exp new file mode 100644 index 0000000..43c58a1 --- /dev/null +++ b/conf/upgrade_4.2.1.exp @@ -0,0 +1,11 @@ +#!/usr/bin/expect +set timeout 5 + +set mysql_password [lindex $argv 0] + +spawn /var/www/seafile/seafile-server-4.3.1/upgrade/upgrade_4.1_4.2.sh + +expect "to contiune" +send "\r"; + +interact \ No newline at end of file diff --git a/conf/upgrade_4.3.1.exp b/conf/upgrade_4.3.1.exp new file mode 100644 index 0000000..1460173 --- /dev/null +++ b/conf/upgrade_4.3.1.exp @@ -0,0 +1,11 @@ +#!/usr/bin/expect +set timeout 5 + +set mysql_password [lindex $argv 0] + +spawn /var/www/seafile/seafile-server-4.3.1/upgrade/upgrade_4.2_4.3.sh + +expect "to contiune" +send "\r"; + +interact \ No newline at end of file diff --git a/manifest.json b/manifest.json index 556b838..2c9f820 100644 --- a/manifest.json +++ b/manifest.json @@ -70,7 +70,7 @@ "en": "What is the server architecture?", "fr": "Quelle est l'architecture du serveur ?" }, - "choices": ["x86-64", "i386", "arm"], + "choices": ["x86-64", "i386", "rpi", "armhf"], "default": "x86-64" } ] diff --git a/scripts/install b/scripts/install index 1c6e871..521c7ee 100644 --- a/scripts/install +++ b/scripts/install @@ -9,7 +9,7 @@ is_public=$6 architecture=$7 final_path=/var/www/seafile seafile_data=/home/yunohost.app/seafile-data -seafile_version=4.0.6 +seafile_version=4.3.1 # Retrieve admin email admin_email=$(sudo yunohost user info $admin | grep mail: | sed "s/mail: //g") @@ -48,20 +48,17 @@ sudo mv seafile-server-$seafile_version/* $final_path/seafile-server-$seafile_ve sudo mv ../sources/'seafile-server_'$seafile_version'_'$architecture'.tar' $final_path/installed # Find available ports -findPort 10001 -ccnet_port=$port -findPort 12001 -seafile_port=$port findPort 8000 seahub_port=$port findPort 8082 fileserver_port=$port +findPort 8080 +webdav_port=$port # store config in yunohost -sudo yunohost app setting seafile ccnet_port -v $ccnet_port -sudo yunohost app setting seafile seafile_port -v $seafile_port 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 fileserver_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 @@ -77,7 +74,7 @@ sudo yunohost app setting seafile db_pwd -v $db_pwd # Run install script sudo chmod +x ../conf/install.exp sudo chmod +x $final_path/seafile-server-$seafile_version/setup-seafile-mysql.sh -sudo ../conf/install.exp $server_name $domain $ccnet_port $seafile_data $seafile_port $fileserver_port $db_pwd +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 @@ -86,6 +83,8 @@ echo 'FILE_SERVER_ROOT = "https://'$domain'/seafhttp"' | sudo tee -a $final_path 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 # Email configuration echo 'EMAIL_USE_TLS = False' | sudo tee -a $final_path/seahub_settings.py @@ -114,6 +113,7 @@ sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf sed -i "s@SEAHUB_PORT@$seahub_port@g" ../conf/nginx.conf sed -i "s@SEAFILE_FILESERVER_PORT@$fileserver_port@g" ../conf/nginx.conf +sed -i "s@WEBDAV_PORT@$webdav_port@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/seafile.conf # Copy first launch script @@ -124,15 +124,11 @@ sudo chmod +x $final_path/first_launch.exp sudo chown -R www-data:www-data $final_path sudo chown -R www-data:www-data $seafile_data -# Open port -sudo yunohost firewall allow $ccnet_port -sudo yunohost firewall allow $seafile_port - # Start seafile, seahub and populate admin account -sudo su - www-data -c "/var/www/seafile/seafile-server-4.0.6/seafile.sh start" +sudo su - www-data -c "/var/www/seafile/seafile-server-$seafile_version/seafile.sh start" sudo su - www-data -c "$final_path/first_launch.exp $admin_email $admin_password" -# add sso config to unprotect domain.tld/seafhttp in /etc/ssowat/conf.json.persistent +# 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 sudo cp ../conf/remove_sso_conf.py $final_path sudo python $final_path/add_sso_conf.py @@ -147,6 +143,15 @@ else sudo yunohost app setting seafile unprotected_uris -v "/" fi +# Add webdav +sudo cp ../conf/seafdav.conf $final_path/conf/seafdav.conf +sudo sed -i "s@SEAFILE_FILESERVER_PORT@$fileserver_port@g" $final_path/conf/seafdav.conf + +# 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 + # register yunohost service sudo yunohost service add seafile-server diff --git a/scripts/remove b/scripts/remove index ed1cd6f..86a07b7 100644 --- a/scripts/remove +++ b/scripts/remove @@ -15,12 +15,6 @@ sudo rm -rf /home/yunohost.app/seafile-data # Remove databases mysql -u root -p$root_pwd -e "DROP DATABASE ccnetdb ; DROP DATABASE seafiledb ; DROP DATABASE seahubdb ; DROP USER seafile@localhost ;" -ccnet_port=$(sudo yunohost app setting seafile ccnet_port) -seafile_port=$(sudo yunohost app setting seafile seafile_port) - -sudo yunohost firewall disallow $ccnet_port -sudo yunohost firewall disallow $seafile_port - sudo yunohost service remove seafile-server # Restart services diff --git a/scripts/upgrade b/scripts/upgrade index 565dd62..3fc1d42 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -5,7 +5,7 @@ app=seafile 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.1.1 +seafile_version=4.3.1 final_path=/var/www/$app # extract new version @@ -19,20 +19,82 @@ sudo service seafile-server stop # 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.1.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 # do the upgrade -sudo ../conf/upgrade_4.1.1.exp $root_pwd +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 + sudo ../conf/upgrade_4.3.1.exp $root_pwd +;; +"4.1."* ) + # Update seafile by script + sudo ../conf/upgrade_4.2.1.exp $root_pwd + sudo ../conf/upgrade_4.3.1.exp $root_pwd +;; +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 + sudo yunohost app setting seafile fileserver_port -v $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) + 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 + sudo sed -i "s@SEAFILE_FILESERVER_PORT@$fileserver_port@g" $final_path/conf/seafdav.conf + + # 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 # restore correct permissions sudo chown -R www-data:www-data $final_path -# 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 $ccnet_port -sudo yunohost firewall disallow $seafile_port - # restart seafile server sudo service seafile-server start diff --git a/sources/seafile-server_4.1.1_i386.tar b/sources/seafile-server_4.1.1_i386.tar deleted file mode 100644 index 8af778d..0000000 Binary files a/sources/seafile-server_4.1.1_i386.tar and /dev/null differ diff --git a/sources/seafile-server_4.0.6_arm.tar b/sources/seafile-server_4.3.1_armhf.tar similarity index 63% rename from sources/seafile-server_4.0.6_arm.tar rename to sources/seafile-server_4.3.1_armhf.tar index 975d76f..853ee6c 100644 Binary files a/sources/seafile-server_4.0.6_arm.tar and b/sources/seafile-server_4.3.1_armhf.tar differ diff --git a/sources/seafile-server_4.1.1_x86-64.tar b/sources/seafile-server_4.3.1_i386.tar similarity index 67% rename from sources/seafile-server_4.1.1_x86-64.tar rename to sources/seafile-server_4.3.1_i386.tar index db8a74b..e4b42c2 100644 Binary files a/sources/seafile-server_4.1.1_x86-64.tar and b/sources/seafile-server_4.3.1_i386.tar differ diff --git a/sources/seafile-server_4.0.6_i386.tar b/sources/seafile-server_4.3.1_rpi.tar similarity index 64% rename from sources/seafile-server_4.0.6_i386.tar rename to sources/seafile-server_4.3.1_rpi.tar index 49612e9..a25ef59 100644 Binary files a/sources/seafile-server_4.0.6_i386.tar and b/sources/seafile-server_4.3.1_rpi.tar differ diff --git a/sources/seafile-server_4.0.6_x86-64.tar b/sources/seafile-server_4.3.1_x86-64.tar similarity index 64% rename from sources/seafile-server_4.0.6_x86-64.tar rename to sources/seafile-server_4.3.1_x86-64.tar index ccd4dd5..1c5c7c3 100644 Binary files a/sources/seafile-server_4.0.6_x86-64.tar and b/sources/seafile-server_4.3.1_x86-64.tar differ