From cdcee17360a1e74a6117ad647b80f449517bda9f Mon Sep 17 00:00:00 2001 From: skywalker Date: Thu, 19 Nov 2020 16:48:35 +0800 Subject: [PATCH] seafile-server-8.0-ubuntu-amd64-http --- seafile-server-8.0-ubuntu-amd64-http | 536 +++++++++++++++++++++++++++ 1 file changed, 536 insertions(+) create mode 100644 seafile-server-8.0-ubuntu-amd64-http diff --git a/seafile-server-8.0-ubuntu-amd64-http b/seafile-server-8.0-ubuntu-amd64-http new file mode 100644 index 0000000..31dc024 --- /dev/null +++ b/seafile-server-8.0-ubuntu-amd64-http @@ -0,0 +1,536 @@ +#!/bin/bash +# +# seafile-server-installer/seafile-server-ubuntu-16-04-amd64 +# +# Copyright 2015, Alexander Jackson +# Copyright 2016, Zheng Xie +# +# 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 . +# +# + +if [[ $HOME == "" ]]; then + export HOME=/root +fi + +if [[ $SEAFILE_DEBUG != "" ]]; then + set -x +fi +set -e + +if [[ "$#" -ne 1 ]]; then + echo "You must specif Seafile version to install" + echo "Like: $0 8.0.0" + exit 1 +fi + +clear +cat < /etc/nginx/sites-available/seafile.conf << EOF +log_format seafileformat '\$http_x_forwarded_for \$remote_addr [\$time_local] "\$request" \$status \$body_bytes_sent "\$http_referer" "\$http_user_agent" \$upstream_response_time'; + +server { + listen 80; + server_name seafile.example.com; + + proxy_set_header X-Forwarded-For \$remote_addr; + + location / { + proxy_pass http://127.0.0.1:8000; + proxy_set_header Host \$host; + proxy_set_header X-Real-IP \$remote_addr; + proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host \$server_name; + proxy_set_header X-Forwarded-Proto \$scheme; + proxy_read_timeout 1200s; + + # used for view/edit office file via Office Online Server + client_max_body_size 0; + + access_log /var/log/nginx/seahub.access.log seafileformat; + 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_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; + proxy_connect_timeout 36000s; + proxy_read_timeout 36000s; + + access_log /var/log/nginx/seafhttp.access.log seafileformat; + error_log /var/log/nginx/seafhttp.error.log; + } + location /media { + root ${SEAFILE_SERVER_HOME}/seafile-server-latest/seahub; + } + location /seafdav { + proxy_pass http://127.0.0.1:8080/seafdav; + proxy_set_header Host \$host; + proxy_set_header X-Real-IP \$remote_addr; + proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host \$server_name; + proxy_set_header X-Forwarded-Proto \$scheme; + proxy_read_timeout 1200s; + + client_max_body_size 0; + + access_log /var/log/nginx/seafdav.access.log seafileformat; + error_log /var/log/nginx/seafdav.error.log; + } +} +EOF + +ln -sf /etc/nginx/sites-available/seafile.conf /etc/nginx/sites-enabled/seafile.conf + +service nginx restart + + +# ------------------------------------------- +# MariaDB +# ------------------------------------------- +if [[ -f "/root/.my.cnf" ]] ; +then + echo "MariaDB installed before, skip this part" + SQLROOTPW=`sed -n 's/password=//p' /root/.my.cnf` +else + DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server + service mysql start + + 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 "seafile_dir" to your path of seafile installation +user=${SEAFILE_SERVER_USER} +seafile_dir=${SEAFILE_SERVER_HOME} +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 + + +case "\$1" in + start) + sudo -u \${user} \${script_path}/seafile.sh start >> \${seafile_init_log} + sudo -u \${user} \${script_path}/seahub.sh start >> \${seahub_init_log} + ;; + restart) + sudo -u \${user} \${script_path}/seafile.sh restart >> \${seafile_init_log} + sudo -u \${user} \${script_path}/seahub.sh restart >> \${seahub_init_log} + ;; + 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 +# ------------------------------------------- +mkdir -p ${SEAFILE_SERVER_HOME}/installed +cd ${SEAFILE_SERVER_HOME} +if ! is_pro && [[ ! -e /opt/${SEAFILE_SERVER_PACKAGE} ]]; then + curl -OL ${SEAFILE_SERVER_PACKAGE_URL} +else + cp /opt/${SEAFILE_SERVER_PACKAGE} . +fi +tar xzf ${SEAFILE_SERVER_PACKAGE} + +mv ${SEAFILE_SERVER_PACKAGE} installed + + +# ------------------------------------------- +# Seafile DB +# ------------------------------------------- +if [[ -f "/opt/seafile.my.cnf" ]] ; +then + echo "MariaDB installed before, skip this part" + SQLSEAFILEPW=`sed -n 's/password=//p' /opt/seafile.my.cnf` +else + SQLSEAFILEPW=$(pwgen) + + cat > /opt/seafile.my.cnf <> ${DEST_SETTINGS_PY} < ${TOPDIR}/aio_seafile-server.log<