first commit

This commit is contained in:
Josué 2015-08-24 20:45:36 +02:00
parent 90578e90df
commit f532ecd7b6
22 changed files with 210 additions and 51 deletions

View file

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

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

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

@ -39,3 +39,25 @@ location /seafhttp/ {
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.1/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.1/upgrade/upgrade_4.1_4.2.sh
expect "to contiune"
send "\r";
interact

11
conf/upgrade_4.3.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.1/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.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

View file

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

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.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
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