+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source. For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code. There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU AGPL, see
+.
diff --git a/README.md b/README.md
index a4ee95f..4573dcc 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,126 @@
-# seafile-server-installer-cm
-One script to install seafile server
+# seafile-server-installer
+These installer scripts offer a quick and easy way to set up the [Seafile Server Community Edition](http://seafile.com/en/home/), using MariaDB, Memcached and NGINX as a Reverse Proxy in under 5 minutes. We're also adding an init script that starts Seafile when booting the server.
+
+### What's it for?
+Installing the [Seafile Server Community Edition](http://seafile.com/en/home/) on Debian or Ubuntu (64bit) in a standard and more secure manner then the out of the box setup scripts offer. Instead of SQLite we're using MariaDB and instead of Gunicorn we're using NGINX.
+
+
+### Why?
+There are just too many ways to misconfigure a manual Seafile server installation. We've notices that many people don't realize that the default installation is unsecure. In other cases people get stuck during the installation or forget a step like changing "FILE_SERVER_ROOT" or use IP addresses instead of resolvable DNS names.
+This script is derived from our [reference installation for Seafile Server Professional](https://wiki.seafile.com.de/doku.php?id=debian_7_wheezy_64bit). It helps us to standardize the installation procedure and helps with identifying setup errors more easily.
+
+
+### How long does the installation take?
+The installation time will vary depending on your internet connection speed and hardware. On our SSD-based servers we were able to install a production-ready Seafile server in roughly 5 minutes.
+
+
+### Operating system
+It's meant to run on a [Debian Jessie minimal installation](https://www.youtube.com/watch?v=BCwz9oSSt8g) or [Ubuntu Trusty minimal installation](https://www.youtube.com/watch?v=qdCbWOHwBL4). No desktop environment or other weird stuff like hosting panels (Plesk, ISPConfig, etc.)...
+
+
+### Which components are used?
+1. [Newest Seafile Server Community Edition](https://download.seafile.com.de/)
+2. [NGINX](http://nginx.org/packages/mainline/debian/)
+3. MariaDB
+4. Memcached
+
+
+### Which special features are enabled by default?
+1. HTTPS-Proxy on port 443
+2. Forced redirect from unenrypted HTTP port 80 to encrypted HTTPS port 443
+2. Seahub with FastCGI
+3. [SeafDAV](http://manual.seafile.com/extension/webdav.html) with FastCGI
+4. Memcached
+5. Seafile autostart
+
+
+### What does the installer do?
+1. Update and upgrade Debian
+2. Install NGINX from http://nginx.org/packages/mainline/debian/
+3. Create Seafile init script and add it to systemd startup
+4. Create unprivilieged system user "seafile" with home directory "/opt/seafile"
+5. Download and extract latest Seafile server sources from https://download.seafile.com.de/seafile-server_latest_x86-64.tar.gz
+6. Create "seafile" database user and Seafile databases (DB-Credentials in ~/.my.cnf)
+7. Initialize various Seafile files
+8. Enable SeafDAV, Memcached and MariaDB
+9. Setup Seafile to listen to IP (hostname -i) instead of DNS (*Switch this to DNS before live deployment*)
+10. Create Seafile admin with individual password
+11. Install "seafile-server-change-address" script
+12. Display setup infos and what to do next.
+
+
+### How do I run it?
+
+For **Debian Wheezy (64bit)** run the following lines as root:
+
+cd /tmp
+wget --no-check-certificate https://raw.githubusercontent.com/SeafileDE/seafile-server-installer/master/seafile-ce_debian-wheezy-amd64
+time bash seafile-ce_debian-wheezy-amd64
+
+
+For **Debian Jessie (32bit)** run the following lines as root:
+
+cd /tmp
+wget --no-check-certificate https://raw.githubusercontent.com/SeafileDE/seafile-server-installer/master/seafile-ce_debian-jessie-i386
+time bash seafile-ce_debian-jessie-i386
+
+
+For **Debian Jessie (64bit)** run the following lines as root:
+
+cd /tmp
+wget --no-check-certificate https://raw.githubusercontent.com/SeafileDE/seafile-server-installer/master/seafile-ce_debian-jessie-amd64
+time bash seafile-ce_debian-jessie-amd64
+
+
+For **Ubuntu Trusty (64bit)** run the following lines as root:
+
+cd /tmp
+wget --no-check-certificate https://raw.githubusercontent.com/SeafileDE/seafile-server-installer/master/seafile-server-community_ubuntu-trusty-amd64
+time bash seafile-server-community_ubuntu-trusty-amd64
+
+
+BETA: For **Uberspace** run the following line as user:
+
+wget https://raw.githubusercontent.com/SeafileDE/seafile-server-installer/master/seafile-ce_uberspace
+time bash seafile-ce_uberspace
+
+
+
+### Caution!
+Never run the script on a production server. It's more or less a one trick pony and can seriously damage production systems. So run it only one time and delete it afterwards.
+
+As a precaution I have added a few simple checks to abort installation if the unprivileged Seafile user or Seafile installation directory pre-exist:
+
+1. Check if you're running this script as root. If not, abort.
+2. Check if the user "seafile" exists. If yes, abort.
+3. Check if the directory "/opt/seafile" exists. If yes, abort.
+
+
+### How do I update Seafile?
+You will have to handle Seafile updates/upgrades manually after the initial installation. Consult http://manual.seafile.com/deploy/upgrade.html on how to upgrade Seafile.
+
+BTW Ideas on how to automate upgrades are very welcome!
+
+
+### What do I have to do after the installer has finished?
+1. Delete installer script. You wont need it anymore and might even seriously damage your system if you ran it again.
+2. Follow the suggested steps at the end of the installation to finalize your Seafile server installation. As a bare minimum you most definitely will want to change the listening IP to a valid DNS name by running "seafile-server-change-address" as root...
+3. Install a firewall. TCP-Port 443 needs to be accessible. Optionally you can open TCP-Port 80 which redirects to HTTPS
+
+
+### License
+Copyright 2015, Alexander Jackson
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the [GNU Affero General Public License](http://www.gnu.org/licenses/agpl-3.0.html) as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+
+### Where can I submit bugs or add suggestions?
+Contact me at alexander.jackson@seafile.de or create an [Issue](https://github.com/SeafileDE/seafile-server-community_debian-jessie-amd64/issues/new) on Github. Or just reply in the [corresponding forum thread](https://forum.seafile-server.org/t/howto-seafile-server-community-edition-on-debian-jessie-amd64/1464).
diff --git a/no_certificate/seafile-ce_debian-jessie-amd64-no_certificate b/no_certificate/seafile-ce_debian-jessie-amd64-no_certificate
new file mode 100644
index 0000000..f933c8e
--- /dev/null
+++ b/no_certificate/seafile-ce_debian-jessie-amd64-no_certificate
@@ -0,0 +1,603 @@
+#!/bin/bash
+#
+# seafile-server-installer/seafile-ce_debian-jessie-amd64
+#
+# Copyright 2015, Alexander Jackson
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+#
+#set -x
+# -------------------------------------------
+# Vars
+# -------------------------------------------
+SEAFILE_ADMIN=admin@seafile.local
+SEAFILE_USER=seafile
+SERVER_NAME=$(hostname -s | cut -c -16)
+IP_OR_DOMAIN=$(hostname -i)
+HOSTNAME=$(hostname -i)
+FILESERVER_PORT=8082
+SERVER_PORT=10001
+SEAFILE_SERVER_PORT=12001
+
+
+# -------------------------------------------
+# Seafile Server Community Edition on Debian Jessie (64bit)
+# -------------------------------------------
+clear
+cat < /dev/null 2>&1 ;
+then
+ echo " Aborting because user ${SEAFILE_USER} already exist" ; exit 1
+fi
+
+
+# -------------------------------------------
+# Abort if directory /opt/seafile/ exists
+# -------------------------------------------
+if [[ -d "/opt/seafile/" ]] ;
+then
+ echo " Aborting because directory /opt/seafile/ already exist" ; exit 1
+fi
+
+
+# -------------------------------------------
+# Update System
+# -------------------------------------------
+apt-get update && apt-get dist-upgrade -y
+
+
+# -------------------------------------------
+# Ensure aptitude is installed
+# -------------------------------------------
+apt-get install aptitude -y
+
+
+# -------------------------------------------
+# Additional requirements
+# -------------------------------------------
+aptitude install sudo python-setuptools python-simplejson python-imaging python-mysqldb \
+openjdk-7-jre memcached python-memcache pwgen curl openssl -y
+
+
+# -------------------------------------------
+# NGINX
+# -------------------------------------------
+cat > /etc/apt/sources.list.d/nginx.list < /etc/nginx/conf.d/seafile.conf <<'EOF'
+server {
+ listen 80;
+ server_name "";
+
+ location / {
+ fastcgi_pass 127.0.0.1:8000;
+ 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;
+
+ access_log /var/log/nginx/seahub.access.log;
+ error_log /var/log/nginx/seahub.error.log;
+ }
+ location /seafhttp {
+ rewrite ^/seafhttp(.*)$ $1 break;
+ proxy_pass http://127.0.0.1:8082;
+ client_max_body_size 0;
+ proxy_connect_timeout 36000s;
+ proxy_read_timeout 36000s;
+ }
+ location /media {
+ root /opt/seafile/seafile-server-latest/seahub;
+ }
+ location /seafdav {
+ fastcgi_pass 127.0.0.1:8080;
+ 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;
+
+ client_max_body_size 0;
+
+ access_log /var/log/nginx/seafdav.access.log;
+ error_log /var/log/nginx/seafdav.error.log;
+ }
+ }
+EOF
+
+service nginx restart
+
+
+# -------------------------------------------
+# MariaDB
+# -------------------------------------------
+DEBIAN_FRONTEND=noninteractive aptitude install mariadb-server -y
+
+SQLROOTPW=$(pwgen)
+
+mysqladmin -u root password $SQLROOTPW
+
+cat > /root/.my.cnf < /etc/init.d/seafile-server <<'EOF'
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: seafile-server
+# Required-Start: $remote_fs $syslog mysql
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Seafile server
+# Description: Start Seafile server
+### END INIT INFO
+
+# Author: Alexander Jackson
+#
+
+# Change the value of "user" to your linux user name
+user=seafile
+
+# Change the value of "seafile_dir" to your path of seafile installation
+seafile_dir=/opt/seafile
+script_path=${seafile_dir}/seafile-server-latest
+seafile_init_log=${seafile_dir}/logs/seafile.init.log
+seahub_init_log=${seafile_dir}/logs/seahub.init.log
+
+# Change the value of fastcgi to true if fastcgi is to be used
+fastcgi=true
+# Set the port of fastcgi, default is 8000. Change it if you need different.
+fastcgi_port=8000
+
+case "$1" in
+ start)
+ sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${user} ${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log}
+ else
+ sudo -u ${user} ${script_path}/seahub.sh start >> ${seahub_init_log}
+ fi
+ ;;
+ restart)
+ sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${seahub_init_log}
+ else
+ sudo -u ${user} ${script_path}/seahub.sh restart >> ${seahub_init_log}
+ fi
+ ;;
+ stop)
+ sudo -u ${user} ${script_path}/seafile.sh $1 >> ${seafile_init_log}
+ sudo -u ${user} ${script_path}/seahub.sh $1 >> ${seahub_init_log}
+ ;;
+ *)
+ echo "Usage: /etc/init.d/seafile-server {start|stop|restart}"
+ exit 1
+ ;;
+esac
+EOF
+
+chmod +x /etc/init.d/seafile-server
+update-rc.d seafile-server defaults
+
+
+# -------------------------------------------
+# Seafile
+# -------------------------------------------
+adduser --system --gecos "${SEAFILE_USER}" ${SEAFILE_USER} --home /opt/seafile
+mkdir -p /opt/seafile/installed
+cd /opt/seafile/
+curl -OL https://download.seafile.com.de/seafile-server_latest_x86-64.tar.gz
+tar xzf seafile-server_latest_x86-64.tar.gz
+
+SEAFILE_VERSION=$(basename /opt/seafile/seafile-server-* | awk -F'-' ' { print $3 }')
+
+mv seafile-server_latest_x86-64.tar.gz installed/seafile-server_${SEAFILE_VERSION}_x86-64.tar.gz
+
+
+# -------------------------------------------
+# Seafile DB
+# -------------------------------------------
+SQLSEAFILEPW=$(pwgen)
+
+cat > /opt/seafile/.my.cnf < "${DEFAULT_CCNET_CONF_DIR}/seafile.ini"
+
+
+# -------------------------------------------
+# Configure Seafile WebDAV Server(SeafDAV)
+# -------------------------------------------
+mkdir -p ${DEFAULT_CONF_DIR}
+cat > ${DEFAULT_CONF_DIR}/seafdav.conf < "${DEST_SETTINGS_PY}"
+
+
+# -------------------------------------------
+# prepare avatar directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/seahub-data"
+mv "${ORIG_AVATAR_DIR}" "${DEST_AVATAR_DIR}"
+ln -s ../../../seahub-data/avatars ${MEDIA_DIR}
+
+
+# -------------------------------------------
+# create logs directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/logs"
+
+
+# -------------------------------------------
+# Create symlink for current server version
+# -------------------------------------------
+ln -s $(basename ${INSTALLPATH}) ${SEAFILE_SERVER_SYMLINK}
+
+
+# Fix permissions
+chmod 0600 "$DEST_SETTINGS_PY"
+chmod 0700 "$DEFAULT_CCNET_CONF_DIR"
+chmod 0700 "$SEAFILE_DATA_DIR"
+chmod 0700 "$DEFAULT_CONF_DIR"
+
+
+# -------------------------------------------
+# copy user manuals to library template
+# -------------------------------------------
+mkdir -p ${LIBRARY_TEMPLATE_DIR}
+cp -f ${SRC_DOCS_DIR}/*.doc ${LIBRARY_TEMPLATE_DIR}
+
+
+# -------------------------------------------
+# Configuring ccnet.conf
+# -------------------------------------------
+SEAFILESQLPW=$(grep password /opt/seafile/.my.cnf | awk -F'=' {'print $2'})
+
+cat >> ${DEFAULT_CCNET_CONF_DIR}/ccnet.conf <> ${DEST_SETTINGS_PY} < ${seafile_dir}/aio_seafile-server.log<
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+#
+#set -x
+# -------------------------------------------
+# Vars
+# -------------------------------------------
+SEAFILE_ADMIN=admin@seafile.local
+SEAFILE_USER=seafile
+SERVER_NAME=$(hostname -s | cut -c -16)
+IP_OR_DOMAIN=$(hostname -i)
+HOSTNAME=$(hostname -i)
+FILESERVER_PORT=8082
+SERVER_PORT=10001
+SEAFILE_SERVER_PORT=12001
+
+
+# -------------------------------------------
+# Seafile Server Community Edition on Debian Jessie (32bit)
+# -------------------------------------------
+clear
+cat < /dev/null 2>&1 ;
+#then
+# echo " Aborting because user ${SEAFILE_USER} already exist" ; exit 1
+#fi
+
+
+# -------------------------------------------
+# Abort if directory /opt/seafile/ exists
+# -------------------------------------------
+#if [[ -d "/opt/seafile/" ]] ;
+#then
+# echo " Aborting because directory /opt/seafile/ already exist" ; exit 1
+#fi
+
+
+# -------------------------------------------
+# Update System
+# -------------------------------------------
+apt-get update && apt-get dist-upgrade -y
+
+
+# -------------------------------------------
+# Ensure aptitude is installed
+# -------------------------------------------
+apt-get install aptitude -y
+
+
+# -------------------------------------------
+# Additional requirements
+# -------------------------------------------
+aptitude install sudo python-setuptools python-simplejson python-imaging python-mysqldb \
+openjdk-7-jre memcached python-memcache pwgen curl openssl -y
+
+
+# -------------------------------------------
+# NGINX
+# -------------------------------------------
+cat > /etc/apt/sources.list.d/nginx.list < /etc/nginx/conf.d/seafile.conf <<'EOF'
+server {
+ listen 80;
+ server_name "";
+
+ location / {
+ fastcgi_pass 127.0.0.1:8000;
+ 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;
+
+ access_log /var/log/nginx/seahub.access.log;
+ error_log /var/log/nginx/seahub.error.log;
+ }
+ location /seafhttp {
+ rewrite ^/seafhttp(.*)$ $1 break;
+ proxy_pass http://127.0.0.1:8082;
+ client_max_body_size 0;
+ proxy_connect_timeout 36000s;
+ proxy_read_timeout 36000s;
+ }
+ location /media {
+ root /opt/seafile/seafile-server-latest/seahub;
+ }
+ location /seafdav {
+ fastcgi_pass 127.0.0.1:8080;
+ 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;
+
+ client_max_body_size 0;
+
+ access_log /var/log/nginx/seafdav.access.log;
+ error_log /var/log/nginx/seafdav.error.log;
+ }
+ }
+EOF
+
+service nginx restart
+
+
+# -------------------------------------------
+# MariaDB
+# -------------------------------------------
+#DEBIAN_FRONTEND=noninteractive aptitude install mariadb-server -y
+
+#SQLROOTPW=$(pwgen)
+
+#mysqladmin -u root password $SQLROOTPW
+
+#cat > /root/.my.cnf < /etc/init.d/seafile-server <<'EOF'
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: seafile-server
+# Required-Start: $remote_fs $syslog mysql
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Seafile server
+# Description: Start Seafile server
+### END INIT INFO
+
+# Author: Alexander Jackson
+#
+
+# Change the value of "user" to your linux user name
+user=seafile
+
+# Change the value of "seafile_dir" to your path of seafile installation
+seafile_dir=/opt/seafile
+script_path=${seafile_dir}/seafile-server-latest
+seafile_init_log=${seafile_dir}/logs/seafile.init.log
+seahub_init_log=${seafile_dir}/logs/seahub.init.log
+
+# Change the value of fastcgi to true if fastcgi is to be used
+fastcgi=true
+# Set the port of fastcgi, default is 8000. Change it if you need different.
+fastcgi_port=8000
+
+case "$1" in
+ start)
+ sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${user} ${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log}
+ else
+ sudo -u ${user} ${script_path}/seahub.sh start >> ${seahub_init_log}
+ fi
+ ;;
+ restart)
+ sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${seahub_init_log}
+ else
+ sudo -u ${user} ${script_path}/seahub.sh restart >> ${seahub_init_log}
+ fi
+ ;;
+ stop)
+ sudo -u ${user} ${script_path}/seafile.sh $1 >> ${seafile_init_log}
+ sudo -u ${user} ${script_path}/seahub.sh $1 >> ${seahub_init_log}
+ ;;
+ *)
+ echo "Usage: /etc/init.d/seafile-server {start|stop|restart}"
+ exit 1
+ ;;
+esac
+EOF
+
+chmod +x /etc/init.d/seafile-server
+update-rc.d seafile-server defaults
+
+
+# -------------------------------------------
+# Seafile
+# -------------------------------------------
+adduser --system --gecos "${SEAFILE_USER}" ${SEAFILE_USER} --home /opt/seafile
+mkdir -p /opt/seafile/installed
+cd /opt/seafile/
+curl -OL https://download.seafile.com.de/seafile-server_latest_i386.tar.gz
+tar xzf seafile-server_latest_i386.tar.gz
+
+SEAFILE_VERSION=$(basename /opt/seafile/seafile-server-* | awk -F'-' ' { print $3 }')
+
+mv seafile-server_4.1.2_i386.tar.gz installed/seafile-server_${SEAFILE_VERSION}_i386.tar.gz
+
+
+# -------------------------------------------
+# Seafile DB
+# -------------------------------------------
+SQLSEAFILEPW=$(pwgen)
+
+cat > /opt/seafile/.my.cnf < "${DEFAULT_CCNET_CONF_DIR}/seafile.ini"
+
+
+# -------------------------------------------
+# Configure Seafile WebDAV Server(SeafDAV)
+# -------------------------------------------
+mkdir -p ${DEFAULT_CONF_DIR}
+cat > ${DEFAULT_CONF_DIR}/seafdav.conf < "${DEST_SETTINGS_PY}"
+
+
+# -------------------------------------------
+# prepare avatar directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/seahub-data"
+mv "${ORIG_AVATAR_DIR}" "${DEST_AVATAR_DIR}"
+ln -s ../../../seahub-data/avatars ${MEDIA_DIR}
+
+
+# -------------------------------------------
+# create logs directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/logs"
+
+
+# -------------------------------------------
+# Create symlink for current server version
+# -------------------------------------------
+ln -s $(basename ${INSTALLPATH}) ${SEAFILE_SERVER_SYMLINK}
+
+
+# Fix permissions
+chmod 0600 "$DEST_SETTINGS_PY"
+chmod 0700 "$DEFAULT_CCNET_CONF_DIR"
+chmod 0700 "$SEAFILE_DATA_DIR"
+chmod 0700 "$DEFAULT_CONF_DIR"
+
+
+# -------------------------------------------
+# copy user manuals to library template
+# -------------------------------------------
+mkdir -p ${LIBRARY_TEMPLATE_DIR}
+cp -f ${SRC_DOCS_DIR}/*.doc ${LIBRARY_TEMPLATE_DIR}
+
+
+# -------------------------------------------
+# Configuring ccnet.conf
+# -------------------------------------------
+SEAFILESQLPW=$(grep password /opt/seafile/.my.cnf | awk -F'=' {'print $2'})
+
+cat >> ${DEFAULT_CCNET_CONF_DIR}/ccnet.conf <> ${DEST_SETTINGS_PY} < ${seafile_dir}/aio_seafile-server.log<
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+#
+#set -x
+# -------------------------------------------
+# All-In-One Seafile Server installer for Debian Wheezy (64bit)
+# -------------------------------------------
+clear
+cat < /etc/apt/sources.list.d/nginx.list < /etc/nginx/conf.d/seafile.conf <<'EOF'
+server {
+ listen 80;
+ server_name "";
+
+ location / {
+ fastcgi_pass 127.0.0.1:8000;
+ 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;
+
+ access_log /var/log/nginx/seahub.access.log;
+ error_log /var/log/nginx/seahub.error.log;
+ }
+ location /seafhttp {
+ rewrite ^/seafhttp(.*)$ $1 break;
+ proxy_pass http://127.0.0.1:8082;
+ client_max_body_size 0;
+ proxy_connect_timeout 36000s;
+ proxy_read_timeout 36000s;
+ }
+ location /media {
+ root /opt/seafile/haiwen/seafile-server-latest/seahub;
+ }
+ location /seafdav {
+ fastcgi_pass 127.0.0.1:8080;
+ 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;
+
+ client_max_body_size 0;
+
+ access_log /var/log/nginx/seafdav.access.log;
+ error_log /var/log/nginx/seafdav.error.log;
+ }
+ }
+EOF
+
+service nginx restart
+
+
+# -------------------------------------------
+# Additional requirements
+# -------------------------------------------
+aptitude install sudo python-setuptools python-simplejson python-imaging python-mysqldb \
+openjdk-7-jre memcached python-memcache pwgen curl -y
+
+
+# -------------------------------------------
+# MariaDB
+# -------------------------------------------
+cat > /etc/apt/sources.list.d/mariadb.list < /root/.my.cnf < /etc/init.d/seafile-server <<'EOF'
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: seafile-server
+# Required-Start: $remote_fs $syslog mysql
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Seafile server
+# Description: Start Seafile server
+### END INIT INFO
+
+# Author: Alexander Jackson
+#
+
+# Change the value of "user" to your linux user name
+user=seafile
+
+# Change the value of "seafile_dir" to your path of seafile installation
+seafile_dir=/opt/seafile
+script_path=${seafile_dir}/seafile-server-latest
+seafile_init_log=${seafile_dir}/logs/seafile.init.log
+seahub_init_log=${seafile_dir}/logs/seahub.init.log
+
+# Change the value of fastcgi to true if fastcgi is to be used
+fastcgi=true
+# Set the port of fastcgi, default is 8000. Change it if you need different.
+fastcgi_port=8000
+
+case "$1" in
+ start)
+ sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${user} ${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log}
+ else
+ sudo -u ${user} ${script_path}/seahub.sh start >> ${seahub_init_log}
+ fi
+ ;;
+ restart)
+ sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${seahub_init_log}
+ else
+ sudo -u ${user} ${script_path}/seahub.sh restart >> ${seahub_init_log}
+ fi
+ ;;
+ stop)
+ sudo -u ${user} ${script_path}/seafile.sh $1 >> ${seafile_init_log}
+ sudo -u ${user} ${script_path}/seahub.sh $1 >> ${seahub_init_log}
+ ;;
+ *)
+ echo "Usage: /etc/init.d/seafile-server {start|stop|restart}"
+ exit 1
+ ;;
+esac
+EOF
+
+chmod +x /etc/init.d/seafile-server
+update-rc.d seafile-server defaults
+
+
+# -------------------------------------------
+# Seafile
+# -------------------------------------------
+adduser --system --gecos "seafile" seafile --home /opt/seafile
+mkdir -p /opt/seafile/haiwen/installed
+cd /opt/seafile/haiwen/
+curl -OL https://download.seafile.com.de/seafile-server_latest_x86-64.tar.gz
+tar xzf seafile-server_latest_x86-64.tar.gz
+
+SEAFILE_VERSION=$(basename /opt/seafile/haiwen/seafile-server-* | awk -F'-' ' { print $3 }')
+
+mv seafile-server_latest_x86-64.tar.gz installed/seafile-server_${SEAFILE_VERSION}_x86-64.tar.gz
+
+
+# -------------------------------------------
+# Seafile DB
+# -------------------------------------------
+SQLSEAFILEPW=$(pwgen)
+
+cat > /opt/seafile/.my.cnf < "${DEFAULT_CCNET_CONF_DIR}/seafile.ini"
+
+
+# -------------------------------------------
+# Configure Seafile WebDAV Server(SeafDAV)
+# -------------------------------------------
+mkdir -p ${DEFAULT_CONF_DIR}
+cat > ${DEFAULT_CONF_DIR}/seafdav.conf < "${DEST_SETTINGS_PY}"
+
+
+# -------------------------------------------
+# prepare avatar directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/seahub-data"
+mv "${ORIG_AVATAR_DIR}" "${DEST_AVATAR_DIR}"
+ln -s ../../../seahub-data/avatars ${MEDIA_DIR}
+
+
+# -------------------------------------------
+# create logs directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/logs"
+
+
+# -------------------------------------------
+# Create symlink for current server version
+# -------------------------------------------
+ln -s $(basename ${INSTALLPATH}) ${SEAFILE_SERVER_SYMLINK}
+
+
+# Fix permissions
+chmod 0600 "$DEST_SETTINGS_PY"
+chmod 0700 "$DEFAULT_CCNET_CONF_DIR"
+chmod 0700 "$SEAFILE_DATA_DIR"
+chmod 0700 "$DEFAULT_CONF_DIR"
+
+
+# -------------------------------------------
+# copy user manuals to library template
+# -------------------------------------------
+mkdir -p ${LIBRARY_TEMPLATE_DIR}
+cp -f ${SRC_DOCS_DIR}/*.doc ${LIBRARY_TEMPLATE_DIR}
+
+
+# -------------------------------------------
+# Configuring ccnet.conf
+# -------------------------------------------
+cat >> ${DEFAULT_CCNET_CONF_DIR}/ccnet.conf <> ${DEST_SETTINGS_PY} < ${seafile_dir}/aio_seafile-server.log<
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+#
+#set -x
+# -------------------------------------------
+# Vars
+# -------------------------------------------
+SEAFILE_ADMIN=admin@seafile.lan
+SEAFILE_USER=seafile
+SEAFILE_SERVER_NAME=$(hostname -s | cut -c -16)
+SEAFILE_DNS=$(hostname -i)
+HOSTNAME=$(hostname -i)
+FILESERVER_PORT=8082
+SERVER_PORT=10001
+SEAFILE_SERVER_PORT=12001
+# Don't touch the following variable, unless you know what you are doing
+SEAFILE_VERSION=4.1.2
+SEAFILE_EDITION=pro-server
+SEAFILE_SOURCE=/usr/src/seafile/seafile-${SEAFILE_EDITION}_${SEAFILE_VERSION}_x86-64.tar.gz
+
+
+# -------------------------------------------
+# Seafile Server Professional Edition on Debian Jessie (64bit)
+# -------------------------------------------
+clear
+cat < /dev/null 2>&1 ;
+then
+ echo " Aborting because user ${SEAFILE_USER} already exist" ; exit 1
+fi
+
+
+# -------------------------------------------
+# Abort if directory /opt/seafile/ exists
+# -------------------------------------------
+if [[ -d "/opt/seafile/" ]] ;
+then
+ echo " Aborting because directory /opt/seafile/ already exist" ; exit 1
+fi
+
+
+# -------------------------------------------
+# Update System
+# -------------------------------------------
+apt-get update
+apt-get dist-upgrade -y
+
+
+# -------------------------------------------
+# Additional requirements
+# -------------------------------------------
+apt-get install sudo ntp htop pwgen curl openssl unattended-upgrades -y
+
+
+# -------------------------------------------
+# ensure correct time is set
+# -------------------------------------------
+ntpd -gq
+
+
+# -------------------------------------------
+# Security programs
+# -------------------------------------------
+apt-get install ufw fail2ban -y
+
+
+# -------------------------------------------
+# Activate firewall
+# -------------------------------------------
+for i in ssh http https ; do ufw allow $i; done
+yes | ufw enable
+
+
+# -------------------------------------------
+# Seafile requirements
+# -------------------------------------------
+apt-get install python-setuptools python-simplejson python-imaging python-mysqldb \
+openjdk-7-jre memcached python-memcache libreoffice python-uno poppler-utils -y
+
+
+# -------------------------------------------
+# NGINX
+# -------------------------------------------
+cat > /etc/apt/sources.list.d/nginx.list < /etc/nginx/conf.d/seafile.conf <<'EOF'
+server {
+ listen 80;
+ server_name "";
+
+ location / {
+ fastcgi_pass 127.0.0.1:8000;
+ 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;
+
+ access_log /var/log/nginx/seahub.access.log;
+ error_log /var/log/nginx/seahub.error.log;
+ }
+ location /seafhttp {
+ rewrite ^/seafhttp(.*)$ $1 break;
+ proxy_pass http://127.0.0.1:8082;
+ client_max_body_size 0;
+ proxy_connect_timeout 36000s;
+ proxy_read_timeout 36000s;
+ }
+ location /media {
+ root /opt/seafile/seafile-server-latest/seahub;
+ }
+ location /seafdav {
+ fastcgi_pass 127.0.0.1:8080;
+ 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;
+
+ client_max_body_size 0;
+
+ access_log /var/log/nginx/seafdav.access.log;
+ error_log /var/log/nginx/seafdav.error.log;
+ }
+ }
+EOF
+
+mkdir /etc/nginx/ssl
+
+openssl genrsa -out /etc/nginx/ssl/seafile.key 4096
+openssl req -new -x509 -key /etc/nginx/ssl/seafile.key -out /etc/nginx/ssl/seafile.crt -days 10950 -batch
+
+
+# -------------------------------------------
+# Create optimized nginx.conf
+# -------------------------------------------
+cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
+
+cat > /etc/nginx/nginx.conf <<'ENDOFFILE'
+user nginx nginx;
+worker_processes 4;
+events {
+ worker_connections 8096;
+ multi_accept on;
+ use epoll;
+}
+pid /var/run/nginx.pid;
+worker_rlimit_nofile 40000;
+http {
+ server_tokens off;
+ server_names_hash_bucket_size 128;
+ client_max_body_size 50M;
+ include /etc/nginx/mime.types;
+ default_type application/octet-stream;
+ log_format main '$remote_addr - $remote_user [$time_local] "$request" '
+ '$status $body_bytes_sent "$http_referer" '
+ '"$http_user_agent" "$http_x_forwarded_for"';
+ access_log /var/log/nginx/access.log main;
+ error_log /var/log/nginx/error.log warn;
+ sendfile on;
+ tcp_nopush on;
+ tcp_nodelay on;
+ client_body_timeout 12;
+ client_header_timeout 12;
+ keepalive_timeout 15;
+ send_timeout 10;
+ gzip on;
+ gzip_vary on;
+ gzip_proxied expired no-cache no-store private auth any;
+ gzip_comp_level 9;
+ gzip_min_length 10240;
+ gzip_buffers 16 8k;
+ gzip_http_version 1.1;
+ gzip_types text/plain text/css text/xml text/javascript application/javascript application/x-javascript application/xml font/woff2;
+ gzip_disable "MSIE [1-6].";
+ include /etc/nginx/conf.d/*.conf;
+ include /etc/nginx/sites-enabled/*;
+ map $scheme $php_https { default off; https on; }
+ include perfect-forward-secrecy.conf;
+}
+ENDOFFILE
+
+
+# -------------------------------------------
+# Setup perfect forward secrecy
+# -------------------------------------------
+openssl dhparam -dsaparam -out /etc/nginx/dh4096.pem 4096
+
+cat > /etc/nginx/perfect-forward-secrecy.conf <<'EOF'
+ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
+ssl_prefer_server_ciphers on;
+ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA";
+ssl_dhparam dh4096.pem;
+ssl_session_cache shared:SSL:10m;
+ssl_session_timeout 10m;
+EOF
+
+
+# -------------------------------------------
+# Fix NGINX worker_processes to number of CPU cores
+# -------------------------------------------
+CPUS=$(cat /proc/cpuinfo | grep processor | wc | awk '{ print $1 }')
+eval "sed -i 's/worker_processes.*/worker_processes $CPUS;/g' /etc/nginx/nginx.conf"
+
+
+systemctl restart nginx
+
+
+# -------------------------------------------
+# MariaDB
+# -------------------------------------------
+DEBIAN_FRONTEND=noninteractive apt-get install mariadb-server -y
+
+SQLROOTPW=$(pwgen)
+
+mysqladmin -u root password $SQLROOTPW
+
+cat > /root/.my.cnf < /etc/init.d/seafile-server <<'EOF'
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: seafile-server
+# Required-Start: $remote_fs $syslog mysql
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Seafile server
+# Description: Start Seafile server
+### END INIT INFO
+
+# Author: Alexander Jackson
+#
+
+# Change the value of "user" to your linux user name
+USER=seafile
+
+# Change the value of "SEAFILE_DIR" to your path of seafile installation
+SEAFILE_DIR=/opt/seafile
+SCRIPT_PATH=${SEAFILE_DIR}/seafile-server-latest
+SEAFILE_INIT_LOG=${SEAFILE_DIR}/logs/seafile.init.log
+SEAHUB_INIT_LOG=${SEAFILE_DIR}/logs/seahub.init.log
+
+# Change the value of fastcgi to true if fastcgi is to be used
+fastcgi=true
+# Set the port of fastcgi, default is 8000. Change it if you need different.
+fastcgi_port=8000
+
+case "$1" in
+ start)
+ sudo -u ${USER} ${SCRIPT_PATH}/seafile.sh start >> ${SEAFILE_INIT_LOG}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${USER} ${SCRIPT_PATH}/seahub.sh start-fastcgi ${fastcgi_port} >> ${SEAHUB_INIT_LOG}
+ else
+ sudo -u ${USER} ${SCRIPT_PATH}/seahub.sh start >> ${SEAHUB_INIT_LOG}
+ fi
+ ;;
+ restart)
+ sudo -u ${USER} ${SCRIPT_PATH}/seafile.sh restart >> ${SEAFILE_INIT_LOG}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${USER} ${SCRIPT_PATH}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${SEAHUB_INIT_LOG}
+ else
+ sudo -u ${USER} ${SCRIPT_PATH}/seahub.sh restart >> ${SEAHUB_INIT_LOG}
+ fi
+ ;;
+ stop)
+ sudo -u ${USER} ${SCRIPT_PATH}/seafile.sh $1 >> ${SEAFILE_INIT_LOG}
+ sudo -u ${USER} ${SCRIPT_PATH}/seahub.sh $1 >> ${SEAHUB_INIT_LOG}
+ ;;
+ *)
+ echo "Usage: /etc/init.d/seafile-server {start|stop|restart}"
+ exit 1
+ ;;
+esac
+EOF
+
+chmod +x /etc/init.d/seafile-server
+systemctl enable seafile-server
+
+
+# -------------------------------------------
+# Install seafile-server-change-address script
+# -------------------------------------------
+cat > /usr/local/sbin/seafile-server-change-address <<'ENDOFFILE'
+#/bin/bash
+#set -x
+# -------------------------------------------
+# Vars
+# -------------------------------------------
+HOSTNAME=$(hostname -f)
+SEAFILE_DIR=/opt/seafile
+
+
+# -------------------------------------------
+# Intro
+# -------------------------------------------
+clear
+cat < /opt/seafile/.my.cnf < "${DEFAULT_CCNET_CONF_DIR}/seafile.ini"
+
+
+# -------------------------------------------
+# Configure Seafile WebDAV Server(SeafDAV)
+# -------------------------------------------
+mkdir -p ${DEFAULT_CONF_DIR}
+cat > ${DEFAULT_CONF_DIR}/seafdav.conf < "${DEST_SETTINGS_PY}"
+
+
+# -------------------------------------------
+# prepare avatar directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/seahub-data"
+mv "${ORIG_AVATAR_DIR}" "${DEST_AVATAR_DIR}"
+ln -s ../../../seahub-data/avatars ${MEDIA_DIR}
+
+
+# -------------------------------------------
+# create logs directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/logs"
+
+
+# -------------------------------------------
+# Create symlink for current server version
+# -------------------------------------------
+ln -s $(basename ${INSTALLPATH}) ${SEAFILE_SERVER_SYMLINK}
+
+
+# Fix permissions
+chmod 0600 "$DEST_SETTINGS_PY"
+chmod 0700 "$DEFAULT_CCNET_CONF_DIR"
+chmod 0700 "$SEAFILE_DATA_DIR"
+chmod 0700 "$DEFAULT_CONF_DIR"
+
+
+# -------------------------------------------
+# copy user manuals to library template
+# -------------------------------------------
+mkdir -p ${LIBRARY_TEMPLATE_DIR}
+cp -f ${SRC_DOCS_DIR}/*.doc ${LIBRARY_TEMPLATE_DIR}
+
+
+# -------------------------------------------
+# Setup professional features
+# -------------------------------------------
+PRO_PY=${INSTALLPATH}/pro/pro.py
+$PYTHON ${PRO_PY} setup
+
+
+# -------------------------------------------
+# Configuring ccnet.conf
+# -------------------------------------------
+SEAFILESQLPW=$(grep password /opt/seafile/.my.cnf | awk -F'=' {'print $2'})
+
+cat >> ${DEFAULT_CCNET_CONF_DIR}/ccnet.conf <> ${DEST_SETTINGS_PY} < ${SEAFILE_DIR}/seafile-pro-installer.log<
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+#
+#set -x
+# -------------------------------------------
+# Vars
+# -------------------------------------------
+SEAFILE_ADMIN=admin@seafile.local
+SEAFILE_USER=seafile
+SERVER_NAME=$(hostname -s)
+IP_OR_DOMAIN=$(hostname -i)
+HOSTNAME=$(hostname -i)
+FILESERVER_PORT=8082
+SERVER_PORT=10001
+SEAFILE_SERVER_PORT=12001
+
+
+# -------------------------------------------
+# Seafile Server Community Edition on Ubuntu Trusty (64bit)
+# -------------------------------------------
+clear
+cat < /dev/null 2>&1 ;
+then
+ echo " Aborting because user ${SEAFILE_USER} already exist" ; exit 1
+fi
+
+
+# -------------------------------------------
+# Abort if directory /opt/seafile/ exists
+# -------------------------------------------
+if [[ -d "/opt/seafile/" ]] ;
+then
+ echo " Aborting because directory /opt/seafile/ already exist" ; exit 1
+fi
+
+
+# -------------------------------------------
+# Update System
+# -------------------------------------------
+aptitude update && aptitude dist-upgrade -y
+
+
+# -------------------------------------------
+# Ensure aptitude is installed
+# -------------------------------------------
+apt-get install aptitude -y
+
+# -------------------------------------------
+# Additional requirements
+# -------------------------------------------
+aptitude install sudo python-setuptools python-simplejson python-imaging python-mysqldb \
+openjdk-7-jre memcached python-memcache pwgen curl openssl -y
+
+
+# -------------------------------------------
+# NGINX
+# -------------------------------------------
+cat > /etc/apt/sources.list.d/nginx.list < /etc/nginx/conf.d/seafile.conf <<'EOF'
+server {
+ listen 80;
+ server_name "";
+
+ location / {
+ fastcgi_pass 127.0.0.1:8000;
+ 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;
+
+ access_log /var/log/nginx/seahub.access.log;
+ error_log /var/log/nginx/seahub.error.log;
+ }
+ location /seafhttp {
+ rewrite ^/seafhttp(.*)$ $1 break;
+ proxy_pass http://127.0.0.1:8082;
+ client_max_body_size 0;
+ proxy_connect_timeout 36000s;
+ proxy_read_timeout 36000s;
+ }
+ location /media {
+ root /opt/seafile/seafile-server-latest/seahub;
+ }
+ location /seafdav {
+ fastcgi_pass 127.0.0.1:8080;
+ 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;
+
+ client_max_body_size 0;
+
+ access_log /var/log/nginx/seafdav.access.log;
+ error_log /var/log/nginx/seafdav.error.log;
+ }
+ }
+EOF
+
+service nginx restart
+
+
+# -------------------------------------------
+# MariaDB
+# -------------------------------------------
+DEBIAN_FRONTEND=noninteractive aptitude install mariadb-server -y
+
+SQLROOTPW=$(pwgen)
+
+mysqladmin -u root password $SQLROOTPW
+
+cat > /root/.my.cnf < /etc/init.d/seafile-server <<'EOF'
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: seafile-server
+# Required-Start: $remote_fs $syslog mysql
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Seafile server
+# Description: Start Seafile server
+### END INIT INFO
+
+# Author: Alexander Jackson
+#
+
+# Change the value of "user" to your linux user name
+user=seafile
+
+# Change the value of "seafile_dir" to your path of seafile installation
+seafile_dir=/opt/seafile
+script_path=${seafile_dir}/seafile-server-latest
+seafile_init_log=${seafile_dir}/logs/seafile.init.log
+seahub_init_log=${seafile_dir}/logs/seahub.init.log
+
+# Change the value of fastcgi to true if fastcgi is to be used
+fastcgi=true
+# Set the port of fastcgi, default is 8000. Change it if you need different.
+fastcgi_port=8000
+
+case "$1" in
+ start)
+ sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${user} ${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log}
+ else
+ sudo -u ${user} ${script_path}/seahub.sh start >> ${seahub_init_log}
+ fi
+ ;;
+ restart)
+ sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${seahub_init_log}
+ else
+ sudo -u ${user} ${script_path}/seahub.sh restart >> ${seahub_init_log}
+ fi
+ ;;
+ stop)
+ sudo -u ${user} ${script_path}/seafile.sh $1 >> ${seafile_init_log}
+ sudo -u ${user} ${script_path}/seahub.sh $1 >> ${seahub_init_log}
+ ;;
+ *)
+ echo "Usage: /etc/init.d/seafile-server {start|stop|restart}"
+ exit 1
+ ;;
+esac
+EOF
+
+chmod +x /etc/init.d/seafile-server
+update-rc.d seafile-server defaults
+
+
+# -------------------------------------------
+# Seafile
+# -------------------------------------------
+adduser --system --gecos "${SEAFILE_USER}" ${SEAFILE_USER} --home /opt/seafile
+mkdir -p /opt/seafile/installed
+cd /opt/seafile/
+curl -OL https://download.seafile.com.de/seafile-server_latest_x86-64.tar.gz
+tar xzf seafile-server_latest_x86-64.tar.gz
+
+SEAFILE_VERSION=$(basename /opt/seafile/seafile-server-* | awk -F'-' ' { print $3 }')
+
+mv seafile-server_latest_x86-64.tar.gz installed/seafile-server_${SEAFILE_VERSION}_x86-64.tar.gz
+
+
+# -------------------------------------------
+# Seafile DB
+# -------------------------------------------
+SQLSEAFILEPW=$(pwgen)
+
+cat > /opt/seafile/.my.cnf < "${DEFAULT_CCNET_CONF_DIR}/seafile.ini"
+
+
+# -------------------------------------------
+# Configure Seafile WebDAV Server(SeafDAV)
+# -------------------------------------------
+mkdir -p ${DEFAULT_CONF_DIR}
+cat > ${DEFAULT_CONF_DIR}/seafdav.conf < "${DEST_SETTINGS_PY}"
+
+
+# -------------------------------------------
+# prepare avatar directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/seahub-data"
+mv "${ORIG_AVATAR_DIR}" "${DEST_AVATAR_DIR}"
+ln -s ../../../seahub-data/avatars ${MEDIA_DIR}
+
+
+# -------------------------------------------
+# create logs directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/logs"
+
+
+# -------------------------------------------
+# Create symlink for current server version
+# -------------------------------------------
+ln -s $(basename ${INSTALLPATH}) ${SEAFILE_SERVER_SYMLINK}
+
+
+# Fix permissions
+chmod 0600 "$DEST_SETTINGS_PY"
+chmod 0700 "$DEFAULT_CCNET_CONF_DIR"
+chmod 0700 "$SEAFILE_DATA_DIR"
+chmod 0700 "$DEFAULT_CONF_DIR"
+
+
+# -------------------------------------------
+# copy user manuals to library template
+# -------------------------------------------
+mkdir -p ${LIBRARY_TEMPLATE_DIR}
+cp -f ${SRC_DOCS_DIR}/*.doc ${LIBRARY_TEMPLATE_DIR}
+
+
+# -------------------------------------------
+# Configuring ccnet.conf
+# -------------------------------------------
+SEAFILESQLPW=$(grep password /opt/seafile/.my.cnf | awk -F'=' {'print $2'})
+
+cat >> ${DEFAULT_CCNET_CONF_DIR}/ccnet.conf <> ${DEST_SETTINGS_PY} < ${seafile_dir}/aio_seafile-server.log<
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+#
+
+Anyone is welcome to make this one happen! ;-)
diff --git a/seafile-ce_centos-7-amd64 b/seafile-ce_centos-7-amd64
new file mode 100644
index 0000000..90ea992
--- /dev/null
+++ b/seafile-ce_centos-7-amd64
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+# seafile-server-installer/seafile-ce_centos-7-amd64
+#
+# Copyright 2015, Alexander Jackson
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+#
+
+Anyone is welcome to make this one happen! ;-)
diff --git a/seafile-ce_debian-jessie-amd64 b/seafile-ce_debian-jessie-amd64
new file mode 100644
index 0000000..adfbb7b
--- /dev/null
+++ b/seafile-ce_debian-jessie-amd64
@@ -0,0 +1,623 @@
+#!/bin/bash
+#
+# seafile-server-installer/seafile-ce_debian-jessie-amd64
+#
+# Copyright 2015, Alexander Jackson
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+#
+#set -x
+# -------------------------------------------
+# Vars
+# -------------------------------------------
+SEAFILE_ADMIN=admin@seafile.local
+SEAFILE_USER=seafile
+SERVER_NAME=$(hostname -s | cut -c -16)
+IP_OR_DOMAIN=$(hostname -i)
+HOSTNAME=$(hostname -i)
+FILESERVER_PORT=8082
+SERVER_PORT=10001
+SEAFILE_SERVER_PORT=12001
+
+
+# -------------------------------------------
+# Seafile Server Community Edition on Debian Jessie (64bit)
+# -------------------------------------------
+clear
+cat < /dev/null 2>&1 ;
+then
+ echo " Aborting because user ${SEAFILE_USER} already exist" ; exit 1
+fi
+
+
+# -------------------------------------------
+# Abort if directory /opt/seafile/ exists
+# -------------------------------------------
+if [[ -d "/opt/seafile/" ]] ;
+then
+ echo " Aborting because directory /opt/seafile/ already exist" ; exit 1
+fi
+
+
+# -------------------------------------------
+# Update System
+# -------------------------------------------
+apt-get update && apt-get dist-upgrade -y
+
+
+# -------------------------------------------
+# Ensure aptitude is installed
+# -------------------------------------------
+apt-get install aptitude -y
+
+
+# -------------------------------------------
+# Additional requirements
+# -------------------------------------------
+aptitude install sudo python-setuptools python-simplejson python-imaging python-mysqldb \
+openjdk-7-jre memcached python-memcache pwgen curl openssl -y
+
+
+# -------------------------------------------
+# NGINX
+# -------------------------------------------
+cat > /etc/apt/sources.list.d/nginx.list < /etc/nginx/conf.d/seafile.conf <<'EOF'
+server {
+ listen 80;
+ server_name "";
+ return 301 https://$http_host$request_uri?;
+}
+
+server {
+ listen 443 spdy;
+ server_name "";
+
+ ssl on;
+ ssl_certificate /etc/nginx/ssl/seafile.crt;
+ ssl_certificate_key /etc/nginx/ssl/seafile.key;
+
+ location / {
+ fastcgi_pass 127.0.0.1:8000;
+ 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;
+ fastcgi_param HTTP_SCHEME https;
+
+ access_log /var/log/nginx/seahub.access.log;
+ error_log /var/log/nginx/seahub.error.log;
+ }
+ location /seafhttp {
+ rewrite ^/seafhttp(.*)$ $1 break;
+ proxy_pass http://127.0.0.1:8082;
+ client_max_body_size 0;
+ proxy_connect_timeout 36000s;
+ proxy_read_timeout 36000s;
+ }
+ location /media {
+ root /opt/seafile/seafile-server-latest/seahub;
+ }
+ location /seafdav {
+ fastcgi_pass 127.0.0.1:8080;
+ 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;
+ }
+ }
+EOF
+
+mkdir /etc/nginx/ssl
+
+openssl genrsa -out /etc/nginx/ssl/seafile.key 4096
+openssl req -new -x509 -key /etc/nginx/ssl/seafile.key -out /etc/nginx/ssl/seafile.crt -days 10950 -batch
+
+service nginx restart
+
+
+# -------------------------------------------
+# MariaDB
+# -------------------------------------------
+DEBIAN_FRONTEND=noninteractive aptitude install mariadb-server -y
+
+SQLROOTPW=$(pwgen)
+
+mysqladmin -u root password $SQLROOTPW
+
+cat > /root/.my.cnf < /etc/init.d/seafile-server <<'EOF'
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: seafile-server
+# Required-Start: $remote_fs $syslog mysql
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Seafile server
+# Description: Start Seafile server
+### END INIT INFO
+
+# Author: Alexander Jackson
+#
+
+# Change the value of "user" to your linux user name
+user=seafile
+
+# Change the value of "seafile_dir" to your path of seafile installation
+seafile_dir=/opt/seafile
+script_path=${seafile_dir}/seafile-server-latest
+seafile_init_log=${seafile_dir}/logs/seafile.init.log
+seahub_init_log=${seafile_dir}/logs/seahub.init.log
+
+# Change the value of fastcgi to true if fastcgi is to be used
+fastcgi=true
+# Set the port of fastcgi, default is 8000. Change it if you need different.
+fastcgi_port=8000
+
+case "$1" in
+ start)
+ sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${user} ${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log}
+ else
+ sudo -u ${user} ${script_path}/seahub.sh start >> ${seahub_init_log}
+ fi
+ ;;
+ restart)
+ sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${seahub_init_log}
+ else
+ sudo -u ${user} ${script_path}/seahub.sh restart >> ${seahub_init_log}
+ fi
+ ;;
+ stop)
+ sudo -u ${user} ${script_path}/seafile.sh $1 >> ${seafile_init_log}
+ sudo -u ${user} ${script_path}/seahub.sh $1 >> ${seahub_init_log}
+ ;;
+ *)
+ echo "Usage: /etc/init.d/seafile-server {start|stop|restart}"
+ exit 1
+ ;;
+esac
+EOF
+
+chmod +x /etc/init.d/seafile-server
+update-rc.d seafile-server defaults
+
+
+# -------------------------------------------
+# Seafile
+# -------------------------------------------
+adduser --system --gecos "${SEAFILE_USER}" ${SEAFILE_USER} --home /opt/seafile
+mkdir -p /opt/seafile/installed
+cd /opt/seafile/
+curl -OL https://download.seafile.com.de/seafile-server_latest_x86-64.tar.gz
+tar xzf seafile-server_latest_x86-64.tar.gz
+
+SEAFILE_VERSION=$(basename /opt/seafile/seafile-server-* | awk -F'-' ' { print $3 }')
+
+mv seafile-server_latest_x86-64.tar.gz installed/seafile-server_${SEAFILE_VERSION}_x86-64.tar.gz
+
+
+# -------------------------------------------
+# Seafile DB
+# -------------------------------------------
+SQLSEAFILEPW=$(pwgen)
+
+cat > /opt/seafile/.my.cnf < "${DEFAULT_CCNET_CONF_DIR}/seafile.ini"
+
+
+# -------------------------------------------
+# Configure Seafile WebDAV Server(SeafDAV)
+# -------------------------------------------
+mkdir -p ${DEFAULT_CONF_DIR}
+cat > ${DEFAULT_CONF_DIR}/seafdav.conf < "${DEST_SETTINGS_PY}"
+
+
+# -------------------------------------------
+# prepare avatar directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/seahub-data"
+mv "${ORIG_AVATAR_DIR}" "${DEST_AVATAR_DIR}"
+ln -s ../../../seahub-data/avatars ${MEDIA_DIR}
+
+
+# -------------------------------------------
+# create logs directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/logs"
+
+
+# -------------------------------------------
+# Create symlink for current server version
+# -------------------------------------------
+ln -s $(basename ${INSTALLPATH}) ${SEAFILE_SERVER_SYMLINK}
+
+
+# Fix permissions
+chmod 0600 "$DEST_SETTINGS_PY"
+chmod 0700 "$DEFAULT_CCNET_CONF_DIR"
+chmod 0700 "$SEAFILE_DATA_DIR"
+chmod 0700 "$DEFAULT_CONF_DIR"
+
+
+# -------------------------------------------
+# copy user manuals to library template
+# -------------------------------------------
+mkdir -p ${LIBRARY_TEMPLATE_DIR}
+cp -f ${SRC_DOCS_DIR}/*.doc ${LIBRARY_TEMPLATE_DIR}
+
+
+# -------------------------------------------
+# Configuring ccnet.conf
+# -------------------------------------------
+SEAFILESQLPW=$(grep password /opt/seafile/.my.cnf | awk -F'=' {'print $2'})
+
+cat >> ${DEFAULT_CCNET_CONF_DIR}/ccnet.conf <> ${DEST_SETTINGS_PY} < ${seafile_dir}/aio_seafile-server.log<
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+#
+#set -x
+# -------------------------------------------
+# Vars
+# -------------------------------------------
+SEAFILE_ADMIN=admin@seafile.local
+SEAFILE_USER=seafile
+SERVER_NAME=$(hostname -s | cut -c -16)
+IP_OR_DOMAIN=$(hostname -i)
+HOSTNAME=$(hostname -i)
+FILESERVER_PORT=8082
+SERVER_PORT=10001
+SEAFILE_SERVER_PORT=12001
+
+
+# -------------------------------------------
+# Seafile Server Community Edition on Debian Jessie (32bit)
+# -------------------------------------------
+clear
+cat < /dev/null 2>&1 ;
+#then
+# echo " Aborting because user ${SEAFILE_USER} already exist" ; exit 1
+#fi
+
+
+# -------------------------------------------
+# Abort if directory /opt/seafile/ exists
+# -------------------------------------------
+#if [[ -d "/opt/seafile/" ]] ;
+#then
+# echo " Aborting because directory /opt/seafile/ already exist" ; exit 1
+#fi
+
+
+# -------------------------------------------
+# Update System
+# -------------------------------------------
+apt-get update && apt-get dist-upgrade -y
+
+
+# -------------------------------------------
+# Ensure aptitude is installed
+# -------------------------------------------
+apt-get install aptitude -y
+
+
+# -------------------------------------------
+# Additional requirements
+# -------------------------------------------
+aptitude install sudo python-setuptools python-simplejson python-imaging python-mysqldb \
+openjdk-7-jre memcached python-memcache pwgen curl openssl -y
+
+
+# -------------------------------------------
+# NGINX
+# -------------------------------------------
+cat > /etc/apt/sources.list.d/nginx.list < /etc/nginx/conf.d/seafile.conf <<'EOF'
+server {
+ listen 80;
+ server_name "";
+ return 301 https://$http_host$request_uri?;
+}
+
+server {
+ listen 443 spdy;
+ server_name "";
+
+ ssl on;
+ ssl_certificate /etc/nginx/ssl/seafile.crt;
+ ssl_certificate_key /etc/nginx/ssl/seafile.key;
+
+ location / {
+ fastcgi_pass 127.0.0.1:8000;
+ 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;
+ fastcgi_param HTTP_SCHEME https;
+
+ access_log /var/log/nginx/seahub.access.log;
+ error_log /var/log/nginx/seahub.error.log;
+ }
+ location /seafhttp {
+ rewrite ^/seafhttp(.*)$ $1 break;
+ proxy_pass http://127.0.0.1:8082;
+ client_max_body_size 0;
+ proxy_connect_timeout 36000s;
+ proxy_read_timeout 36000s;
+ }
+ location /media {
+ root /opt/seafile/seafile-server-latest/seahub;
+ }
+ location /seafdav {
+ fastcgi_pass 127.0.0.1:8080;
+ 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;
+ }
+ }
+EOF
+
+mkdir /etc/nginx/ssl
+
+openssl genrsa -out /etc/nginx/ssl/seafile.key 4096
+openssl req -new -x509 -key /etc/nginx/ssl/seafile.key -out /etc/nginx/ssl/seafile.crt -days 10950 -batch
+
+service nginx restart
+
+
+# -------------------------------------------
+# MariaDB
+# -------------------------------------------
+#DEBIAN_FRONTEND=noninteractive aptitude install mariadb-server -y
+
+#SQLROOTPW=$(pwgen)
+
+#mysqladmin -u root password $SQLROOTPW
+
+#cat > /root/.my.cnf < /etc/init.d/seafile-server <<'EOF'
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: seafile-server
+# Required-Start: $remote_fs $syslog mysql
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Seafile server
+# Description: Start Seafile server
+### END INIT INFO
+
+# Author: Alexander Jackson
+#
+
+# Change the value of "user" to your linux user name
+user=seafile
+
+# Change the value of "seafile_dir" to your path of seafile installation
+seafile_dir=/opt/seafile
+script_path=${seafile_dir}/seafile-server-latest
+seafile_init_log=${seafile_dir}/logs/seafile.init.log
+seahub_init_log=${seafile_dir}/logs/seahub.init.log
+
+# Change the value of fastcgi to true if fastcgi is to be used
+fastcgi=true
+# Set the port of fastcgi, default is 8000. Change it if you need different.
+fastcgi_port=8000
+
+case "$1" in
+ start)
+ sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${user} ${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log}
+ else
+ sudo -u ${user} ${script_path}/seahub.sh start >> ${seahub_init_log}
+ fi
+ ;;
+ restart)
+ sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${seahub_init_log}
+ else
+ sudo -u ${user} ${script_path}/seahub.sh restart >> ${seahub_init_log}
+ fi
+ ;;
+ stop)
+ sudo -u ${user} ${script_path}/seafile.sh $1 >> ${seafile_init_log}
+ sudo -u ${user} ${script_path}/seahub.sh $1 >> ${seahub_init_log}
+ ;;
+ *)
+ echo "Usage: /etc/init.d/seafile-server {start|stop|restart}"
+ exit 1
+ ;;
+esac
+EOF
+
+chmod +x /etc/init.d/seafile-server
+update-rc.d seafile-server defaults
+
+
+# -------------------------------------------
+# Seafile
+# -------------------------------------------
+adduser --system --gecos "${SEAFILE_USER}" ${SEAFILE_USER} --home /opt/seafile
+mkdir -p /opt/seafile/installed
+cd /opt/seafile/
+curl -OL https://download.seafile.com.de/seafile-server_latest_i386.tar.gz
+tar xzf seafile-server_latest_i386.tar.gz
+
+SEAFILE_VERSION=$(basename /opt/seafile/seafile-server-* | awk -F'-' ' { print $3 }')
+
+mv seafile-server_4.1.2_i386.tar.gz installed/seafile-server_${SEAFILE_VERSION}_i386.tar.gz
+
+
+# -------------------------------------------
+# Seafile DB
+# -------------------------------------------
+SQLSEAFILEPW=$(pwgen)
+
+cat > /opt/seafile/.my.cnf < "${DEFAULT_CCNET_CONF_DIR}/seafile.ini"
+
+
+# -------------------------------------------
+# Configure Seafile WebDAV Server(SeafDAV)
+# -------------------------------------------
+mkdir -p ${DEFAULT_CONF_DIR}
+cat > ${DEFAULT_CONF_DIR}/seafdav.conf < "${DEST_SETTINGS_PY}"
+
+
+# -------------------------------------------
+# prepare avatar directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/seahub-data"
+mv "${ORIG_AVATAR_DIR}" "${DEST_AVATAR_DIR}"
+ln -s ../../../seahub-data/avatars ${MEDIA_DIR}
+
+
+# -------------------------------------------
+# create logs directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/logs"
+
+
+# -------------------------------------------
+# Create symlink for current server version
+# -------------------------------------------
+ln -s $(basename ${INSTALLPATH}) ${SEAFILE_SERVER_SYMLINK}
+
+
+# Fix permissions
+chmod 0600 "$DEST_SETTINGS_PY"
+chmod 0700 "$DEFAULT_CCNET_CONF_DIR"
+chmod 0700 "$SEAFILE_DATA_DIR"
+chmod 0700 "$DEFAULT_CONF_DIR"
+
+
+# -------------------------------------------
+# copy user manuals to library template
+# -------------------------------------------
+mkdir -p ${LIBRARY_TEMPLATE_DIR}
+cp -f ${SRC_DOCS_DIR}/*.doc ${LIBRARY_TEMPLATE_DIR}
+
+
+# -------------------------------------------
+# Configuring ccnet.conf
+# -------------------------------------------
+SEAFILESQLPW=$(grep password /opt/seafile/.my.cnf | awk -F'=' {'print $2'})
+
+cat >> ${DEFAULT_CCNET_CONF_DIR}/ccnet.conf <> ${DEST_SETTINGS_PY} < ${seafile_dir}/aio_seafile-server.log<
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+#
+#set -x
+# -------------------------------------------
+# All-In-One Seafile Server installer for Debian Wheezy (64bit)
+# -------------------------------------------
+clear
+cat < /etc/apt/sources.list.d/nginx.list < /etc/nginx/conf.d/seafile.conf <<'EOF'
+server {
+ listen 80;
+ server_name "";
+ return 301 https://$http_host$request_uri?;
+}
+
+server {
+ listen 443 spdy;
+ server_name "";
+
+ ssl on;
+ ssl_certificate /etc/nginx/ssl/seafile.crt;
+ ssl_certificate_key /etc/nginx/ssl/seafile.key;
+
+ location / {
+ fastcgi_pass 127.0.0.1:8000;
+ 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;
+ fastcgi_param HTTP_SCHEME https;
+
+ access_log /var/log/nginx/seahub.access.log;
+ error_log /var/log/nginx/seahub.error.log;
+ }
+ location /seafhttp {
+ rewrite ^/seafhttp(.*)$ $1 break;
+ proxy_pass http://127.0.0.1:8082;
+ client_max_body_size 0;
+ proxy_connect_timeout 36000s;
+ proxy_read_timeout 36000s;
+ }
+ location /media {
+ root /opt/seafile/haiwen/seafile-server-latest/seahub;
+ }
+ location /seafdav {
+ fastcgi_pass 127.0.0.1:8080;
+ 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;
+ }
+ }
+EOF
+
+mkdir /etc/nginx/ssl
+
+openssl genrsa -out /etc/nginx/ssl/seafile.key 4096
+openssl req -new -x509 -key /etc/nginx/ssl/seafile.key -out /etc/nginx/ssl/seafile.crt -days 10950 -batch
+
+service nginx restart
+
+
+# -------------------------------------------
+# Additional requirements
+# -------------------------------------------
+aptitude install sudo python-setuptools python-simplejson python-imaging python-mysqldb \
+openjdk-7-jre memcached python-memcache pwgen curl -y
+
+
+# -------------------------------------------
+# MariaDB
+# -------------------------------------------
+cat > /etc/apt/sources.list.d/mariadb.list < /root/.my.cnf < /etc/init.d/seafile-server <<'EOF'
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: seafile-server
+# Required-Start: $remote_fs $syslog mysql
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Seafile server
+# Description: Start Seafile server
+### END INIT INFO
+
+# Author: Alexander Jackson
+#
+
+# Change the value of "user" to your linux user name
+user=seafile
+
+# Change the value of "seafile_dir" to your path of seafile installation
+seafile_dir=/opt/seafile/haiwen
+script_path=${seafile_dir}/seafile-server-latest
+seafile_init_log=${seafile_dir}/logs/seafile.init.log
+seahub_init_log=${seafile_dir}/logs/seahub.init.log
+
+# Change the value of fastcgi to true if fastcgi is to be used
+fastcgi=true
+# Set the port of fastcgi, default is 8000. Change it if you need different.
+fastcgi_port=8000
+
+case "$1" in
+ start)
+ sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${user} ${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log}
+ else
+ sudo -u ${user} ${script_path}/seahub.sh start >> ${seahub_init_log}
+ fi
+ ;;
+ restart)
+ sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${seahub_init_log}
+ else
+ sudo -u ${user} ${script_path}/seahub.sh restart >> ${seahub_init_log}
+ fi
+ ;;
+ stop)
+ sudo -u ${user} ${script_path}/seafile.sh $1 >> ${seafile_init_log}
+ sudo -u ${user} ${script_path}/seahub.sh $1 >> ${seahub_init_log}
+ ;;
+ *)
+ echo "Usage: /etc/init.d/seafile-server {start|stop|restart}"
+ exit 1
+ ;;
+esac
+EOF
+
+chmod +x /etc/init.d/seafile-server
+update-rc.d seafile-server defaults
+
+
+# -------------------------------------------
+# Seafile
+# -------------------------------------------
+adduser --system --gecos "seafile" seafile --home /opt/seafile
+mkdir -p /opt/seafile/haiwen/installed
+cd /opt/seafile/haiwen/
+curl -OL https://download.seafile.com.de/seafile-server_latest_x86-64.tar.gz
+tar xzf seafile-server_latest_x86-64.tar.gz
+
+SEAFILE_VERSION=$(basename /opt/seafile/haiwen/seafile-server-* | awk -F'-' ' { print $3 }')
+
+mv seafile-server_latest_x86-64.tar.gz installed/seafile-server_${SEAFILE_VERSION}_x86-64.tar.gz
+
+
+# -------------------------------------------
+# Seafile DB
+# -------------------------------------------
+SQLSEAFILEPW=$(pwgen)
+
+cat > /opt/seafile/.my.cnf < "${DEFAULT_CCNET_CONF_DIR}/seafile.ini"
+
+
+# -------------------------------------------
+# Configure Seafile WebDAV Server(SeafDAV)
+# -------------------------------------------
+mkdir -p ${DEFAULT_CONF_DIR}
+cat > ${DEFAULT_CONF_DIR}/seafdav.conf < "${DEST_SETTINGS_PY}"
+
+
+# -------------------------------------------
+# prepare avatar directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/seahub-data"
+mv "${ORIG_AVATAR_DIR}" "${DEST_AVATAR_DIR}"
+ln -s ../../../seahub-data/avatars ${MEDIA_DIR}
+
+
+# -------------------------------------------
+# create logs directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/logs"
+
+
+# -------------------------------------------
+# Create symlink for current server version
+# -------------------------------------------
+ln -s $(basename ${INSTALLPATH}) ${SEAFILE_SERVER_SYMLINK}
+
+
+# Fix permissions
+chmod 0600 "$DEST_SETTINGS_PY"
+chmod 0700 "$DEFAULT_CCNET_CONF_DIR"
+chmod 0700 "$SEAFILE_DATA_DIR"
+chmod 0700 "$DEFAULT_CONF_DIR"
+
+
+# -------------------------------------------
+# copy user manuals to library template
+# -------------------------------------------
+mkdir -p ${LIBRARY_TEMPLATE_DIR}
+cp -f ${SRC_DOCS_DIR}/*.doc ${LIBRARY_TEMPLATE_DIR}
+
+
+# -------------------------------------------
+# Configuring ccnet.conf
+# -------------------------------------------
+cat >> ${DEFAULT_CCNET_CONF_DIR}/ccnet.conf <> ${DEST_SETTINGS_PY} < ${seafile_dir}/aio_seafile-server.log<
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+#
+#set -x
+# -------------------------------------------
+# Vars
+# -------------------------------------------
+SEAFILE_ADMIN=admin@seafile.local
+SEAFILE_USER=seafile
+WHOAMI=$(whoami)
+HOSTNAME=$(hostname -f)
+SERVER_NAME=$(echo ${WHOAMI}$(hostname -s) | cut -c -16)
+
+
+# -------------------------------------------
+# Seafile Server Community Edition on Uberspace
+# -------------------------------------------
+clear
+cat < ${PORT_LIST}
+
+COUNT=1
+while [ ${COUNT} -le 5 ]; do
+ ISFREE=$(netstat -tapln | grep ${PORT})
+ while [[ -n "${ISFREE}" ]]; do
+ PORT=$[PORT+INCREMENT]
+ ISFREE=$(netstat -tapln | grep ${PORT});
+ if [ ${COUNT} > ${END_PORT} ]; then
+ echo "Not enough free ports available. Aborting installation!" ; exit 1
+ fi
+ done
+
+# Write free port to file
+echo -n "${PORT} " >> ${PORT_LIST}
+
+# Increment search port
+PORT=$(( PORT+1 ))
+
+# Increment loop counter
+(( COUNT++ ))
+done
+
+# Import free ports to vars
+read SEAHUB_PORT FILESERVER_PORT SERVER_PORT SEAFILE_SERVER_PORT SEAFDAV_PORT< ${PORT_LIST}
+
+# Delete port list
+rm ${PORT_LIST}
+
+
+# -------------------------------------------
+# Apache htaccess
+# -------------------------------------------
+cat > ~/html/.htaccess <<"EOF"
+RewriteEngine on
+
+# Redirect to https
+RewriteCond %{HTTPS} !=on
+RewriteCond %{ENV:HTTPS} !=on
+RewriteRule ^(.*)$ https://WHOAMI.HOSTNAME/$1 [L,R=301]
+
+# Port of seafile httpserver (compare ~/haiwen/seafile-data/seafile.conf)
+RewriteRule ^seafhttp/(.*)$ http://localhost:FILESERVER_PORT/$1 [QSA,P,L]
+
+RewriteRule ^/(seafmedia.*)$ /$1 [QSA,L,PT]
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteRule ^(.*)$ /fcgi-bin/seahub/$1 [QSA,L,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
+EOF
+
+# Set seahub port
+eval sed -i 's/WHOAMI/${WHOAMI}/' ~/html/.htaccess
+eval sed -i 's/HOSTNAME/${HOSTNAME}/' ~/html/.htaccess
+eval sed -i 's/FILESERVER_PORT/${FILESERVER_PORT}/' ~/html/.htaccess
+
+
+# -------------------------------------------
+# Create Seahub FastCGI script
+# -------------------------------------------
+cat > ~/fcgi-bin/seahub < ~/bin/seafile <<'ENDOFILE'
+#!/bin/bash
+# Short-Description: Seafile server
+# Description: Start Seafile server
+### END INIT INFO
+# Author: Alexander Jackson
+#
+# Change the value of "seafile_dir" to your path of seafile installation
+seafile_dir=~/seafile
+script_path=${seafile_dir}/seafile-server-latest
+seafile_init_log=${seafile_dir}/logs/seafile.init.log
+
+case "$1" in
+ start)
+ ${script_path}/seafile.sh start >> ${seafile_init_log}
+ ;;
+ restart)
+ ${script_path}/seafile.sh restart >> ${seafile_init_log}
+ ;;
+ stop)
+ ${script_path}/seafile.sh $1 >> ${seafile_init_log} && \
+ ps aux | grep seahub | grep -v grep | awk '{ print $2 }' | while read line; do kill $line ; done
+ ;;
+ *)
+ echo "Usage: seafile {start|stop|restart}"
+ exit 1
+ ;;
+esac
+ENDOFILE
+
+chmod +x ~/bin/seafile
+
+
+# -------------------------------------------
+# Go to ${HOME}/seafile/seafile-server-${SEAFILE_VERSION}
+# -------------------------------------------
+cd ${HOME}/seafile/seafile-server-${SEAFILE_VERSION}/
+
+
+# -------------------------------------------
+# Vars - Don't touch these unless you really know what you are doing!
+# -------------------------------------------
+INSTALLPATH=${HOME}/seafile/seafile-server-${SEAFILE_VERSION}
+TOPDIR=$(dirname "${INSTALLPATH}")
+SRC_DOCS_DIR=${INSTALLPATH}/seafile/docs/
+SEAHUB_SECRET_KEYGEN=${INSTALLPATH}/seahub/tools/secret_key_generator.py
+DEFAULT_CCNET_CONF_DIR=${TOPDIR}/ccnet
+DEFAULT_SEAFILE_DATA_DIR=${TOPDIR}/seafile-data
+DEFAULT_SEAHUB_DB=${TOPDIR}/seahub.db
+DEFAULT_CONF_DIR=${TOPDIR}/conf
+SEAFILE_DATA_DIR=${TOPDIR}/seafile-data
+LIBRARY_TEMPLATE_DIR=${SEAFILE_DATA_DIR}/library-template
+DEST_SETTINGS_PY=${TOPDIR}/seahub_settings.py
+CCNET_INIT=${INSTALLPATH}/seafile/bin/ccnet-init
+SEAF_SERVER_INIT=${INSTALLPATH}/seafile/bin/seaf-server-init
+MEDIA_DIR=${INSTALLPATH}/seahub/media
+ORIG_AVATAR_DIR=${INSTALLPATH}/seahub/media/avatars
+DEST_AVATAR_DIR=${TOPDIR}/seahub-data/avatars
+SEAFILE_SERVER_SYMLINK=${TOPDIR}/seafile-server-latest
+
+
+# -------------------------------------------
+# Create ccnet conf
+# -------------------------------------------
+export SEAFILE_LD_LIBRARY_PATH=${INSTALLPATH}/seafile/lib/:${INSTALLPATH}/seafile/lib64:${LD_LIBRARY_PATH}
+LD_LIBRARY_PATH=$SEAFILE_LD_LIBRARY_PATH "${CCNET_INIT}" -c "${DEFAULT_CCNET_CONF_DIR}" \
+ --name "${SERVER_NAME}" --port "${SERVER_PORT}" --host "${HOSTNAME}"
+
+# Fix service url
+eval "sed -i 's/^SERVICE_URL.*/SERVICE_URL = https:\/\/${WHOAMI}.${HOSTNAME}/' ${DEFAULT_CCNET_CONF_DIR}/ccnet.conf"
+
+
+# -------------------------------------------
+# Create seafile conf
+# -------------------------------------------
+LD_LIBRARY_PATH=$SEAFILE_LD_LIBRARY_PATH ${SEAF_SERVER_INIT} --seafile-dir "${SEAFILE_DATA_DIR}" \
+ --port ${SEAFILE_SERVER_PORT} --fileserver-port ${FILESERVER_PORT}
+
+
+# -------------------------------------------
+# Write seafile.ini
+# -------------------------------------------
+echo "${SEAFILE_DATA_DIR}" > "${DEFAULT_CCNET_CONF_DIR}/seafile.ini"
+
+
+# -------------------------------------------
+# Configure Seafile WebDAV Server(SeafDAV)
+# -------------------------------------------
+mkdir -p ${DEFAULT_CONF_DIR}
+cat > ${DEFAULT_CONF_DIR}/seafdav.conf < "${DEST_SETTINGS_PY}"
+
+
+# -------------------------------------------
+# prepare avatar directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/seahub-data"
+mv "${ORIG_AVATAR_DIR}" "${DEST_AVATAR_DIR}"
+ln -s ../../../seahub-data/avatars ${MEDIA_DIR}
+
+
+# -------------------------------------------
+# create logs directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/logs"
+
+
+# -------------------------------------------
+# Create symlink for current server version
+# -------------------------------------------
+ln -s $(basename ${INSTALLPATH}) ${SEAFILE_SERVER_SYMLINK}
+
+
+# Fix permissions
+chmod 0600 "$DEST_SETTINGS_PY"
+chmod 0700 "$DEFAULT_CCNET_CONF_DIR"
+chmod 0700 "$SEAFILE_DATA_DIR"
+chmod 0700 "$DEFAULT_CONF_DIR"
+
+
+# -------------------------------------------
+# copy user manuals to library template
+# -------------------------------------------
+mkdir -p ${LIBRARY_TEMPLATE_DIR}
+cp -f ${SRC_DOCS_DIR}/*.doc ${LIBRARY_TEMPLATE_DIR}
+
+
+# -------------------------------------------
+# Configuring ccnet.conf
+# -------------------------------------------
+SEAFILESQLPW=$(grep password $HOME/.my.cnf | awk -F'=' {'print $2'} | awk -F' ' {'print $1'})
+
+cat >> ${DEFAULT_CCNET_CONF_DIR}/ccnet.conf <> ${DEST_SETTINGS_PY} </dev/null | base64 -w 0 | rev | cut -b 2- | rev)
+eval "sed -i 's/= ask_admin_email()/= \"${SEAFILE_ADMIN}\"/' ${INSTALLPATH}/check_init_admin.py"
+eval "sed -i 's/= ask_admin_password()/= \"${SEAFILE_ADMIN_PW}\"/' ${INSTALLPATH}/check_init_admin.py"
+
+
+# -------------------------------------------
+# Start and stop Seafile eco system. This generates the initial admin user.
+# -------------------------------------------
+${TOPDIR}/seafile-server-${SEAFILE_VERSION}/seafile.sh start
+${TOPDIR}/seafile-server-${SEAFILE_VERSION}/seahub.sh start ${SEAHUB_PORT}
+${TOPDIR}/seafile-server-${SEAFILE_VERSION}/seahub.sh stop
+
+
+# -------------------------------------------
+# Restore original check_init_admin.py
+# -------------------------------------------
+mv ${INSTALLPATH}/check_init_admin.py.backup ${INSTALLPATH}/check_init_admin.py
+
+
+# -------------------------------------------
+# Final report
+# -------------------------------------------
+cat > ~/seafile/seafile-ce_uberspace.log <
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+#
+#set -x
+# Vars
+SILENCER='> /dev/null 2>&1'
+
+# -------------------------------------------
+# Seafile Server Community Edition on Uberspace
+# -------------------------------------------
+clear
+cat <
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+#
+#set -x
+# -------------------------------------------
+# Vars
+# -------------------------------------------
+SEAFILE_ADMIN=admin@seafile.lan
+SEAFILE_USER=seafile
+SEAFILE_SERVER_NAME=$(hostname -s | cut -c -16)
+SEAFILE_DNS=$(hostname -i)
+HOSTNAME=$(hostname -i)
+FILESERVER_PORT=8082
+SERVER_PORT=10001
+SEAFILE_SERVER_PORT=12001
+# Don't touch the following variable, unless you know what you are doing
+SEAFILE_VERSION=4.1.2
+SEAFILE_EDITION=pro-server
+SEAFILE_SOURCE=/usr/src/seafile/seafile-${SEAFILE_EDITION}_${SEAFILE_VERSION}_x86-64.tar.gz
+
+
+# -------------------------------------------
+# Seafile Server Professional Edition on Debian Jessie (64bit)
+# -------------------------------------------
+clear
+cat < /dev/null 2>&1 ;
+then
+ echo " Aborting because user ${SEAFILE_USER} already exist" ; exit 1
+fi
+
+
+# -------------------------------------------
+# Abort if directory /opt/seafile/ exists
+# -------------------------------------------
+if [[ -d "/opt/seafile/" ]] ;
+then
+ echo " Aborting because directory /opt/seafile/ already exist" ; exit 1
+fi
+
+
+# -------------------------------------------
+# Update System
+# -------------------------------------------
+apt-get update
+apt-get dist-upgrade -y
+
+
+# -------------------------------------------
+# Additional requirements
+# -------------------------------------------
+apt-get install sudo ntp htop pwgen curl openssl unattended-upgrades -y
+
+
+# -------------------------------------------
+# ensure correct time is set
+# -------------------------------------------
+ntpd -gq
+
+
+# -------------------------------------------
+# Security programs
+# -------------------------------------------
+apt-get install ufw fail2ban -y
+
+
+# -------------------------------------------
+# Activate firewall
+# -------------------------------------------
+for i in ssh http https ; do ufw allow $i; done
+yes | ufw enable
+
+
+# -------------------------------------------
+# Seafile requirements
+# -------------------------------------------
+apt-get install python-setuptools python-simplejson python-imaging python-mysqldb \
+openjdk-7-jre memcached python-memcache libreoffice python-uno poppler-utils -y
+
+
+# -------------------------------------------
+# NGINX
+# -------------------------------------------
+cat > /etc/apt/sources.list.d/nginx.list < /etc/nginx/conf.d/seafile.conf <<'EOF'
+server {
+ listen 80;
+ server_name "";
+ return 301 https://$http_host$request_uri?;
+}
+
+server {
+ listen 443 spdy;
+ server_name "";
+
+ ssl on;
+ ssl_certificate /etc/nginx/ssl/seafile.crt;
+ ssl_certificate_key /etc/nginx/ssl/seafile.key;
+
+ location / {
+ fastcgi_pass 127.0.0.1:8000;
+ 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;
+ fastcgi_param HTTP_SCHEME https;
+
+ access_log /var/log/nginx/seahub.access.log;
+ error_log /var/log/nginx/seahub.error.log;
+ }
+ location /seafhttp {
+ rewrite ^/seafhttp(.*)$ $1 break;
+ proxy_pass http://127.0.0.1:8082;
+ client_max_body_size 0;
+ proxy_connect_timeout 36000s;
+ proxy_read_timeout 36000s;
+ }
+ location /media {
+ root /opt/seafile/seafile-server-latest/seahub;
+ }
+ location /seafdav {
+ fastcgi_pass 127.0.0.1:8080;
+ 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;
+ }
+ }
+EOF
+
+mkdir /etc/nginx/ssl
+
+openssl genrsa -out /etc/nginx/ssl/seafile.key 4096
+openssl req -new -x509 -key /etc/nginx/ssl/seafile.key -out /etc/nginx/ssl/seafile.crt -days 10950 -batch
+
+
+# -------------------------------------------
+# Create optimized nginx.conf
+# -------------------------------------------
+cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
+
+cat > /etc/nginx/nginx.conf <<'ENDOFFILE'
+user nginx nginx;
+worker_processes 4;
+events {
+ worker_connections 8096;
+ multi_accept on;
+ use epoll;
+}
+pid /var/run/nginx.pid;
+worker_rlimit_nofile 40000;
+http {
+ server_tokens off;
+ server_names_hash_bucket_size 128;
+ client_max_body_size 50M;
+ include /etc/nginx/mime.types;
+ default_type application/octet-stream;
+ log_format main '$remote_addr - $remote_user [$time_local] "$request" '
+ '$status $body_bytes_sent "$http_referer" '
+ '"$http_user_agent" "$http_x_forwarded_for"';
+ access_log /var/log/nginx/access.log main;
+ error_log /var/log/nginx/error.log warn;
+ sendfile on;
+ tcp_nopush on;
+ tcp_nodelay on;
+ client_body_timeout 12;
+ client_header_timeout 12;
+ keepalive_timeout 15;
+ send_timeout 10;
+ gzip on;
+ gzip_vary on;
+ gzip_proxied expired no-cache no-store private auth any;
+ gzip_comp_level 9;
+ gzip_min_length 10240;
+ gzip_buffers 16 8k;
+ gzip_http_version 1.1;
+ gzip_types text/plain text/css text/xml text/javascript application/javascript application/x-javascript application/xml font/woff2;
+ gzip_disable "MSIE [1-6].";
+ include /etc/nginx/conf.d/*.conf;
+ include /etc/nginx/sites-enabled/*;
+ map $scheme $php_https { default off; https on; }
+ include perfect-forward-secrecy.conf;
+}
+ENDOFFILE
+
+
+# -------------------------------------------
+# Setup perfect forward secrecy
+# -------------------------------------------
+openssl dhparam -dsaparam -out /etc/nginx/dh4096.pem 4096
+
+cat > /etc/nginx/perfect-forward-secrecy.conf <<'EOF'
+ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
+ssl_prefer_server_ciphers on;
+ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA";
+ssl_dhparam dh4096.pem;
+ssl_session_cache shared:SSL:10m;
+ssl_session_timeout 10m;
+EOF
+
+
+# -------------------------------------------
+# Fix NGINX worker_processes to number of CPU cores
+# -------------------------------------------
+CPUS=$(cat /proc/cpuinfo | grep processor | wc | awk '{ print $1 }')
+eval "sed -i 's/worker_processes.*/worker_processes $CPUS;/g' /etc/nginx/nginx.conf"
+
+
+systemctl restart nginx
+
+
+# -------------------------------------------
+# MariaDB
+# -------------------------------------------
+DEBIAN_FRONTEND=noninteractive apt-get install mariadb-server -y
+
+SQLROOTPW=$(pwgen)
+
+mysqladmin -u root password $SQLROOTPW
+
+cat > /root/.my.cnf < /etc/init.d/seafile-server <<'EOF'
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: seafile-server
+# Required-Start: $remote_fs $syslog mysql
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Seafile server
+# Description: Start Seafile server
+### END INIT INFO
+
+# Author: Alexander Jackson
+#
+
+# Change the value of "user" to your linux user name
+USER=seafile
+
+# Change the value of "SEAFILE_DIR" to your path of seafile installation
+SEAFILE_DIR=/opt/seafile
+SCRIPT_PATH=${SEAFILE_DIR}/seafile-server-latest
+SEAFILE_INIT_LOG=${SEAFILE_DIR}/logs/seafile.init.log
+SEAHUB_INIT_LOG=${SEAFILE_DIR}/logs/seahub.init.log
+
+# Change the value of fastcgi to true if fastcgi is to be used
+fastcgi=true
+# Set the port of fastcgi, default is 8000. Change it if you need different.
+fastcgi_port=8000
+
+case "$1" in
+ start)
+ sudo -u ${USER} ${SCRIPT_PATH}/seafile.sh start >> ${SEAFILE_INIT_LOG}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${USER} ${SCRIPT_PATH}/seahub.sh start-fastcgi ${fastcgi_port} >> ${SEAHUB_INIT_LOG}
+ else
+ sudo -u ${USER} ${SCRIPT_PATH}/seahub.sh start >> ${SEAHUB_INIT_LOG}
+ fi
+ ;;
+ restart)
+ sudo -u ${USER} ${SCRIPT_PATH}/seafile.sh restart >> ${SEAFILE_INIT_LOG}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${USER} ${SCRIPT_PATH}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${SEAHUB_INIT_LOG}
+ else
+ sudo -u ${USER} ${SCRIPT_PATH}/seahub.sh restart >> ${SEAHUB_INIT_LOG}
+ fi
+ ;;
+ stop)
+ sudo -u ${USER} ${SCRIPT_PATH}/seafile.sh $1 >> ${SEAFILE_INIT_LOG}
+ sudo -u ${USER} ${SCRIPT_PATH}/seahub.sh $1 >> ${SEAHUB_INIT_LOG}
+ ;;
+ *)
+ echo "Usage: /etc/init.d/seafile-server {start|stop|restart}"
+ exit 1
+ ;;
+esac
+EOF
+
+chmod +x /etc/init.d/seafile-server
+systemctl enable seafile-server
+
+
+# -------------------------------------------
+# Install seafile-server-change-address script
+# -------------------------------------------
+cat > /usr/local/sbin/seafile-server-change-address <<'ENDOFFILE'
+#/bin/bash
+#set -x
+# -------------------------------------------
+# Vars
+# -------------------------------------------
+HOSTNAME=$(hostname -f)
+SEAFILE_DIR=/opt/seafile
+
+
+# -------------------------------------------
+# Intro
+# -------------------------------------------
+clear
+cat < /opt/seafile/.my.cnf < "${DEFAULT_CCNET_CONF_DIR}/seafile.ini"
+
+
+# -------------------------------------------
+# Configure Seafile WebDAV Server(SeafDAV)
+# -------------------------------------------
+mkdir -p ${DEFAULT_CONF_DIR}
+cat > ${DEFAULT_CONF_DIR}/seafdav.conf < "${DEST_SETTINGS_PY}"
+
+
+# -------------------------------------------
+# prepare avatar directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/seahub-data"
+mv "${ORIG_AVATAR_DIR}" "${DEST_AVATAR_DIR}"
+ln -s ../../../seahub-data/avatars ${MEDIA_DIR}
+
+
+# -------------------------------------------
+# create logs directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/logs"
+
+
+# -------------------------------------------
+# Create symlink for current server version
+# -------------------------------------------
+ln -s $(basename ${INSTALLPATH}) ${SEAFILE_SERVER_SYMLINK}
+
+
+# Fix permissions
+chmod 0600 "$DEST_SETTINGS_PY"
+chmod 0700 "$DEFAULT_CCNET_CONF_DIR"
+chmod 0700 "$SEAFILE_DATA_DIR"
+chmod 0700 "$DEFAULT_CONF_DIR"
+
+
+# -------------------------------------------
+# copy user manuals to library template
+# -------------------------------------------
+mkdir -p ${LIBRARY_TEMPLATE_DIR}
+cp -f ${SRC_DOCS_DIR}/*.doc ${LIBRARY_TEMPLATE_DIR}
+
+
+# -------------------------------------------
+# Setup professional features
+# -------------------------------------------
+PRO_PY=${INSTALLPATH}/pro/pro.py
+$PYTHON ${PRO_PY} setup
+
+
+# -------------------------------------------
+# Configuring ccnet.conf
+# -------------------------------------------
+SEAFILESQLPW=$(grep password /opt/seafile/.my.cnf | awk -F'=' {'print $2'})
+
+cat >> ${DEFAULT_CCNET_CONF_DIR}/ccnet.conf <> ${DEST_SETTINGS_PY} < ${SEAFILE_DIR}/seafile-pro-installer.log<
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+#
+#set -x
+# -------------------------------------------
+# Vars
+# -------------------------------------------
+SEAFILE_ADMIN=admin@seafile.local
+SEAFILE_USER=seafile
+SERVER_NAME=$(hostname -s)
+IP_OR_DOMAIN=$(hostname -i)
+HOSTNAME=$(hostname -i)
+FILESERVER_PORT=8082
+SERVER_PORT=10001
+SEAFILE_SERVER_PORT=12001
+
+
+# -------------------------------------------
+# Seafile Server Community Edition on Ubuntu Trusty (64bit)
+# -------------------------------------------
+clear
+cat < /dev/null 2>&1 ;
+then
+ echo " Aborting because user ${SEAFILE_USER} already exist" ; exit 1
+fi
+
+
+# -------------------------------------------
+# Abort if directory /opt/seafile/ exists
+# -------------------------------------------
+if [[ -d "/opt/seafile/" ]] ;
+then
+ echo " Aborting because directory /opt/seafile/ already exist" ; exit 1
+fi
+
+
+# -------------------------------------------
+# Update System
+# -------------------------------------------
+aptitude update && aptitude dist-upgrade -y
+
+
+# -------------------------------------------
+# Ensure aptitude is installed
+# -------------------------------------------
+apt-get install aptitude -y
+
+# -------------------------------------------
+# Additional requirements
+# -------------------------------------------
+aptitude install sudo python-setuptools python-simplejson python-imaging python-mysqldb \
+openjdk-7-jre memcached python-memcache pwgen curl openssl -y
+
+
+# -------------------------------------------
+# NGINX
+# -------------------------------------------
+cat > /etc/apt/sources.list.d/nginx.list < /etc/nginx/conf.d/seafile.conf <<'EOF'
+server {
+ listen 80;
+ server_name "";
+ return 301 https://$http_host$request_uri?;
+}
+
+server {
+ listen 443 spdy;
+ server_name "";
+
+ ssl on;
+ ssl_certificate /etc/nginx/ssl/seafile.crt;
+ ssl_certificate_key /etc/nginx/ssl/seafile.key;
+
+ location / {
+ fastcgi_pass 127.0.0.1:8000;
+ 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;
+ fastcgi_param HTTP_SCHEME https;
+
+ access_log /var/log/nginx/seahub.access.log;
+ error_log /var/log/nginx/seahub.error.log;
+ }
+ location /seafhttp {
+ rewrite ^/seafhttp(.*)$ $1 break;
+ proxy_pass http://127.0.0.1:8082;
+ client_max_body_size 0;
+ proxy_connect_timeout 36000s;
+ proxy_read_timeout 36000s;
+ }
+ location /media {
+ root /opt/seafile/seafile-server-latest/seahub;
+ }
+ location /seafdav {
+ fastcgi_pass 127.0.0.1:8080;
+ 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;
+ }
+ }
+EOF
+
+mkdir /etc/nginx/ssl
+
+openssl genrsa -out /etc/nginx/ssl/seafile.key 4096
+openssl req -new -x509 -key /etc/nginx/ssl/seafile.key -out /etc/nginx/ssl/seafile.crt -days 10950 -batch
+
+service nginx restart
+
+
+# -------------------------------------------
+# MariaDB
+# -------------------------------------------
+DEBIAN_FRONTEND=noninteractive aptitude install mariadb-server -y
+
+SQLROOTPW=$(pwgen)
+
+mysqladmin -u root password $SQLROOTPW
+
+cat > /root/.my.cnf < /etc/init.d/seafile-server <<'EOF'
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: seafile-server
+# Required-Start: $remote_fs $syslog mysql
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Seafile server
+# Description: Start Seafile server
+### END INIT INFO
+
+# Author: Alexander Jackson
+#
+
+# Change the value of "user" to your linux user name
+user=seafile
+
+# Change the value of "seafile_dir" to your path of seafile installation
+seafile_dir=/opt/seafile
+script_path=${seafile_dir}/seafile-server-latest
+seafile_init_log=${seafile_dir}/logs/seafile.init.log
+seahub_init_log=${seafile_dir}/logs/seahub.init.log
+
+# Change the value of fastcgi to true if fastcgi is to be used
+fastcgi=true
+# Set the port of fastcgi, default is 8000. Change it if you need different.
+fastcgi_port=8000
+
+case "$1" in
+ start)
+ sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${user} ${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log}
+ else
+ sudo -u ${user} ${script_path}/seahub.sh start >> ${seahub_init_log}
+ fi
+ ;;
+ restart)
+ sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log}
+ if [ $fastcgi = true ];
+ then
+ sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${seahub_init_log}
+ else
+ sudo -u ${user} ${script_path}/seahub.sh restart >> ${seahub_init_log}
+ fi
+ ;;
+ stop)
+ sudo -u ${user} ${script_path}/seafile.sh $1 >> ${seafile_init_log}
+ sudo -u ${user} ${script_path}/seahub.sh $1 >> ${seahub_init_log}
+ ;;
+ *)
+ echo "Usage: /etc/init.d/seafile-server {start|stop|restart}"
+ exit 1
+ ;;
+esac
+EOF
+
+chmod +x /etc/init.d/seafile-server
+update-rc.d seafile-server defaults
+
+
+# -------------------------------------------
+# Seafile
+# -------------------------------------------
+adduser --system --gecos "${SEAFILE_USER}" ${SEAFILE_USER} --home /opt/seafile
+mkdir -p /opt/seafile/installed
+cd /opt/seafile/
+curl -OL https://download.seafile.com.de/seafile-server_latest_x86-64.tar.gz
+tar xzf seafile-server_latest_x86-64.tar.gz
+
+SEAFILE_VERSION=$(basename /opt/seafile/seafile-server-* | awk -F'-' ' { print $3 }')
+
+mv seafile-server_latest_x86-64.tar.gz installed/seafile-server_${SEAFILE_VERSION}_x86-64.tar.gz
+
+
+# -------------------------------------------
+# Seafile DB
+# -------------------------------------------
+SQLSEAFILEPW=$(pwgen)
+
+cat > /opt/seafile/.my.cnf < "${DEFAULT_CCNET_CONF_DIR}/seafile.ini"
+
+
+# -------------------------------------------
+# Configure Seafile WebDAV Server(SeafDAV)
+# -------------------------------------------
+mkdir -p ${DEFAULT_CONF_DIR}
+cat > ${DEFAULT_CONF_DIR}/seafdav.conf < "${DEST_SETTINGS_PY}"
+
+
+# -------------------------------------------
+# prepare avatar directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/seahub-data"
+mv "${ORIG_AVATAR_DIR}" "${DEST_AVATAR_DIR}"
+ln -s ../../../seahub-data/avatars ${MEDIA_DIR}
+
+
+# -------------------------------------------
+# create logs directory
+# -------------------------------------------
+mkdir -p "${TOPDIR}/logs"
+
+
+# -------------------------------------------
+# Create symlink for current server version
+# -------------------------------------------
+ln -s $(basename ${INSTALLPATH}) ${SEAFILE_SERVER_SYMLINK}
+
+
+# Fix permissions
+chmod 0600 "$DEST_SETTINGS_PY"
+chmod 0700 "$DEFAULT_CCNET_CONF_DIR"
+chmod 0700 "$SEAFILE_DATA_DIR"
+chmod 0700 "$DEFAULT_CONF_DIR"
+
+
+# -------------------------------------------
+# copy user manuals to library template
+# -------------------------------------------
+mkdir -p ${LIBRARY_TEMPLATE_DIR}
+cp -f ${SRC_DOCS_DIR}/*.doc ${LIBRARY_TEMPLATE_DIR}
+
+
+# -------------------------------------------
+# Configuring ccnet.conf
+# -------------------------------------------
+SEAFILESQLPW=$(grep password /opt/seafile/.my.cnf | awk -F'=' {'print $2'})
+
+cat >> ${DEFAULT_CCNET_CONF_DIR}/ccnet.conf <> ${DEST_SETTINGS_PY} < ${seafile_dir}/aio_seafile-server.log<
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+#
+#set -x
+# -------------------------------------------
+# Vars
+# -------------------------------------------
+CLASS_DEFAULT=1
+RSA=4096
+
+
+# -------------------------------------------
+# About
+# -------------------------------------------
+cat << EOF
+
+ StartSSL certificate creator for NGINX
+
+ Go to https://www.startssl.com and sign up. Decide
+ if the free class1 certs are good enough or if you
+ need paid class2 or class3 certificates. Class1
+ certificates are the default after signing up. You
+ don't need to do anything else to issue class1 certs.
+
+ For questions or suggestions please contact me at
+ alexander.jackson@seafile.de
+
+ -----------------------------------------------------------------
+ Hit return to proceed or CTRL-C to abort.
+
+EOF
+
+read dummy
+
+
+# -------------------------------------------
+# Start working
+# -------------------------------------------
+read -p "New certs class? [$CLASS_DEFAULT]" CLASS
+CLASS="${CLASS:-$CLASS_DEFAULT}"
+
+if [[ $CLASS > 3 ]]; then
+ echo Wrong class type. Select 1, 2 or 3. Aborting.. ; exit 1
+fi
+
+read -p "New certs domain name? " DOMAIN
+
+CERT_DIR=$(pwd)/certs/${DOMAIN}
+
+
+# -------------------------------------------
+# Abort if CERT_DIR exists
+# -------------------------------------------
+if [[ -d "${CERT_DIR}" ]] ;
+then
+ echo " Aborting because directory ${CERT_DIR} already exist" ; exit 1
+fi
+
+mkdir -p ${CERT_DIR}
+
+
+# -------------------------------------------
+# Create certificate signing request and private key in batch mode
+# -------------------------------------------
+openssl req -new -nodes -keyout ${CERT_DIR}/${DOMAIN}.key -out ${CERT_DIR}/${DOMAIN}.csr -newkey rsa:${RSA} -batch
+
+
+# -------------------------------------------
+# Print instructions
+# -------------------------------------------
+cat << EOF
+
+ Follow these steps next:
+
+ 1. Go to https://www.startssl.com >
+ 2. Certificates Wizard >
+ 3. Certificate Target: (Web Server SSL/TLS Certificate) > Continue >
+ 4. Generate Private Key > Skip >
+ 5. Submit Certificate Request (CSR) (Paste your csr shown below)
+
+EOF
+
+cat ${CERT_DIR}/${DOMAIN}.csr
+
+
+
+# -------------------------------------------
+# Print more instructions
+# -------------------------------------------
+cat << EOF
+
+ 6. Continue >>
+ 7. Certificate Request Received > Continue >>
+ 8. Add Domains: (select your domain)
+ 9. Optionally Add Domains > Add More < (repeat until happy) > Continue >>
+ 10. Ready Processing Certificate > Continue >>
+
+EOF
+
+echo "Hit return when the certificate is displayed."
+read dummy
+
+echo "Replace content with certificate, save and exit." > ${CERT_DIR}/${DOMAIN}.crt
+
+nano ${CERT_DIR}/${DOMAIN}.crt
+
+echo "Creating class ${CLASS} chained certificate for NGINX"
+
+
+# -------------------------------------------
+# Create certificate change for usage with NGINX
+# -------------------------------------------
+cat ${CERT_DIR}/${DOMAIN}.crt > ${CERT_DIR}/${DOMAIN}_chained.crt
+
+if [[ $CLASS -eq 1 ]]; then
+ wget -O - https://www.startssl.com/certs/class1/sha2/pem/sub.class1.server.sha2.ca.pem >> ${CERT_DIR}/${DOMAIN}_chained.crt
+fi
+
+if [[ $CLASS -eq 2 ]]; then
+ wget -O - https://www.startssl.com/certs/class2/sha2/pem/sub.class2.server.sha2.ca.pem >> ${CERT_DIR}/${DOMAIN}_chained.crt
+fi
+
+if [[ $CLASS -eq 3 ]]; then
+ wget -O - https://www.startssl.com/certs/class3/sha2/pem/sub.class3.server.sha2.ca.pem >> ${CERT_DIR}/${DOMAIN}_chained.crt
+fi
+
+wget -O - https://www.startssl.com/certs/ca-sha2.pem >> ${CERT_DIR}/${DOMAIN}_chained.crt
+
+
+# -------------------------------------------
+# List new csr and key for informational value
+# -------------------------------------------
+echo "Our newly Created files:"
+ls -ahl ${CERT_DIR}
+
+
+# -------------------------------------------
+# Print
+# -------------------------------------------
+cat << EOF
+
+ Implementation example for NGINX:
+
+ [...]
+ ssl on;
+ ssl_certificate ${CERT_DIR}/${DOMAIN}_chained.crt;
+ ssl_certificate_key ${CERT_DIR}/${DOMAIN}.key;
+ [...]
+
+ Finished!
+
+EOF