Merge pull request #4 from Josue-T/master

Update to seafile 4.3.2
Update script
Add armhf support but they are a bug, please see this issue : haiwen/seafile#1358 
Add logrotate
Add webdav

Former-commit-id: 168bf5c3af
This commit is contained in:
tostaki 2015-09-08 00:02:16 +02:00
commit dbc049f79e
26 changed files with 223 additions and 56 deletions

View file

@ -24,18 +24,18 @@ 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.2
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)
In armhf it don't run actually. Please see this issue : https://github.com/haiwen/seafile/issues/1358
TODO
-----
- Webdav configuration
- Auto login/logout
- logrotate configuration

View file

@ -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))

View file

@ -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))

View file

@ -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";

View file

@ -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.2/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";

28
conf/logrotate Normal file
View file

@ -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
}

View file

@ -33,9 +33,32 @@ location /seafhttp/ {
client_max_body_size 0;
proxy_connect_timeout 36000s;
proxy_read_timeout 36000s;
}
proxy_send_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;
}

21
conf/nginx_add_webdav Normal file
View file

@ -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;
}

View file

@ -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))

5
conf/seafdav.conf Normal file
View file

@ -0,0 +1,5 @@
[WEBDAV]
enabled = true
port = WEBDAV_PORT
fastcgi = true
share_name = /seafdav

View file

@ -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.2/upgrade/upgrade_4.0_4.1.sh
expect "to contiune"
send "\r";

11
conf/upgrade_4.2.1.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-4.3.2/upgrade/upgrade_4.1_4.2.sh
expect "to contiune"
send "\r";
interact

11
conf/upgrade_4.3.2.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-4.3.2/upgrade/upgrade_4.2_4.3.sh
expect "to contiune"
send "\r";
interact

View file

@ -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"
}
]

View file

@ -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.2
# 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 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
@ -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,8 +113,13 @@ 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
# Add webdav
sudo cp ../conf/seafdav.conf $final_path/conf/seafdav.conf
sudo sed -i "s@WEBDAV_PORT@$webdav_port@g" $final_path/conf/seafdav.conf
# Copy first launch script
sudo cp ../conf/first_launch.exp $final_path
sudo chmod +x $final_path/first_launch.exp
@ -124,15 +128,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 "$final_path/first_launch.exp $admin_email $admin_password"
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 $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 +147,11 @@ else
sudo yunohost app setting seafile unprotected_uris -v "/"
fi
# 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
@ -154,5 +159,7 @@ sudo yunohost service add seafile-server
sudo service nginx reload
sudo yunohost app ssowatconf
# Start seafile
# Restart seafile
sudo su - www-data -s /bin/bash -c "/var/www/seafile/seafile-server-latest/seahub.sh stop"
sudo service seafile-server stop
sudo service seafile-server start

View file

@ -11,16 +11,11 @@ sudo rm -rf /var/www/seafile
sudo rm -f /etc/nginx/conf.d/$domain.d/seafile.conf
sudo rm -f /etc/init.d/seafile-server
sudo rm -rf /home/yunohost.app/seafile-data
sudo rm -r /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 ;"
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

View file

@ -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.2
final_path=/var/www/$app
# extract new version
@ -19,19 +19,84 @@ 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.2.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.2.exp $root_pwd
;;
"4.1."* )
# Update seafile by script
sudo ../conf/upgrade_4.2.1.exp $root_pwd
sudo ../conf/upgrade_4.3.2.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 webdav_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@WEBDAV_PORT@$webdav_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
# delete seafile cache
sudo rm -r /tmp/seahub_cache
# restart seafile server
sudo service seafile-server start

View file

@ -1 +0,0 @@
975d76fae7e7109f9ff1e80d143a4ee414c4b48a

View file

@ -1 +0,0 @@
49612e98e534d7ce61743da13282d9538925faea

View file

@ -1 +0,0 @@
ccd4dd526f76614765521791672befffd622116b

View file

@ -1 +0,0 @@
8af778d2df71d4b757dc748c98199a8df823a7da

View file

@ -1 +0,0 @@
db8a74bd09e625ba9664e150543a650d84597693

View file

@ -0,0 +1 @@
dce9bb444d0d0d24228013ed9182c07835e7b1bf

View file

@ -0,0 +1 @@
74b0849ab352875cb660ef8faa91a291fa41a9a6

View file

@ -0,0 +1 @@
0aae7f1b9a19a98c469da89f395d9c353b5fa050

View file

@ -0,0 +1 @@
a97899f393f9bd2a6e35859d0594569bc7f2c40f