mirror of
https://github.com/haiwen/seafile-server-installer-cn.git
synced 2025-12-26 01:22:52 +00:00
Compare commits
157 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec8775bae1 | ||
|
|
d742554a31 | ||
|
|
8eb1b22aeb | ||
|
|
aea4c53fe4 | ||
|
|
192410e065 | ||
|
|
091dafef4a | ||
|
|
459837caa9 | ||
|
|
48b9c7685b | ||
|
|
68f84f53cc | ||
|
|
0723c19f61 | ||
|
|
9f8e36afec | ||
|
|
7d43a9ee3b | ||
|
|
beca5368cb | ||
|
|
7f1b557911 | ||
|
|
e45257c7c1 | ||
|
|
8cd221d0ce | ||
|
|
9a0eb564c5 | ||
|
|
185f2d13ac | ||
|
|
b45b411311 | ||
|
|
8f8dc44a4d | ||
|
|
57990f8561 | ||
|
|
2777664be3 | ||
|
|
669f989b2b | ||
|
|
ec9eaf1542 | ||
|
|
0b6d0f93d4 | ||
|
|
fa1e2c7922 | ||
|
|
582235733f | ||
|
|
aac69d4ba1 | ||
|
|
ccacbded6e | ||
|
|
c2ce8b685f | ||
|
|
97cbea2a41 | ||
|
|
67bae644ca | ||
|
|
36703b142a | ||
|
|
c01f7c2cf8 | ||
|
|
9fd00e5a0f | ||
|
|
eef6314471 | ||
|
|
d28068f662 | ||
|
|
65e2ed4ab1 | ||
|
|
f1259f1a1a | ||
|
|
cc52eef96f | ||
|
|
75c7b2d15f | ||
|
|
8298cb1239 | ||
|
|
aa2f62fd2f | ||
|
|
ac3bea4035 | ||
|
|
33b7e50be6 | ||
|
|
756aebc62a | ||
|
|
cc0b624944 | ||
|
|
ad00df1edb | ||
|
|
1cef223041 | ||
|
|
4cfd2be422 | ||
|
|
d6f116a99b | ||
|
|
e45aed5eea | ||
|
|
c6a92ee696 | ||
|
|
7be1e5dcb4 | ||
|
|
7385be14fb | ||
|
|
9cde46455b | ||
|
|
727098d07d | ||
|
|
d14454c39e | ||
|
|
cdcee17360 | ||
|
|
c385537ff4 | ||
|
|
28786f86ac | ||
|
|
f2e3156c32 | ||
|
|
e14b10fa4b | ||
|
|
1d1bd19fd6 | ||
|
|
5d2738abc1 | ||
|
|
f30d6f27bb | ||
|
|
ae6d8f8a90 | ||
|
|
d550a45734 | ||
|
|
ac38e2e254 | ||
|
|
12af02bb77 | ||
|
|
d84a6d6705 | ||
|
|
638d20e983 | ||
|
|
452b407257 | ||
|
|
c0319b8828 | ||
|
|
a71c92f648 | ||
|
|
d725c5277c | ||
|
|
8cb37a0dab | ||
|
|
a48cf01871 | ||
|
|
ed238db4d0 | ||
|
|
bfa7f39fe1 | ||
|
|
c0b57e5409 | ||
|
|
a592f51132 | ||
|
|
a5bf55d221 | ||
|
|
a5dbb80f58 | ||
|
|
c233b1c3fc | ||
|
|
11830e8bba | ||
|
|
3ab63f30e7 | ||
|
|
0b45ed2adf | ||
|
|
ed0c575530 | ||
|
|
ada95ccbef | ||
|
|
3e212eeb3e | ||
|
|
2cc49a3536 | ||
|
|
b4193fa48a | ||
|
|
592aff262d | ||
|
|
480b2d77f4 | ||
|
|
3a012a4fa6 | ||
|
|
d7561439f9 | ||
|
|
e8ef774861 | ||
|
|
df6f38cf4b | ||
|
|
219b9ec829 | ||
|
|
bc8c40b1ff | ||
|
|
48006381dd | ||
|
|
cf67bbe7e5 | ||
|
|
66f27170f3 | ||
|
|
ff85f63c8b | ||
|
|
2a594e5781 | ||
|
|
c53e332058 | ||
|
|
4e7f8ca3b7 | ||
|
|
4e8e73e614 | ||
|
|
fd9f2d88c3 | ||
|
|
e7b1d8fdf8 | ||
|
|
ecca90ba11 | ||
|
|
a3bd3abc6c | ||
|
|
b672ebaa7e | ||
|
|
1c46bc566b | ||
|
|
f2726fc541 | ||
|
|
2f8d07d238 | ||
|
|
b95d1b67d5 | ||
|
|
bbdac4875c | ||
|
|
9303aa91fb | ||
|
|
800e65c5ee | ||
|
|
4959775531 | ||
|
|
c932290909 | ||
|
|
00a982da0b | ||
|
|
e3fd8969a4 | ||
|
|
d7fae50c2b | ||
|
|
2b556eb7b7 | ||
|
|
065c50c8e9 | ||
|
|
b4498eec67 | ||
|
|
143155ddc2 | ||
|
|
76691fe637 | ||
|
|
edcb4c7edf | ||
|
|
76c7f6c1f5 | ||
|
|
0f4874b291 | ||
|
|
a36481599c | ||
|
|
88a1efeb15 | ||
|
|
be36a09f90 | ||
|
|
a356b56af0 | ||
|
|
152ef5775c | ||
|
|
7262683944 | ||
|
|
928e893b4e | ||
|
|
e7dd175b22 | ||
|
|
cbfd2635df | ||
|
|
5c1fcf4b6f | ||
|
|
b6954410d9 | ||
|
|
25fde48ba8 | ||
|
|
a96050531f | ||
|
|
ace9f05f26 | ||
|
|
6ac670b50b | ||
|
|
f4284ee6d7 | ||
|
|
f2962f5224 | ||
|
|
8f6fbd284f | ||
|
|
64e8b2230b | ||
|
|
28e98027d3 | ||
|
|
5fcd645f0a | ||
|
|
d6ac764ea5 | ||
|
|
b261284a6a |
|
|
@ -0,0 +1,3 @@
|
||||||
|
*.pyc
|
||||||
|
*~
|
||||||
|
*#
|
||||||
77
README.md
77
README.md
|
|
@ -1,72 +1,67 @@
|
||||||
# Seafile 安装脚本
|
# Seafile 安装脚本
|
||||||
|
|
||||||
这里的安装脚本可以帮助您快速的安装好 Seafile 服务器,并配置好 MariaDB, Memcached, WebDAV, Ngnix 和开机自动启动脚本。
|
> 从 2024 年开始,一键安装脚本不再维护,请使用 Docker 来安装。
|
||||||
|
|
||||||
|
一键安装脚本可以帮助您在 Ubuntu 18.04/20.04 系统上快速的安装好 Seafile 服务器,并配置好 MariaDB, Memcached, WebDAV, Ngnix 和开机自动启动脚本。
|
||||||
|
|
||||||
|
|
||||||
### 使用步骤
|
## 使用步骤
|
||||||
|
|
||||||
安装干净的 Ubuntu 14.04 系统并切换成 root 账号 (sudo -i)。
|
安装干净的 Ubuntu 18.04/20.04,并**做好镜像** (如果安装失败需要还原到镜像)。
|
||||||
|
|
||||||
获取安装脚本
|
切换成 root 账号 (`sudo -i`)
|
||||||
|
|
||||||
```
|
|
||||||
wget https://raw.githubusercontent.com/haiwen/seafile-server-installer-cn/master/seafile-server-ubuntu-14-04-amd64-http
|
### 获取安装脚本
|
||||||
|
|
||||||
|
适用于 Seafile 8.0.x 及以上版本
|
||||||
|
|
||||||
|
```sh
|
||||||
|
wget https://raw.githubusercontent.com/haiwen/seafile-server-installer-cn/master/seafile-8.0_ubuntu
|
||||||
```
|
```
|
||||||
|
|
||||||
运行安装脚本并指定要安装的版本 (5.0.2)
|
### 运行安装脚本并指定要安装的版本 (例如 8.0.0)
|
||||||
|
|
||||||
```
|
```
|
||||||
bash seafile-server-ubuntu-14-04-amd64-http 5.0.2
|
bash seafile-8.0_ubuntu 8.0.0
|
||||||
```
|
```
|
||||||
|
|
||||||
脚本会让你选择要安装的版本, 按照提示进行选择即可:
|
脚本会让您选择要安装的版本, 按照提示进行选择即可:
|
||||||
|
|
||||||
* 如果要安装专业版, 需要先将下载好的专业版的包 `seafile-pro-server_5.0.1_x86-64.tar.gz` 放到 `/opt/` 目录下
|
* 如果要安装专业版, 需要先将下载好的专业版的包 `seafile-pro-server_8.0.0_x86-64.tar.gz` 放到 `/opt/` 目录下
|
||||||
* 如果是安装开源版,安装脚本在执行过程中会检查**/opt**目录下是否有指定版本号的安装包,如果存在则会安装此包,否则会从 Seafile 网站下载。所以,为了避免因下载失败而导致安装中断,您可以提前下载好安装包放到**/opt/**目录下。
|
* 如果是安装开源版,安装脚本在执行过程中会检查 `/opt`目录下是否有指定版本号的安装包,如果存在则会安装此包,否则会从 Seafile 网站下载。所以,为了避免因下载失败而导致安装中断,您可以提前下载好安装包放到`/opt/`目录下。
|
||||||
|
|
||||||
该脚本运行完后会在命令行中打印配置信息和管理员账号密码,请仔细阅读。
|
该脚本运行完后会在命令行中打印配置信息和管理员账号密码,请仔细阅读。(您也可以查看安装日志`/opt/seafile/aio_seafile-server.log`),MySQL 的 root 用户密码存储在 `/root/.my.cnf` 中;MySQL 的 seafile 用户密码存储在 `/opt/seafile.my.cnf` 中。
|
||||||
|
|
||||||
#### 通过 Web UI 对服务器进行配置
|
|
||||||
|
### 通过 Web UI 对服务器进行配置
|
||||||
|
|
||||||
安装完成后,您需要通过 Web UI 服务器进行基本的配置,以便能正常的从网页端进行文件的上传和下载:
|
安装完成后,您需要通过 Web UI 服务器进行基本的配置,以便能正常的从网页端进行文件的上传和下载:
|
||||||
|
|
||||||
1. 首先在浏览器中输入服务器的地址,并用管理员账号和初始密码登录
|
1. 首先在浏览器中输入服务器的地址,并用管理员账号和初始密码登录
|
||||||
2. 点击界面的右上角的工具按钮进入管理员界面
|
|
||||||
|
2. 点击界面的右上角的头像按钮进入管理员界面
|
||||||

|

|
||||||
|
|
||||||
3. 进入设置页面填写正确的服务器对外的 SERVICE_URL 和 FILE_SERVER_ROOT,比如
|
3. 进入设置页面填写正确的服务器对外的 SERVICE_URL 和 FILE_SERVER_ROOT,比如
|
||||||
|
```
|
||||||
|
SERVICE_URL: http://www.example.com
|
||||||
|
FILE_SERVER_ROOT: http://www.example.com/seafhttp
|
||||||
|
```
|
||||||
|
|
||||||
|
现在您可以退出管理员界面,并进行基本的测试。关于服务器的配置选项介绍和日常运维可以参考 https://cloud.seafile.com/published/seafile-manual-cn/config/README.md
|
||||||
|
|
||||||
```
|
|
||||||
SERVICE_URL: http://www.myseafile.com
|
|
||||||
FILE_SERVER_ROOT: 'http://www.myseafile.com/seafhttp'
|
|
||||||
```
|
|
||||||
|
|
||||||
现在您可以退出管理员界面,并进行基本的测试。关于服务器的配置选项介绍和日常运维可以参考 http://manual-cn.seafile.com/config/index.html
|
|
||||||
|
|
||||||
### 如果安装脚本出错
|
### 如果安装脚本出错
|
||||||
|
|
||||||
如果安装脚本出错,您可以用下列命名来清空重试 (或者重置虚拟机)。
|
如果安装脚本出错,您需要重置虚拟机到干净的镜像。
|
||||||
|
|
||||||
```
|
|
||||||
rm -rf /opt/seafile
|
|
||||||
```
|
|
||||||
|
|
||||||
## 启动关闭服务
|
### 启动关闭服务
|
||||||
|
|
||||||
自动安装脚本会在系统中安装开机自动启动脚本。您也可以使用该脚本来关闭/启动 Seafile 服务,命令如下:
|
自动安装脚本会在系统中安装开机自动启动脚本。您也可以使用该脚本来关闭/启动 Seafile 服务,命令如下:
|
||||||
|
|
||||||
service seafile-server stop
|
```
|
||||||
service seafile-server start
|
service seafile-server stop
|
||||||
|
service seafile-server start
|
||||||
## 其他高级配置
|
```
|
||||||
|
|
||||||
### 备份 mysql
|
|
||||||
|
|
||||||
* 拷贝 `db-backup` 目录到 `/opt/seafile`
|
|
||||||
* 修改 `db-backup/db_backup.sh` 中的 `USER` `PASSWD`
|
|
||||||
* 执行 `crontab -e` 并添加内容 `0 1 * * * * /opt/seafile/db-backup/db_backup.sh` (每天凌晨1:00进行备份)
|
|
||||||
|
|
||||||
### 配置邮件发送
|
|
||||||
|
|
||||||
参考 http://manual-cn.seafile.com/config/sending_email.html
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
ccnet-db
|
|
||||||
seafile-db
|
|
||||||
seahub-db
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
USER=root
|
|
||||||
PASSWD=aeneinoi
|
|
||||||
DATE=`date +%Y%m%d%H%M`
|
|
||||||
IGN_TAB=""
|
|
||||||
|
|
||||||
for ign_tab in `cat table-ignore.txt`;
|
|
||||||
do
|
|
||||||
IGN_TAB=${IGN_TAB}" --ignore-table=${ign_tab}"
|
|
||||||
done
|
|
||||||
|
|
||||||
for DATABASE in `cat db-list.txt`;
|
|
||||||
do
|
|
||||||
mysqldump -u${USER} -p${PASSWD} --opt $DATABASE ${IGN_TAB} > $DATABASE-$DATE.sql
|
|
||||||
done
|
|
||||||
|
|
||||||
# Compress and clean
|
|
||||||
tar czvf mysql-back-$DATE.tar.gz *.sql
|
|
||||||
rm -rf *.sql
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
seahub-db.avatar_uploaded
|
|
||||||
seahub-db.avatar_avatar
|
|
||||||
seahub-db.avatar_groupavatar
|
|
||||||
seahub-db.Event
|
|
||||||
seahub-db.FileAudit
|
|
||||||
seahub-db.FileUpdate
|
|
||||||
seahub-db.PermAudit
|
|
||||||
seahub-db.UserEvent
|
|
||||||
seahub-db.UserTrafficStat
|
|
||||||
seahub-db.VirusFile
|
|
||||||
seahub-db.VirusScanRecord
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
|
|
@ -0,0 +1,549 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# seafile-server-installer-cn/seafile-10.0_ubuntu
|
||||||
|
#
|
||||||
|
# Copyright 2015, Alexander Jackson <alexander.jackson@seafile.de>
|
||||||
|
# Copyright 2016, Zheng Xie <xie.zheng@seafile.com>
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
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 10.0.0"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
clear
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
This script installs the community/professional edition of the Seafile Server on a Ubuntu 18.04/20.04 64bit
|
||||||
|
- Newest Seafile server version, MariaDB, Memcached, NGINX -
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
This installer is meant to run on a freshly installed machine
|
||||||
|
only. If you run it on a production server things can and
|
||||||
|
probably will go terribly wrong and you will lose valuable
|
||||||
|
data!
|
||||||
|
|
||||||
|
For questions or suggestions please contact us at
|
||||||
|
support@seafile.com
|
||||||
|
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
Possible options:
|
||||||
|
1 = Seafile Community (Free) Edition (CE)
|
||||||
|
2 = Seafile Professional Edition (PRO)
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [[ ${SEAFILE_PRO} == "" ]]; then
|
||||||
|
PS3="Which Seafile version would you like to install? "
|
||||||
|
select SEAFILE_SERVER_VERSION in CE PRO ABORT; do
|
||||||
|
case "${SEAFILE_SERVER_VERSION}" in
|
||||||
|
ABORT)
|
||||||
|
echo "Aborting"
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"")
|
||||||
|
echo "$REPLY: Wrong value. Select 1 or 2."
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [[ ${SEAFILE_SERVER_VERSION} = "PRO" ]]; then
|
||||||
|
SEAFILE_PRO=1
|
||||||
|
else
|
||||||
|
SEAFILE_PRO=0
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
is_pro() {
|
||||||
|
if [[ "$SEAFILE_PRO" == "1" ]]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
echo
|
||||||
|
if is_pro; then
|
||||||
|
echo "This script will install Seafile Professional Edition for you."
|
||||||
|
else
|
||||||
|
echo "This script will install Seafile Community Edition for you."
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Vars
|
||||||
|
# -------------------------------------------
|
||||||
|
SEAFILE_ADMIN=admin@seafile.local
|
||||||
|
SEAFILE_SERVER_USER=seafile
|
||||||
|
SEAFILE_SERVER_HOME=/opt/seafile
|
||||||
|
IP_OR_DOMAIN=127.0.0.1
|
||||||
|
SEAFILE_VERSION=$1
|
||||||
|
TIME_ZONE=Asia/Shanghai
|
||||||
|
|
||||||
|
if is_pro; then
|
||||||
|
SEAFILE_SERVER_PACKAGE=seafile-pro-server_${SEAFILE_VERSION}_x86-64.tar.gz
|
||||||
|
if [[ ! -e /opt/$SEAFILE_SERVER_PACKAGE ]]; then
|
||||||
|
echo
|
||||||
|
echo "You must download \"$SEAFILE_SERVER_PACKAGE\" to the /opt/ folder before running this script!"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
INSTALLPATH=${SEAFILE_SERVER_HOME}/seafile-pro-server-${SEAFILE_VERSION}/
|
||||||
|
else
|
||||||
|
SEAFILE_SERVER_PACKAGE=seafile-server_${SEAFILE_VERSION}_x86-64.tar.gz
|
||||||
|
SEAFILE_SERVER_PACKAGE_URL=http://seafile-downloads.oss-cn-shanghai.aliyuncs.com/${SEAFILE_SERVER_PACKAGE}
|
||||||
|
INSTALLPATH=${SEAFILE_SERVER_HOME}/seafile-server-${SEAFILE_VERSION}/
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Ensure we are running the installer as root
|
||||||
|
# -------------------------------------------
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
echo " Aborting because you are not root" ; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Abort if directory SEAFILE_SERVER_HOME exists
|
||||||
|
# -------------------------------------------
|
||||||
|
if [[ -d "${SEAFILE_SERVER_HOME}" ]] ;
|
||||||
|
then
|
||||||
|
echo " Aborting because directory ${SEAFILE_SERVER_HOME} already exist" ; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Abort if seafile user exists
|
||||||
|
# -------------------------------------------
|
||||||
|
if getent passwd ${SEAFILE_SERVER_USER} > /dev/null 2>&1 ;
|
||||||
|
then
|
||||||
|
echo "Aborting because user ${SEAFILE_SERVER_USER} already exist" ; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Additional requirements
|
||||||
|
# -------------------------------------------
|
||||||
|
apt-get update
|
||||||
|
|
||||||
|
apt-get install -y python3 python3-setuptools python3-pip python3-ldap memcached \
|
||||||
|
libmemcached-dev libreoffice-script-provider-python libreoffice pwgen curl nginx libmysqlclient-dev
|
||||||
|
|
||||||
|
pip3 install --timeout=3600 django==3.2.* future==0.18.* mysqlclient==2.1.* pymysql pillow==10.2.* pylibmc captcha==0.5.* markupsafe==2.0.1 jinja2 sqlalchemy==1.4.3 psd-tools django-pylibmc django_simple_captcha==0.5.20 djangosaml2==1.5.* pysaml2==7.2.* pycryptodome==3.16.* cffi==1.15.1 lxml
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
service memcached start
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Setup Nginx
|
||||||
|
# -------------------------------------------
|
||||||
|
|
||||||
|
rm /etc/nginx/sites-enabled/*
|
||||||
|
|
||||||
|
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 /notification/ping {
|
||||||
|
proxy_pass http://127.0.0.1:8083/ping;
|
||||||
|
access_log /var/log/nginx/notification.access.log seafileformat;
|
||||||
|
error_log /var/log/nginx/notification.error.log;
|
||||||
|
}
|
||||||
|
location /notification {
|
||||||
|
proxy_pass http://127.0.0.1:8083/;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade \$http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
access_log /var/log/nginx/notification.access.log seafileformat;
|
||||||
|
error_log /var/log/nginx/notification.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 <<EOF
|
||||||
|
[client]
|
||||||
|
user=root
|
||||||
|
password=$SQLROOTPW
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod 600 /root/.my.cnf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Seafile init script
|
||||||
|
# -------------------------------------------
|
||||||
|
cat > /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 <alexander.jackson@seafile.de>
|
||||||
|
|
||||||
|
# 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 <<EOF
|
||||||
|
[client]
|
||||||
|
user=seafile
|
||||||
|
password=$SQLSEAFILEPW
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod 600 /opt/seafile.my.cnf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Add seafile user
|
||||||
|
# -------------------------------------------
|
||||||
|
useradd --system --comment "${SEAFILE_SERVER_USER}" ${SEAFILE_SERVER_USER} --home-dir ${SEAFILE_SERVER_HOME}
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Go to /opt/seafile/seafile-pro-server-${SEAFILE_VERSION}
|
||||||
|
# -------------------------------------------
|
||||||
|
cd $INSTALLPATH
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Vars - Don't touch these unless you really know what you are doing!
|
||||||
|
# -------------------------------------------
|
||||||
|
TOPDIR=$(dirname "${INSTALLPATH}")
|
||||||
|
DEFAULT_CONF_DIR=${TOPDIR}/conf
|
||||||
|
SEAFILE_DATA_DIR=${TOPDIR}/seafile-data
|
||||||
|
DEST_SETTINGS_PY=${TOPDIR}/conf/seahub_settings.py
|
||||||
|
|
||||||
|
mkdir -p ${DEFAULT_CONF_DIR}
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Create ccnet, seafile, seahub conf using setup script
|
||||||
|
# -------------------------------------------
|
||||||
|
|
||||||
|
./setup-seafile-mysql.sh auto -u seafile -w ${SQLSEAFILEPW} -r ${SQLROOTPW}
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Configure Seafile WebDAV Server(SeafDAV)
|
||||||
|
# -------------------------------------------
|
||||||
|
sed -i 's/enabled = .*/enabled = true/' ${DEFAULT_CONF_DIR}/seafdav.conf
|
||||||
|
sed -i 's/share_name = .*/share_name = \/seafdav/' ${DEFAULT_CONF_DIR}/seafdav.conf
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Configuring seahub_settings.py
|
||||||
|
# -------------------------------------------
|
||||||
|
cat >> ${DEST_SETTINGS_PY} <<EOF
|
||||||
|
|
||||||
|
CACHES = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
|
||||||
|
'LOCATION': '127.0.0.1:11211',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
# EMAIL_USE_TLS = False
|
||||||
|
# EMAIL_HOST = 'localhost'
|
||||||
|
# EMAIL_HOST_USER = ''
|
||||||
|
# EMAIL_HOST_PASSWORD = ''
|
||||||
|
# EMAIL_PORT = '25'
|
||||||
|
# DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
|
||||||
|
# SERVER_EMAIL = EMAIL_HOST_USER
|
||||||
|
|
||||||
|
TIME_ZONE = '${TIME_ZONE}'
|
||||||
|
SITE_BASE = 'http://${IP_OR_DOMAIN}'
|
||||||
|
SITE_NAME = 'Seafile Server'
|
||||||
|
SITE_TITLE = 'Seafile Server'
|
||||||
|
SITE_ROOT = '/'
|
||||||
|
ENABLE_SIGNUP = False
|
||||||
|
ACTIVATE_AFTER_REGISTRATION = False
|
||||||
|
SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER = True
|
||||||
|
SEND_EMAIL_ON_RESETTING_USER_PASSWD = True
|
||||||
|
FILE_PREVIEW_MAX_SIZE = 30 * 1024 * 1024
|
||||||
|
SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2
|
||||||
|
SESSION_SAVE_EVERY_REQUEST = False
|
||||||
|
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
|
||||||
|
|
||||||
|
SERVICE_URL = 'http://${IP_OR_DOMAIN}'
|
||||||
|
FILE_SERVER_ROOT = 'http://${IP_OR_DOMAIN}/seafhttp'
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Backup check_init_admin.py befor applying changes
|
||||||
|
# -------------------------------------------
|
||||||
|
cp ${INSTALLPATH}/check_init_admin.py ${INSTALLPATH}/check_init_admin.py.backup
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Set admin credentials in check_init_admin.py
|
||||||
|
# -------------------------------------------
|
||||||
|
SEAFILE_ADMIN_PW=$(pwgen)
|
||||||
|
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.
|
||||||
|
# -------------------------------------------
|
||||||
|
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R ${SEAFILE_SERVER_HOME}
|
||||||
|
|
||||||
|
su - seafile -c "${INSTALLPATH}/seafile.sh start"
|
||||||
|
wait
|
||||||
|
su - seafile -c "${INSTALLPATH}/seahub.sh start"
|
||||||
|
wait # sleep for a while, otherwise seahub will not be stopped
|
||||||
|
su - seafile -c "${INSTALLPATH}/seahub.sh stop"
|
||||||
|
wait
|
||||||
|
su - seafile -c "${INSTALLPATH}/seafile.sh stop"
|
||||||
|
wait
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Restore original check_init_admin.py
|
||||||
|
# -------------------------------------------
|
||||||
|
mv ${INSTALLPATH}/check_init_admin.py.backup ${INSTALLPATH}/check_init_admin.py
|
||||||
|
|
||||||
|
if is_pro; then
|
||||||
|
PRO_PY=${INSTALLPATH}/pro/pro.py
|
||||||
|
$PYTHON ${PRO_PY} setup --mysql --mysql_host=127.0.0.1 --mysql_port=3306 --mysql_user=seafile --mysql_password=${SQLSEAFILEPW} --mysql_db=seahub_db
|
||||||
|
fi
|
||||||
|
|
||||||
|
# kill all process
|
||||||
|
sleep 1
|
||||||
|
service seafile-server stop
|
||||||
|
wait
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Fix permissions
|
||||||
|
# -------------------------------------------
|
||||||
|
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R ${SEAFILE_SERVER_HOME}
|
||||||
|
if [[ -d /tmp/seafile-office-output/ ]]; then
|
||||||
|
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R /tmp/seafile-office-output/
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Start seafile server
|
||||||
|
# -------------------------------------------
|
||||||
|
echo "Starting productive Seafile server"
|
||||||
|
service seafile-server restart
|
||||||
|
wait
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Final report
|
||||||
|
# -------------------------------------------
|
||||||
|
cat > ${TOPDIR}/aio_seafile-server.log<<EOF
|
||||||
|
|
||||||
|
Your Seafile server is installed
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
Server Address: http://${IP_OR_DOMAIN}
|
||||||
|
|
||||||
|
Seafile Admin: ${SEAFILE_ADMIN}
|
||||||
|
Admin Password: ${SEAFILE_ADMIN_PW}
|
||||||
|
|
||||||
|
Seafile Data Dir: ${SEAFILE_DATA_DIR}
|
||||||
|
|
||||||
|
Seafile DB Credentials: Check /opt/seafile.my.cnf
|
||||||
|
Root DB Credentials: Check /root/.my.cnf
|
||||||
|
|
||||||
|
This report is also saved to ${TOPDIR}/aio_seafile-server.log
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Next you should manually complete the following steps
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
1) Log in to Seafile and configure your server domain via the system
|
||||||
|
admin area if applicable.
|
||||||
|
|
||||||
|
2) If this server is behind a firewall, you need to ensure that
|
||||||
|
tcp port 80 is open.
|
||||||
|
|
||||||
|
3) Check https://manual.seafile.com/config/sending_email/
|
||||||
|
for instructions on how to use an existing email account to send email via SMTP.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Optional steps
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
1) Check seahub_settings.py and customize it to fit your needs. Consult
|
||||||
|
https://manual.seafile.com/config/seahub_settings_py/ for possible switches.
|
||||||
|
|
||||||
|
2) Setup NGINX with official SSL certificate, we suggest you use Let’s Encrypt. Check
|
||||||
|
https://manual.seafile.com/deploy/https_with_nginx/
|
||||||
|
|
||||||
|
3) Secure server with iptables based firewall. For instance: UFW or shorewall
|
||||||
|
|
||||||
|
4) Implement a backup routine for your Seafile server.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Seafile support options
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
For free community support visit: https://bbs.seafile.com
|
||||||
|
For paid commercial support visit: https://seafile.com
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod 600 ${TOPDIR}/aio_seafile-server.log
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
|
cat ${TOPDIR}/aio_seafile-server.log
|
||||||
|
|
@ -0,0 +1,551 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# seafile-server-installer-cn/seafile-11.0_ubuntu
|
||||||
|
#
|
||||||
|
# Copyright 2015, Alexander Jackson <alexander.jackson@seafile.de>
|
||||||
|
# Copyright 2016, Zheng Xie <xie.zheng@seafile.com>
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
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 11.0.0"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
clear
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
This script installs the community/professional edition of the Seafile Server on a Ubuntu 20.04/22.04 64bit
|
||||||
|
- Newest Seafile server version, MariaDB, Memcached, NGINX -
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
This installer is meant to run on a freshly installed machine
|
||||||
|
only. If you run it on a production server things can and
|
||||||
|
probably will go terribly wrong and you will lose valuable
|
||||||
|
data!
|
||||||
|
|
||||||
|
For questions or suggestions please contact us at
|
||||||
|
support@seafile.com
|
||||||
|
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
Possible options:
|
||||||
|
1 = Seafile Community (Free) Edition (CE)
|
||||||
|
2 = Seafile Professional Edition (PRO)
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [[ ${SEAFILE_PRO} == "" ]]; then
|
||||||
|
PS3="Which Seafile version would you like to install? "
|
||||||
|
select SEAFILE_SERVER_VERSION in CE PRO ABORT; do
|
||||||
|
case "${SEAFILE_SERVER_VERSION}" in
|
||||||
|
ABORT)
|
||||||
|
echo "Aborting"
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"")
|
||||||
|
echo "$REPLY: Wrong value. Select 1 or 2."
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [[ ${SEAFILE_SERVER_VERSION} = "PRO" ]]; then
|
||||||
|
SEAFILE_PRO=1
|
||||||
|
else
|
||||||
|
SEAFILE_PRO=0
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
is_pro() {
|
||||||
|
if [[ "$SEAFILE_PRO" == "1" ]]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
echo
|
||||||
|
if is_pro; then
|
||||||
|
echo "This script will install Seafile Professional Edition for you."
|
||||||
|
else
|
||||||
|
echo "This script will install Seafile Community Edition for you."
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Vars
|
||||||
|
# -------------------------------------------
|
||||||
|
SEAFILE_ADMIN=admin@seafile.local
|
||||||
|
SEAFILE_SERVER_USER=seafile
|
||||||
|
SEAFILE_SERVER_HOME=/opt/seafile
|
||||||
|
IP_OR_DOMAIN=127.0.0.1
|
||||||
|
SEAFILE_VERSION=$1
|
||||||
|
TIME_ZONE=Asia/Shanghai
|
||||||
|
|
||||||
|
if is_pro; then
|
||||||
|
SEAFILE_SERVER_PACKAGE=seafile-pro-server_${SEAFILE_VERSION}_x86-64.tar.gz
|
||||||
|
if [[ ! -e /opt/$SEAFILE_SERVER_PACKAGE ]]; then
|
||||||
|
echo
|
||||||
|
echo "You must download \"$SEAFILE_SERVER_PACKAGE\" to the /opt/ folder before running this script!"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
INSTALLPATH=${SEAFILE_SERVER_HOME}/seafile-pro-server-${SEAFILE_VERSION}/
|
||||||
|
else
|
||||||
|
SEAFILE_SERVER_PACKAGE=seafile-server_${SEAFILE_VERSION}_x86-64.tar.gz
|
||||||
|
SEAFILE_SERVER_PACKAGE_URL=http://seafile-downloads.oss-cn-shanghai.aliyuncs.com/${SEAFILE_SERVER_PACKAGE}
|
||||||
|
INSTALLPATH=${SEAFILE_SERVER_HOME}/seafile-server-${SEAFILE_VERSION}/
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Ensure we are running the installer as root
|
||||||
|
# -------------------------------------------
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
echo " Aborting because you are not root" ; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Abort if directory SEAFILE_SERVER_HOME exists
|
||||||
|
# -------------------------------------------
|
||||||
|
if [[ -d "${SEAFILE_SERVER_HOME}" ]] ;
|
||||||
|
then
|
||||||
|
echo " Aborting because directory ${SEAFILE_SERVER_HOME} already exist" ; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Abort if seafile user exists
|
||||||
|
# -------------------------------------------
|
||||||
|
if getent passwd ${SEAFILE_SERVER_USER} > /dev/null 2>&1 ;
|
||||||
|
then
|
||||||
|
echo "Aborting because user ${SEAFILE_SERVER_USER} already exist" ; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Additional requirements
|
||||||
|
# -------------------------------------------
|
||||||
|
apt-get update
|
||||||
|
|
||||||
|
apt-get install -y python3 python3-dev python3-setuptools python3-pip python3-ldap memcached \
|
||||||
|
libmemcached-dev pwgen curl nginx libmysqlclient-dev ldap-utils libldap2-dev dnsutils
|
||||||
|
|
||||||
|
pip3 install --timeout=3600 django==4.2.* future==0.18.* mysqlclient==2.1.* pymysql pillow==10.2.* pylibmc captcha==0.5.* markupsafe==2.0.1 jinja2 sqlalchemy==2.0.18 psd-tools django-pylibmc django_simple_captcha==0.6.* djangosaml2==1.5.* pysaml2==7.2.* pycryptodome==3.16.* cffi==1.15.1 python-ldap==3.4.3 lxml \
|
||||||
|
-i https://pypi.tuna.tsinghua.edu.cn/simple/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
service memcached start
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Setup Nginx
|
||||||
|
# -------------------------------------------
|
||||||
|
|
||||||
|
rm /etc/nginx/sites-enabled/*
|
||||||
|
|
||||||
|
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 \$http_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 /notification/ping {
|
||||||
|
proxy_pass http://127.0.0.1:8083/ping;
|
||||||
|
access_log /var/log/nginx/notification.access.log seafileformat;
|
||||||
|
error_log /var/log/nginx/notification.error.log;
|
||||||
|
}
|
||||||
|
location /notification {
|
||||||
|
proxy_pass http://127.0.0.1:8083/;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade \$http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
access_log /var/log/nginx/notification.access.log seafileformat;
|
||||||
|
error_log /var/log/nginx/notification.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
|
||||||
|
# https://mariadb.com/kb/en/mariadb-package-repository-setup-and-usage/
|
||||||
|
curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | sudo bash -s -- --mariadb-server-version="mariadb-10.6"
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server-10.6
|
||||||
|
service mysql start
|
||||||
|
|
||||||
|
SQLROOTPW=$(pwgen)
|
||||||
|
|
||||||
|
mysqladmin -u root password $SQLROOTPW
|
||||||
|
|
||||||
|
cat > /root/.my.cnf <<EOF
|
||||||
|
[client]
|
||||||
|
user=root
|
||||||
|
password=$SQLROOTPW
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod 600 /root/.my.cnf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Seafile init script
|
||||||
|
# -------------------------------------------
|
||||||
|
cat > /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 <alexander.jackson@seafile.de>
|
||||||
|
|
||||||
|
# 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 <<EOF
|
||||||
|
[client]
|
||||||
|
user=seafile
|
||||||
|
password=$SQLSEAFILEPW
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod 600 /opt/seafile.my.cnf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Add seafile user
|
||||||
|
# -------------------------------------------
|
||||||
|
useradd --system --comment "${SEAFILE_SERVER_USER}" ${SEAFILE_SERVER_USER} --home-dir ${SEAFILE_SERVER_HOME}
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Go to /opt/seafile/seafile-pro-server-${SEAFILE_VERSION}
|
||||||
|
# -------------------------------------------
|
||||||
|
cd $INSTALLPATH
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Vars - Don't touch these unless you really know what you are doing!
|
||||||
|
# -------------------------------------------
|
||||||
|
TOPDIR=$(dirname "${INSTALLPATH}")
|
||||||
|
DEFAULT_CONF_DIR=${TOPDIR}/conf
|
||||||
|
SEAFILE_DATA_DIR=${TOPDIR}/seafile-data
|
||||||
|
DEST_SETTINGS_PY=${TOPDIR}/conf/seahub_settings.py
|
||||||
|
|
||||||
|
mkdir -p ${DEFAULT_CONF_DIR}
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Create ccnet, seafile, seahub conf using setup script
|
||||||
|
# -------------------------------------------
|
||||||
|
|
||||||
|
./setup-seafile-mysql.sh auto -u seafile -w ${SQLSEAFILEPW} -r ${SQLROOTPW}
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Configure Seafile WebDAV Server(SeafDAV)
|
||||||
|
# -------------------------------------------
|
||||||
|
sed -i 's/enabled = .*/enabled = true/' ${DEFAULT_CONF_DIR}/seafdav.conf
|
||||||
|
sed -i 's/share_name = .*/share_name = \/seafdav/' ${DEFAULT_CONF_DIR}/seafdav.conf
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Configuring seahub_settings.py
|
||||||
|
# -------------------------------------------
|
||||||
|
cat >> ${DEST_SETTINGS_PY} <<EOF
|
||||||
|
|
||||||
|
CACHES = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
|
||||||
|
'LOCATION': '127.0.0.1:11211',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
# EMAIL_USE_TLS = False
|
||||||
|
# EMAIL_HOST = 'localhost'
|
||||||
|
# EMAIL_HOST_USER = ''
|
||||||
|
# EMAIL_HOST_PASSWORD = ''
|
||||||
|
# EMAIL_PORT = '25'
|
||||||
|
# DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
|
||||||
|
# SERVER_EMAIL = EMAIL_HOST_USER
|
||||||
|
|
||||||
|
TIME_ZONE = '${TIME_ZONE}'
|
||||||
|
SITE_BASE = 'http://${IP_OR_DOMAIN}'
|
||||||
|
SITE_NAME = 'Seafile Server'
|
||||||
|
SITE_TITLE = 'Seafile Server'
|
||||||
|
SITE_ROOT = '/'
|
||||||
|
ENABLE_SIGNUP = False
|
||||||
|
ACTIVATE_AFTER_REGISTRATION = False
|
||||||
|
SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER = True
|
||||||
|
SEND_EMAIL_ON_RESETTING_USER_PASSWD = True
|
||||||
|
FILE_PREVIEW_MAX_SIZE = 30 * 1024 * 1024
|
||||||
|
SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2
|
||||||
|
SESSION_SAVE_EVERY_REQUEST = False
|
||||||
|
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
|
||||||
|
|
||||||
|
SERVICE_URL = 'http://${IP_OR_DOMAIN}'
|
||||||
|
FILE_SERVER_ROOT = 'http://${IP_OR_DOMAIN}/seafhttp'
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Backup check_init_admin.py befor applying changes
|
||||||
|
# -------------------------------------------
|
||||||
|
cp ${INSTALLPATH}/check_init_admin.py ${INSTALLPATH}/check_init_admin.py.backup
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Set admin credentials in check_init_admin.py
|
||||||
|
# -------------------------------------------
|
||||||
|
SEAFILE_ADMIN_PW=$(pwgen)
|
||||||
|
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.
|
||||||
|
# -------------------------------------------
|
||||||
|
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R ${SEAFILE_SERVER_HOME}
|
||||||
|
|
||||||
|
su - seafile -c "${INSTALLPATH}/seafile.sh start"
|
||||||
|
wait
|
||||||
|
su - seafile -c "${INSTALLPATH}/seahub.sh start"
|
||||||
|
wait # sleep for a while, otherwise seahub will not be stopped
|
||||||
|
su - seafile -c "${INSTALLPATH}/seahub.sh stop"
|
||||||
|
wait
|
||||||
|
su - seafile -c "${INSTALLPATH}/seafile.sh stop"
|
||||||
|
wait
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Restore original check_init_admin.py
|
||||||
|
# -------------------------------------------
|
||||||
|
mv ${INSTALLPATH}/check_init_admin.py.backup ${INSTALLPATH}/check_init_admin.py
|
||||||
|
|
||||||
|
# seafevents.conf
|
||||||
|
PRO_PY=${INSTALLPATH}/pro/pro.py
|
||||||
|
$PYTHON ${PRO_PY} setup --mysql --mysql_host=127.0.0.1 --mysql_port=3306 --mysql_user=seafile --mysql_password=${SQLSEAFILEPW} --mysql_db=seahub_db
|
||||||
|
|
||||||
|
# kill all process
|
||||||
|
sleep 1
|
||||||
|
service seafile-server stop
|
||||||
|
wait
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Fix permissions
|
||||||
|
# -------------------------------------------
|
||||||
|
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R ${SEAFILE_SERVER_HOME}
|
||||||
|
if [[ -d /tmp/seafile-office-output/ ]]; then
|
||||||
|
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R /tmp/seafile-office-output/
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Start seafile server
|
||||||
|
# -------------------------------------------
|
||||||
|
echo "Starting productive Seafile server"
|
||||||
|
service seafile-server restart
|
||||||
|
wait
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Final report
|
||||||
|
# -------------------------------------------
|
||||||
|
cat > ${TOPDIR}/aio_seafile-server.log<<EOF
|
||||||
|
|
||||||
|
Your Seafile server is installed
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
Server Address: http://${IP_OR_DOMAIN}
|
||||||
|
|
||||||
|
Seafile Admin: ${SEAFILE_ADMIN}
|
||||||
|
Admin Password: ${SEAFILE_ADMIN_PW}
|
||||||
|
|
||||||
|
Seafile Data Dir: ${SEAFILE_DATA_DIR}
|
||||||
|
|
||||||
|
Seafile DB Credentials: Check /opt/seafile.my.cnf
|
||||||
|
Root DB Credentials: Check /root/.my.cnf
|
||||||
|
|
||||||
|
This report is also saved to ${TOPDIR}/aio_seafile-server.log
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Next you should manually complete the following steps
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
1) Log in to Seafile and configure your server domain via the system
|
||||||
|
admin area if applicable.
|
||||||
|
|
||||||
|
2) If this server is behind a firewall, you need to ensure that
|
||||||
|
tcp port 80 is open.
|
||||||
|
|
||||||
|
3) Check https://manual.seafile.com/config/sending_email/
|
||||||
|
for instructions on how to use an existing email account to send email via SMTP.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Optional steps
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
1) Check seahub_settings.py and customize it to fit your needs. Consult
|
||||||
|
https://manual.seafile.com/config/seahub_settings_py/ for possible switches.
|
||||||
|
|
||||||
|
2) Setup NGINX with official SSL certificate, we suggest you use Let’s Encrypt. Check
|
||||||
|
https://manual.seafile.com/deploy/https_with_nginx/
|
||||||
|
|
||||||
|
3) Secure server with iptables based firewall. For instance: UFW or shorewall
|
||||||
|
|
||||||
|
4) Implement a backup routine for your Seafile server.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Seafile support options
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
For free community support visit: https://bbs.seafile.com
|
||||||
|
For paid commercial support visit: https://seafile.com
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod 600 ${TOPDIR}/aio_seafile-server.log
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
|
cat ${TOPDIR}/aio_seafile-server.log
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# seafile-server-installer/seafile-server-ce-ubuntu-14-04-amd64
|
# seafile-server-installer/seafile-server-ubuntu-16-04-amd64
|
||||||
#
|
#
|
||||||
# Copyright 2015, Alexander Jackson <alexander.jackson@seafile.de>
|
# Copyright 2015, Alexander Jackson <alexander.jackson@seafile.de>
|
||||||
|
# Copyright 2016, Zheng Xie <xie.zheng@seafile.com>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
|
@ -19,6 +20,10 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
if [[ $HOME == "" ]]; then
|
||||||
|
export HOME=/root
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $SEAFILE_DEBUG != "" ]]; then
|
if [[ $SEAFILE_DEBUG != "" ]]; then
|
||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
@ -26,14 +31,14 @@ set -e
|
||||||
|
|
||||||
if [[ "$#" -ne 1 ]]; then
|
if [[ "$#" -ne 1 ]]; then
|
||||||
echo "You must specif Seafile version to install"
|
echo "You must specif Seafile version to install"
|
||||||
echo "Like: $0 4.4.2"
|
echo "Like: $0 7.1.0"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
clear
|
clear
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
|
||||||
This script installs the community edition of the Seafile Server on a Ubuntu 14.04 (Trusty) 64bit
|
This script installs the community edition of the Seafile Server on a Ubuntu 16.04 (Xenial) 64bit
|
||||||
- Newest Seafile server version, MariaDB, Memcached, NGINX -
|
- Newest Seafile server version, MariaDB, Memcached, NGINX -
|
||||||
-----------------------------------------------------------------
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -95,11 +100,9 @@ echo
|
||||||
# Vars
|
# Vars
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
SEAFILE_ADMIN=admin@seafile.local
|
SEAFILE_ADMIN=admin@seafile.local
|
||||||
SEAFILE_USER=seafile
|
SEAFILE_SERVER_USER=seafile
|
||||||
SERVER_NAME=$(hostname -s)
|
SEAFILE_SERVER_HOME=/opt/seafile
|
||||||
IP_OR_DOMAIN=$(hostname -i)
|
IP_OR_DOMAIN=127.0.0.1
|
||||||
HOSTNAME=$(hostname -i)
|
|
||||||
FILESERVER_PORT=8082
|
|
||||||
SEAFILE_VERSION=$1
|
SEAFILE_VERSION=$1
|
||||||
TIME_ZONE=Asia/Shanghai
|
TIME_ZONE=Asia/Shanghai
|
||||||
|
|
||||||
|
|
@ -111,11 +114,11 @@ if is_pro; then
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
INSTALLPATH=/opt/seafile/seafile-pro-server-${SEAFILE_VERSION}/
|
INSTALLPATH=${SEAFILE_SERVER_HOME}/seafile-pro-server-${SEAFILE_VERSION}/
|
||||||
else
|
else
|
||||||
SEAFILE_SERVER_PACKAGE=seafile-server_${SEAFILE_VERSION}_x86-64.tar.gz
|
SEAFILE_SERVER_PACKAGE=seafile-server_${SEAFILE_VERSION}_x86-64.tar.gz
|
||||||
SEAFILE_SERVER_PACKAGE_URL=http://download-cn.seafile.com/${SEAFILE_SERVER_PACKAGE}
|
SEAFILE_SERVER_PACKAGE_URL=http://seafile-downloads.oss-cn-shanghai.aliyuncs.com/${SEAFILE_SERVER_PACKAGE}
|
||||||
INSTALLPATH=/opt/seafile/seafile-server-${SEAFILE_VERSION}/
|
INSTALLPATH=${SEAFILE_SERVER_HOME}/seafile-server-${SEAFILE_VERSION}/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -128,70 +131,85 @@ fi
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Abort if directory /opt/seafile/ exists
|
# Abort if directory SEAFILE_SERVER_HOME exists
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
if [[ -d "/opt/seafile/" ]] ;
|
if [[ -d "${SEAFILE_SERVER_HOME}" ]] ;
|
||||||
then
|
then
|
||||||
echo " Aborting because directory /opt/seafile/ already exist" ; exit 1
|
echo " Aborting because directory ${SEAFILE_SERVER_HOME} already exist" ; exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Additional requirements
|
# Additional requirements
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y sudo python-pip python-setuptools python-imaging python-mysqldb python-ldap \
|
|
||||||
openjdk-7-jre memcached python-memcache pwgen curl openssl poppler-utils libpython2.7 libreoffice \
|
# apt-get install -y python2.7 sudo python-setuptools python-mysqldb python-ldap python-urllib3 \
|
||||||
libreoffice-script-provider-python ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy nginx
|
# openjdk-8-jre memcached libmemcached-dev zlib1g-dev pwgen curl openssl poppler-utils libpython2.7 libreoffice \
|
||||||
|
# libreoffice-script-provider-python ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy nginx
|
||||||
|
|
||||||
|
apt-get install -y python3 python3-setuptools python3-pip python3-ldap memcached openjdk-8-jre \
|
||||||
|
libmemcached-dev libreoffice-script-provider-python libreoffice pwgen curl nginx
|
||||||
|
|
||||||
|
pip3 install --timeout=3600 Pillow pylibmc captcha jinja2 sqlalchemy==1.3.8 psd-tools \
|
||||||
|
django-pylibmc django-simple-captcha
|
||||||
|
|
||||||
|
|
||||||
|
service memcached start
|
||||||
|
|
||||||
|
|
||||||
rm /etc/nginx/sites-enabled/*
|
rm /etc/nginx/sites-enabled/*
|
||||||
|
|
||||||
cat > /etc/nginx/sites-available/seafile.conf <<'EOF'
|
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 {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name "";
|
server_name seafile.example.com;
|
||||||
|
|
||||||
location / {
|
proxy_set_header X-Forwarded-For \$remote_addr;
|
||||||
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;
|
location / {
|
||||||
error_log /var/log/nginx/seahub.error.log;
|
proxy_pass http://127.0.0.1:8000;
|
||||||
}
|
proxy_set_header Host \$host;
|
||||||
location /seafhttp {
|
proxy_set_header X-Real-IP \$remote_addr;
|
||||||
rewrite ^/seafhttp(.*)$ $1 break;
|
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||||
proxy_pass http://127.0.0.1:8082;
|
proxy_set_header X-Forwarded-Host \$server_name;
|
||||||
client_max_body_size 0;
|
proxy_set_header X-Forwarded-Proto \$scheme;
|
||||||
proxy_connect_timeout 36000s;
|
proxy_read_timeout 1200s;
|
||||||
proxy_read_timeout 36000s;
|
|
||||||
}
|
# used for view/edit office file via Office Online Server
|
||||||
location /media {
|
client_max_body_size 0;
|
||||||
root /opt/seafile/seafile-server-latest/seahub;
|
|
||||||
}
|
access_log /var/log/nginx/seahub.access.log seafileformat;
|
||||||
location /seafdav {
|
error_log /var/log/nginx/seahub.error.log;
|
||||||
fastcgi_pass 127.0.0.1:8080;
|
}
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
||||||
fastcgi_param PATH_INFO $fastcgi_script_name;
|
location /seafhttp {
|
||||||
fastcgi_param SERVER_PROTOCOL $server_protocol;
|
rewrite ^/seafhttp(.*)$ \$1 break;
|
||||||
fastcgi_param QUERY_STRING $query_string;
|
proxy_pass http://127.0.0.1:8082;
|
||||||
fastcgi_param REQUEST_METHOD $request_method;
|
client_max_body_size 0;
|
||||||
fastcgi_param CONTENT_TYPE $content_type;
|
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||||
fastcgi_param CONTENT_LENGTH $content_length;
|
proxy_connect_timeout 36000s;
|
||||||
fastcgi_param SERVER_ADDR $server_addr;
|
proxy_read_timeout 36000s;
|
||||||
fastcgi_param SERVER_PORT $server_port;
|
|
||||||
fastcgi_param SERVER_NAME $server_name;
|
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;
|
client_max_body_size 0;
|
||||||
|
|
||||||
access_log /var/log/nginx/seafdav.access.log;
|
access_log /var/log/nginx/seafdav.access.log seafileformat;
|
||||||
error_log /var/log/nginx/seafdav.error.log;
|
error_log /var/log/nginx/seafdav.error.log;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -208,8 +226,10 @@ service nginx restart
|
||||||
if [[ -f "/root/.my.cnf" ]] ;
|
if [[ -f "/root/.my.cnf" ]] ;
|
||||||
then
|
then
|
||||||
echo "MariaDB installed before, skip this part"
|
echo "MariaDB installed before, skip this part"
|
||||||
|
SQLROOTPW=`sed -n 's/password=//p' /root/.my.cnf`
|
||||||
else
|
else
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server
|
DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server
|
||||||
|
service mysql start
|
||||||
|
|
||||||
SQLROOTPW=$(pwgen)
|
SQLROOTPW=$(pwgen)
|
||||||
|
|
||||||
|
|
@ -224,61 +244,43 @@ EOF
|
||||||
chmod 600 /root/.my.cnf
|
chmod 600 /root/.my.cnf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Seafile init script
|
# Seafile init script
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
cat > /etc/init.d/seafile-server <<'EOF'
|
cat > /etc/init.d/seafile-server << EOF
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
### BEGIN INIT INFO
|
### BEGIN INIT INFO
|
||||||
# Provides: seafile-server
|
# Provides: seafile-server
|
||||||
# Required-Start: $remote_fs $syslog mysql
|
# Required-Start: \$remote_fs \$syslog mysql
|
||||||
# Required-Stop: $remote_fs $syslog
|
# Required-Stop: \$remote_fs \$syslog
|
||||||
# Default-Start: 2 3 4 5
|
# Default-Start: 2 3 4 5
|
||||||
# Default-Stop: 0 1 6
|
# Default-Stop: 0 1 6
|
||||||
# Short-Description: Seafile server
|
# Short-Description: Seafile server
|
||||||
# Description: Start Seafile server
|
# Description: Start Seafile server
|
||||||
### END INIT INFO
|
### END INIT INFO
|
||||||
|
|
||||||
# Author: Alexander Jackson <alexander.jackson@seafile.com.de>
|
# Author: Alexander Jackson <alexander.jackson@seafile.de>
|
||||||
#
|
|
||||||
|
|
||||||
# Change the value of "user" to your linux user name
|
|
||||||
user=seafile
|
|
||||||
|
|
||||||
# Change the value of "seafile_dir" to your path of seafile installation
|
# Change the value of "seafile_dir" to your path of seafile installation
|
||||||
seafile_dir=/opt/seafile
|
user=${SEAFILE_SERVER_USER}
|
||||||
script_path=${seafile_dir}/seafile-server-latest
|
seafile_dir=${SEAFILE_SERVER_HOME}
|
||||||
seafile_init_log=${seafile_dir}/logs/seafile.init.log
|
script_path=\${seafile_dir}/seafile-server-latest
|
||||||
seahub_init_log=${seafile_dir}/logs/seahub.init.log
|
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
|
case "\$1" in
|
||||||
start)
|
start)
|
||||||
sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log}
|
sudo -u \${user} \${script_path}/seafile.sh start >> \${seafile_init_log}
|
||||||
if [ $fastcgi = true ];
|
sudo -u \${user} \${script_path}/seahub.sh start >> \${seahub_init_log}
|
||||||
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)
|
restart)
|
||||||
sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log}
|
sudo -u \${user} \${script_path}/seafile.sh restart >> \${seafile_init_log}
|
||||||
if [ $fastcgi = true ];
|
sudo -u \${user} \${script_path}/seahub.sh restart >> \${seahub_init_log}
|
||||||
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)
|
stop)
|
||||||
sudo -u ${user} ${script_path}/seafile.sh $1 >> ${seafile_init_log}
|
sudo -u \${user} \${script_path}/seafile.sh \$1 >> \${seafile_init_log}
|
||||||
sudo -u ${user} ${script_path}/seahub.sh $1 >> ${seahub_init_log}
|
sudo -u \${user} \${script_path}/seahub.sh \$1 >> \${seahub_init_log}
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: /etc/init.d/seafile-server {start|stop|restart}"
|
echo "Usage: /etc/init.d/seafile-server {start|stop|restart}"
|
||||||
|
|
@ -294,9 +296,8 @@ update-rc.d seafile-server defaults
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Seafile
|
# Seafile
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
adduser --system --gecos "${SEAFILE_USER}" ${SEAFILE_USER} --home /opt/seafile
|
mkdir -p ${SEAFILE_SERVER_HOME}/installed
|
||||||
mkdir -p /opt/seafile/installed
|
cd ${SEAFILE_SERVER_HOME}
|
||||||
cd /opt/seafile/
|
|
||||||
if ! is_pro && [[ ! -e /opt/${SEAFILE_SERVER_PACKAGE} ]]; then
|
if ! is_pro && [[ ! -e /opt/${SEAFILE_SERVER_PACKAGE} ]]; then
|
||||||
curl -OL ${SEAFILE_SERVER_PACKAGE_URL}
|
curl -OL ${SEAFILE_SERVER_PACKAGE_URL}
|
||||||
else
|
else
|
||||||
|
|
@ -310,26 +311,26 @@ mv ${SEAFILE_SERVER_PACKAGE} installed
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Seafile DB
|
# Seafile DB
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
SQLSEAFILEPW=$(pwgen)
|
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 <<EOF
|
cat > /opt/seafile.my.cnf <<EOF
|
||||||
[client]
|
[client]
|
||||||
user=seafile
|
user=seafile
|
||||||
password=$SQLSEAFILEPW
|
password=$SQLSEAFILEPW
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chmod 600 /opt/seafile/.my.cnf
|
chmod 600 /opt/seafile.my.cnf
|
||||||
chown -R ${SEAFILE_USER}.nogroup /opt/seafile/
|
fi
|
||||||
|
|
||||||
mysql -e "CREATE DATABASE IF NOT EXISTS \`ccnet-db\` character set = 'utf8';"
|
|
||||||
mysql -e "CREATE DATABASE IF NOT EXISTS \`seafile-db\` character set = 'utf8';"
|
|
||||||
mysql -e "CREATE DATABASE IF NOT EXISTS \`seahub-db\` character set = 'utf8';"
|
|
||||||
mysql -e "create user 'seafile'@'localhost' identified by '$SQLSEAFILEPW';"
|
|
||||||
mysql -e "GRANT ALL PRIVILEGES ON \`ccnet-db\`.* to \`seafile\`@localhost;"
|
|
||||||
mysql -e "GRANT ALL PRIVILEGES ON \`seafile-db\`.* to \`seafile\`@localhost;"
|
|
||||||
mysql -e "GRANT ALL PRIVILEGES ON \`seahub-db\`.* to \`seafile\`@localhost;"
|
|
||||||
mysql seahub-db < ${INSTALLPATH}/seahub/sql/mysql.sql
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Add seafile user
|
||||||
|
# -------------------------------------------
|
||||||
|
useradd --system --comment "${SEAFILE_SERVER_USER}" ${SEAFILE_SERVER_USER} --home-dir ${SEAFILE_SERVER_HOME}
|
||||||
|
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Go to /opt/seafile/seafile-pro-server-${SEAFILE_VERSION}
|
# Go to /opt/seafile/seafile-pro-server-${SEAFILE_VERSION}
|
||||||
|
|
@ -340,170 +341,54 @@ cd $INSTALLPATH
|
||||||
# Vars - Don't touch these unless you really know what you are doing!
|
# Vars - Don't touch these unless you really know what you are doing!
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
TOPDIR=$(dirname "${INSTALLPATH}")
|
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_CONF_DIR=${TOPDIR}/conf
|
DEFAULT_CONF_DIR=${TOPDIR}/conf
|
||||||
SEAFILE_DATA_DIR=${TOPDIR}/seafile-data
|
SEAFILE_DATA_DIR=${TOPDIR}/seafile-data
|
||||||
LIBRARY_TEMPLATE_DIR=${SEAFILE_DATA_DIR}/library-template
|
|
||||||
DEST_SETTINGS_PY=${TOPDIR}/conf/seahub_settings.py
|
DEST_SETTINGS_PY=${TOPDIR}/conf/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
|
|
||||||
|
|
||||||
mkdir -p ${DEFAULT_CONF_DIR}
|
mkdir -p ${DEFAULT_CONF_DIR}
|
||||||
|
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Create ccnet conf
|
# Create ccnet, seafile, seahub conf using setup script
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
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}" --host "${IP_OR_DOMAIN}" -F "${DEFAULT_CONF_DIR}"
|
|
||||||
|
|
||||||
# Fix service url
|
|
||||||
eval "sed -i 's/^SERVICE_URL.*/SERVICE_URL = http:\/\/${IP_OR_DOMAIN}/' ${DEFAULT_CONF_DIR}/ccnet.conf"
|
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------------
|
|
||||||
# Create seafile conf
|
|
||||||
# -------------------------------------------
|
|
||||||
LD_LIBRARY_PATH=$SEAFILE_LD_LIBRARY_PATH ${SEAF_SERVER_INIT} --seafile-dir "${SEAFILE_DATA_DIR}" \
|
|
||||||
--fileserver-port ${FILESERVER_PORT} -F "${DEFAULT_CONF_DIR}"
|
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------------
|
|
||||||
# Write seafile.ini
|
|
||||||
# -------------------------------------------
|
|
||||||
echo "${SEAFILE_DATA_DIR}" > "${DEFAULT_CCNET_CONF_DIR}/seafile.ini"
|
|
||||||
|
|
||||||
|
./setup-seafile-mysql.sh auto -u seafile -w ${SQLSEAFILEPW} -r ${SQLROOTPW}
|
||||||
|
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Configure Seafile WebDAV Server(SeafDAV)
|
# Configure Seafile WebDAV Server(SeafDAV)
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
cat > ${DEFAULT_CONF_DIR}/seafdav.conf <<EOF
|
sed -i 's/enabled = .*/enabled = true/' ${DEFAULT_CONF_DIR}/seafdav.conf
|
||||||
[WEBDAV]
|
sed -i 's/fastcgi = .*/fastcgi = true/' ${DEFAULT_CONF_DIR}/seafdav.conf
|
||||||
enabled = true
|
sed -i 's/share_name = .*/share_name = \/seafdav/' ${DEFAULT_CONF_DIR}/seafdav.conf
|
||||||
port = 8080
|
|
||||||
fastcgi = true
|
|
||||||
share_name = /seafdav
|
|
||||||
EOF
|
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------------
|
|
||||||
# generate seahub_settings.py
|
|
||||||
# -------------------------------------------
|
|
||||||
key=$(python "${SEAHUB_SECRET_KEYGEN}")
|
|
||||||
echo "SECRET_KEY = \"${key}\"" > "${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_CONF_DIR}/ccnet.conf <<EOF
|
|
||||||
|
|
||||||
[Database]
|
|
||||||
ENGINE = mysql
|
|
||||||
HOST = 127.0.0.1
|
|
||||||
PORT = 3306
|
|
||||||
USER = seafile
|
|
||||||
PASSWD = $SQLSEAFILEPW
|
|
||||||
DB = ccnet-db
|
|
||||||
CONNECTION_CHARSET = utf8
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# -------------------------------------------
|
|
||||||
# Configuring seafile.conf
|
|
||||||
# -------------------------------------------
|
|
||||||
cat >> ${DEFAULT_CONF_DIR}/seafile.conf <<EOF
|
|
||||||
|
|
||||||
[database]
|
|
||||||
type = mysql
|
|
||||||
host = 127.0.0.1
|
|
||||||
port = 3306
|
|
||||||
user = seafile
|
|
||||||
password = $SQLSEAFILEPW
|
|
||||||
db_name = seafile-db
|
|
||||||
connection_charset = utf8
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Configuring seahub_settings.py
|
# Configuring seahub_settings.py
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
cat >> ${DEST_SETTINGS_PY} <<EOF
|
cat >> ${DEST_SETTINGS_PY} <<EOF
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
'ENGINE': 'django.db.backends.mysql',
|
|
||||||
'NAME': 'seahub-db',
|
|
||||||
'USER': 'seafile',
|
|
||||||
'PASSWORD': '$SQLSEAFILEPW',
|
|
||||||
'HOST': '127.0.0.1',
|
|
||||||
'PORT': '3306',
|
|
||||||
'OPTIONS': {
|
|
||||||
'init_command': 'SET storage_engine=INNODB',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CACHES = {
|
CACHES = {
|
||||||
'default': {
|
'default': {
|
||||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
|
||||||
'LOCATION': '127.0.0.1:11211',
|
'LOCATION': '127.0.0.1:11211',
|
||||||
}
|
},
|
||||||
|
'locmem': {
|
||||||
|
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
COMPRESS_CACHE_BACKEND = 'locmem'
|
||||||
|
|
||||||
EMAIL_USE_TLS = False
|
# EMAIL_USE_TLS = False
|
||||||
EMAIL_HOST = 'localhost'
|
# EMAIL_HOST = 'localhost'
|
||||||
EMAIL_HOST_USER = ''
|
# EMAIL_HOST_USER = ''
|
||||||
EMAIL_HOST_PASSWORD = ''
|
# EMAIL_HOST_PASSWORD = ''
|
||||||
EMAIL_PORT = '25'
|
# EMAIL_PORT = '25'
|
||||||
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
|
# DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
|
||||||
SERVER_EMAIL = EMAIL_HOST_USER
|
# SERVER_EMAIL = EMAIL_HOST_USER
|
||||||
|
|
||||||
TIME_ZONE = '${TIME_ZONE}'
|
TIME_ZONE = '${TIME_ZONE}'
|
||||||
SITE_BASE = 'http://${IP_OR_DOMAIN}'
|
SITE_BASE = 'http://${IP_OR_DOMAIN}'
|
||||||
SITE_NAME = 'Seafile Server'
|
SITE_NAME = 'Seafile Server'
|
||||||
SITE_TITLE = 'Seafile Server'
|
SITE_TITLE = 'Seafile Server'
|
||||||
SITE_ROOT = '/'
|
SITE_ROOT = '/'
|
||||||
USE_PDFJS = True
|
|
||||||
ENABLE_SIGNUP = False
|
ENABLE_SIGNUP = False
|
||||||
ACTIVATE_AFTER_REGISTRATION = False
|
ACTIVATE_AFTER_REGISTRATION = False
|
||||||
SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER = True
|
SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER = True
|
||||||
|
|
@ -534,11 +419,15 @@ eval "sed -i 's/= ask_admin_password()/= \"${SEAFILE_ADMIN_PW}\"/' ${INSTALLPATH
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Start and stop Seafile eco system. This generates the initial admin user.
|
# Start and stop Seafile eco system. This generates the initial admin user.
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
${INSTALLPATH}/seafile.sh start
|
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R ${SEAFILE_SERVER_HOME}
|
||||||
${INSTALLPATH}/seahub.sh start
|
|
||||||
${INSTALLPATH}/seahub.sh stop
|
|
||||||
${INSTALLPATH}/seafile.sh stop
|
|
||||||
|
|
||||||
|
su - seafile -c "${INSTALLPATH}/seafile.sh start"
|
||||||
|
su - seafile -c "${INSTALLPATH}/seahub.sh start"
|
||||||
|
wait # sleep for a while, otherwise seahub will not be stopped
|
||||||
|
su - seafile -c "${INSTALLPATH}/seahub.sh stop"
|
||||||
|
sleep 1
|
||||||
|
su - seafile -c "${INSTALLPATH}/seafile.sh stop"
|
||||||
|
sleep 1
|
||||||
|
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Restore original check_init_admin.py
|
# Restore original check_init_admin.py
|
||||||
|
|
@ -547,15 +436,22 @@ mv ${INSTALLPATH}/check_init_admin.py.backup ${INSTALLPATH}/check_init_admin.py
|
||||||
|
|
||||||
if is_pro; then
|
if is_pro; then
|
||||||
PRO_PY=${INSTALLPATH}/pro/pro.py
|
PRO_PY=${INSTALLPATH}/pro/pro.py
|
||||||
$PYTHON ${PRO_PY} setup --mysql --mysql_host=127.0.0.1 --mysql_port=3306 --mysql_user=seafile --mysql_password=${SQLSEAFILEPW} --mysql_db=seahub-db
|
$PYTHON ${PRO_PY} setup --mysql --mysql_host=127.0.0.1 --mysql_port=3306 --mysql_user=seafile --mysql_password=${SQLSEAFILEPW} --mysql_db=seahub_db
|
||||||
sed -i 's/enabled = false/enabled = true/' ${TOPDIR}/conf/seafevents.conf
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# kill all process
|
||||||
|
sleep 1
|
||||||
|
pkill -9 -u seafile
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Fix permissions
|
# Fix permissions
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
chown ${SEAFILE_USER}.nogroup -R /opt/seafile/
|
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R ${SEAFILE_SERVER_HOME}
|
||||||
|
if [[ -d /tmp/seafile-office-output/ ]]; then
|
||||||
|
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R /tmp/seafile-office-output/
|
||||||
|
fi
|
||||||
|
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Start seafile server
|
# Start seafile server
|
||||||
|
|
@ -567,12 +463,11 @@ service seafile-server start
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Final report
|
# Final report
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
cat > ${seafile_dir}/aio_seafile-server.log<<EOF
|
cat > ${TOPDIR}/aio_seafile-server.log<<EOF
|
||||||
|
|
||||||
Your Seafile server is installed
|
Your Seafile server is installed
|
||||||
-----------------------------------------------------------------
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
Server Name: ${SERVER_NAME}
|
|
||||||
Server Address: http://${IP_OR_DOMAIN}
|
Server Address: http://${IP_OR_DOMAIN}
|
||||||
|
|
||||||
Seafile Admin: ${SEAFILE_ADMIN}
|
Seafile Admin: ${SEAFILE_ADMIN}
|
||||||
|
|
@ -580,23 +475,26 @@ cat > ${seafile_dir}/aio_seafile-server.log<<EOF
|
||||||
|
|
||||||
Seafile Data Dir: ${SEAFILE_DATA_DIR}
|
Seafile Data Dir: ${SEAFILE_DATA_DIR}
|
||||||
|
|
||||||
Seafile DB Credentials: Check /opt/seafile/.my.cnf
|
Seafile DB Credentials: Check /opt/seafile.my.cnf
|
||||||
Root DB Credentials: Check /root/.my.cnf
|
Root DB Credentials: Check /root/.my.cnf
|
||||||
|
|
||||||
This report is also saved to ${seafile_dir}/aio_seafile-server.log
|
This report is also saved to ${TOPDIR}/aio_seafile-server.log
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Next you should manually complete the following steps
|
Next you should manually complete the following steps
|
||||||
-----------------------------------------------------------------
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
1) Run seafile-server-change-address to add your Seafile servers DNS name
|
1) Log in to Seafile and configure your server domain via the system
|
||||||
|
admin area if applicable.
|
||||||
|
|
||||||
2) If this server is behind a firewall, you need to ensure that
|
2) If this server is behind a firewall, you need to ensure that
|
||||||
tcp port 80 is open.
|
tcp port 80 is open.
|
||||||
|
|
||||||
3) Seahub tries to send emails via the local server. Install and
|
3) Seahub tries to send emails via the local server. Install and
|
||||||
configure Postfix for this to work.
|
configure Postfix for this to work or
|
||||||
|
check https://manual.seafile.com/config/sending_email.html
|
||||||
|
for instructions on how to use an existing email account via SMTP.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -626,15 +524,13 @@ cat > ${seafile_dir}/aio_seafile-server.log<<EOF
|
||||||
Seafile support options
|
Seafile support options
|
||||||
-----------------------------------------------------------------
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
For free community support visit: https://forum.seafile-server.org
|
For free community support visit: https://bbs.seafile.com
|
||||||
For paid commercial support visit: https://seafile.com
|
For paid commercial support visit: https://seafile.com
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chmod 600 ${seafile_dir}/aio_seafile-server.log
|
chmod 600 ${TOPDIR}/aio_seafile-server.log
|
||||||
chown -R ${SEAFILE_USER}.nogroup ${seafile_dir}/aio_seafile-server.log
|
|
||||||
|
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
|
||||||
cat ${seafile_dir}/aio_seafile-server.log
|
cat ${TOPDIR}/aio_seafile-server.log
|
||||||
|
|
@ -0,0 +1,539 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# seafile-server-installer-cn/seafile-8.0_ubuntu
|
||||||
|
#
|
||||||
|
# Copyright 2015, Alexander Jackson <alexander.jackson@seafile.de>
|
||||||
|
# Copyright 2016, Zheng Xie <xie.zheng@seafile.com>
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
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 <<EOF
|
||||||
|
|
||||||
|
This script installs the community/professional edition of the Seafile Server on a Ubuntu 18.04/20.04 64bit
|
||||||
|
- Newest Seafile server version, MariaDB, Memcached, NGINX -
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
This installer is meant to run on a freshly installed machine
|
||||||
|
only. If you run it on a production server things can and
|
||||||
|
probably will go terribly wrong and you will lose valuable
|
||||||
|
data!
|
||||||
|
|
||||||
|
For questions or suggestions please contact us at
|
||||||
|
support@seafile.com
|
||||||
|
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
Possible options:
|
||||||
|
1 = Seafile Community (Free) Edition (CE)
|
||||||
|
2 = Seafile Professional Edition (PRO)
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [[ ${SEAFILE_PRO} == "" ]]; then
|
||||||
|
PS3="Which Seafile version would you like to install? "
|
||||||
|
select SEAFILE_SERVER_VERSION in CE PRO ABORT; do
|
||||||
|
case "${SEAFILE_SERVER_VERSION}" in
|
||||||
|
ABORT)
|
||||||
|
echo "Aborting"
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"")
|
||||||
|
echo "$REPLY: Wrong value. Select 1 or 2."
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [[ ${SEAFILE_SERVER_VERSION} = "PRO" ]]; then
|
||||||
|
SEAFILE_PRO=1
|
||||||
|
else
|
||||||
|
SEAFILE_PRO=0
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
is_pro() {
|
||||||
|
if [[ "$SEAFILE_PRO" == "1" ]]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
echo
|
||||||
|
if is_pro; then
|
||||||
|
echo "This script will install Seafile Professional Edition for you."
|
||||||
|
else
|
||||||
|
echo "This script will install Seafile Community Edition for you."
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Vars
|
||||||
|
# -------------------------------------------
|
||||||
|
SEAFILE_ADMIN=admin@seafile.local
|
||||||
|
SEAFILE_SERVER_USER=seafile
|
||||||
|
SEAFILE_SERVER_HOME=/opt/seafile
|
||||||
|
IP_OR_DOMAIN=127.0.0.1
|
||||||
|
SEAFILE_VERSION=$1
|
||||||
|
TIME_ZONE=Asia/Shanghai
|
||||||
|
|
||||||
|
if is_pro; then
|
||||||
|
SEAFILE_SERVER_PACKAGE=seafile-pro-server_${SEAFILE_VERSION}_x86-64.tar.gz
|
||||||
|
if [[ ! -e /opt/$SEAFILE_SERVER_PACKAGE ]]; then
|
||||||
|
echo
|
||||||
|
echo "You must download \"$SEAFILE_SERVER_PACKAGE\" to the /opt/ folder before running this script!"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
INSTALLPATH=${SEAFILE_SERVER_HOME}/seafile-pro-server-${SEAFILE_VERSION}/
|
||||||
|
else
|
||||||
|
SEAFILE_SERVER_PACKAGE=seafile-server_${SEAFILE_VERSION}_x86-64.tar.gz
|
||||||
|
SEAFILE_SERVER_PACKAGE_URL=http://seafile-downloads.oss-cn-shanghai.aliyuncs.com/${SEAFILE_SERVER_PACKAGE}
|
||||||
|
INSTALLPATH=${SEAFILE_SERVER_HOME}/seafile-server-${SEAFILE_VERSION}/
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Ensure we are running the installer as root
|
||||||
|
# -------------------------------------------
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
echo " Aborting because you are not root" ; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Abort if directory SEAFILE_SERVER_HOME exists
|
||||||
|
# -------------------------------------------
|
||||||
|
if [[ -d "${SEAFILE_SERVER_HOME}" ]] ;
|
||||||
|
then
|
||||||
|
echo " Aborting because directory ${SEAFILE_SERVER_HOME} already exist" ; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Abort if seafile user exists
|
||||||
|
# -------------------------------------------
|
||||||
|
if getent passwd ${SEAFILE_SERVER_USER} > /dev/null 2>&1 ;
|
||||||
|
then
|
||||||
|
echo "Aborting because user ${SEAFILE_SERVER_USER} already exist" ; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Additional requirements
|
||||||
|
# -------------------------------------------
|
||||||
|
apt-get update
|
||||||
|
|
||||||
|
apt-get install -y python3 python3-setuptools python3-pip python3-ldap memcached openjdk-8-jre \
|
||||||
|
libmemcached-dev libreoffice-script-provider-python libreoffice pwgen curl nginx libmysqlclient-dev
|
||||||
|
|
||||||
|
pip3 install --timeout=3600 django==2.2.* future mysqlclient pymysql Pillow pylibmc captcha markupsafe==2.0.1 jinja2 sqlalchemy==1.4.3 \
|
||||||
|
psd-tools django-pylibmc django-simple-captcha
|
||||||
|
|
||||||
|
|
||||||
|
service memcached start
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Setup Nginx
|
||||||
|
# -------------------------------------------
|
||||||
|
|
||||||
|
rm /etc/nginx/sites-enabled/*
|
||||||
|
|
||||||
|
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 <<EOF
|
||||||
|
[client]
|
||||||
|
user=root
|
||||||
|
password=$SQLROOTPW
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod 600 /root/.my.cnf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Seafile init script
|
||||||
|
# -------------------------------------------
|
||||||
|
cat > /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 <alexander.jackson@seafile.de>
|
||||||
|
|
||||||
|
# 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 <<EOF
|
||||||
|
[client]
|
||||||
|
user=seafile
|
||||||
|
password=$SQLSEAFILEPW
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod 600 /opt/seafile.my.cnf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Add seafile user
|
||||||
|
# -------------------------------------------
|
||||||
|
useradd --system --comment "${SEAFILE_SERVER_USER}" ${SEAFILE_SERVER_USER} --home-dir ${SEAFILE_SERVER_HOME}
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Go to /opt/seafile/seafile-pro-server-${SEAFILE_VERSION}
|
||||||
|
# -------------------------------------------
|
||||||
|
cd $INSTALLPATH
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Vars - Don't touch these unless you really know what you are doing!
|
||||||
|
# -------------------------------------------
|
||||||
|
TOPDIR=$(dirname "${INSTALLPATH}")
|
||||||
|
DEFAULT_CONF_DIR=${TOPDIR}/conf
|
||||||
|
SEAFILE_DATA_DIR=${TOPDIR}/seafile-data
|
||||||
|
DEST_SETTINGS_PY=${TOPDIR}/conf/seahub_settings.py
|
||||||
|
|
||||||
|
mkdir -p ${DEFAULT_CONF_DIR}
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Create ccnet, seafile, seahub conf using setup script
|
||||||
|
# -------------------------------------------
|
||||||
|
|
||||||
|
./setup-seafile-mysql.sh auto -u seafile -w ${SQLSEAFILEPW} -r ${SQLROOTPW}
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Configure Seafile WebDAV Server(SeafDAV)
|
||||||
|
# -------------------------------------------
|
||||||
|
sed -i 's/enabled = .*/enabled = true/' ${DEFAULT_CONF_DIR}/seafdav.conf
|
||||||
|
sed -i 's/share_name = .*/share_name = \/seafdav/' ${DEFAULT_CONF_DIR}/seafdav.conf
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Configuring seahub_settings.py
|
||||||
|
# -------------------------------------------
|
||||||
|
cat >> ${DEST_SETTINGS_PY} <<EOF
|
||||||
|
|
||||||
|
CACHES = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
|
||||||
|
'LOCATION': '127.0.0.1:11211',
|
||||||
|
},
|
||||||
|
'locmem': {
|
||||||
|
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
COMPRESS_CACHE_BACKEND = 'locmem'
|
||||||
|
|
||||||
|
# EMAIL_USE_TLS = False
|
||||||
|
# EMAIL_HOST = 'localhost'
|
||||||
|
# EMAIL_HOST_USER = ''
|
||||||
|
# EMAIL_HOST_PASSWORD = ''
|
||||||
|
# EMAIL_PORT = '25'
|
||||||
|
# DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
|
||||||
|
# SERVER_EMAIL = EMAIL_HOST_USER
|
||||||
|
|
||||||
|
TIME_ZONE = '${TIME_ZONE}'
|
||||||
|
SITE_BASE = 'http://${IP_OR_DOMAIN}'
|
||||||
|
SITE_NAME = 'Seafile Server'
|
||||||
|
SITE_TITLE = 'Seafile Server'
|
||||||
|
SITE_ROOT = '/'
|
||||||
|
ENABLE_SIGNUP = False
|
||||||
|
ACTIVATE_AFTER_REGISTRATION = False
|
||||||
|
SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER = True
|
||||||
|
SEND_EMAIL_ON_RESETTING_USER_PASSWD = True
|
||||||
|
CLOUD_MODE = False
|
||||||
|
FILE_PREVIEW_MAX_SIZE = 30 * 1024 * 1024
|
||||||
|
SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2
|
||||||
|
SESSION_SAVE_EVERY_REQUEST = False
|
||||||
|
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
|
||||||
|
|
||||||
|
FILE_SERVER_ROOT = 'http://${IP_OR_DOMAIN}/seafhttp'
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Backup check_init_admin.py befor applying changes
|
||||||
|
# -------------------------------------------
|
||||||
|
cp ${INSTALLPATH}/check_init_admin.py ${INSTALLPATH}/check_init_admin.py.backup
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Set admin credentials in check_init_admin.py
|
||||||
|
# -------------------------------------------
|
||||||
|
SEAFILE_ADMIN_PW=$(pwgen)
|
||||||
|
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.
|
||||||
|
# -------------------------------------------
|
||||||
|
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R ${SEAFILE_SERVER_HOME}
|
||||||
|
|
||||||
|
su - seafile -c "${INSTALLPATH}/seafile.sh start"
|
||||||
|
wait
|
||||||
|
su - seafile -c "${INSTALLPATH}/seahub.sh start"
|
||||||
|
wait # sleep for a while, otherwise seahub will not be stopped
|
||||||
|
su - seafile -c "${INSTALLPATH}/seahub.sh stop"
|
||||||
|
wait
|
||||||
|
su - seafile -c "${INSTALLPATH}/seafile.sh stop"
|
||||||
|
wait
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Restore original check_init_admin.py
|
||||||
|
# -------------------------------------------
|
||||||
|
mv ${INSTALLPATH}/check_init_admin.py.backup ${INSTALLPATH}/check_init_admin.py
|
||||||
|
|
||||||
|
if is_pro; then
|
||||||
|
PRO_PY=${INSTALLPATH}/pro/pro.py
|
||||||
|
$PYTHON ${PRO_PY} setup --mysql --mysql_host=127.0.0.1 --mysql_port=3306 --mysql_user=seafile --mysql_password=${SQLSEAFILEPW} --mysql_db=seahub_db
|
||||||
|
fi
|
||||||
|
|
||||||
|
# kill all process
|
||||||
|
sleep 1
|
||||||
|
service seafile-server stop
|
||||||
|
wait
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Fix permissions
|
||||||
|
# -------------------------------------------
|
||||||
|
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R ${SEAFILE_SERVER_HOME}
|
||||||
|
if [[ -d /tmp/seafile-office-output/ ]]; then
|
||||||
|
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R /tmp/seafile-office-output/
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Start seafile server
|
||||||
|
# -------------------------------------------
|
||||||
|
echo "Starting productive Seafile server"
|
||||||
|
service seafile-server restart
|
||||||
|
wait
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Final report
|
||||||
|
# -------------------------------------------
|
||||||
|
cat > ${TOPDIR}/aio_seafile-server.log<<EOF
|
||||||
|
|
||||||
|
Your Seafile server is installed
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
Server Address: http://${IP_OR_DOMAIN}
|
||||||
|
|
||||||
|
Seafile Admin: ${SEAFILE_ADMIN}
|
||||||
|
Admin Password: ${SEAFILE_ADMIN_PW}
|
||||||
|
|
||||||
|
Seafile Data Dir: ${SEAFILE_DATA_DIR}
|
||||||
|
|
||||||
|
Seafile DB Credentials: Check /opt/seafile.my.cnf
|
||||||
|
Root DB Credentials: Check /root/.my.cnf
|
||||||
|
|
||||||
|
This report is also saved to ${TOPDIR}/aio_seafile-server.log
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Next you should manually complete the following steps
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
1) Log in to Seafile and configure your server domain via the system
|
||||||
|
admin area if applicable.
|
||||||
|
|
||||||
|
2) If this server is behind a firewall, you need to ensure that
|
||||||
|
tcp port 80 is open.
|
||||||
|
|
||||||
|
3) Check https://manual.seafile.com/config/sending_email/
|
||||||
|
for instructions on how to use an existing email account to send email via SMTP.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Optional steps
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
1) Check seahub_settings.py and customize it to fit your needs. Consult
|
||||||
|
https://manual.seafile.com/config/seahub_settings_py/ for possible switches.
|
||||||
|
|
||||||
|
2) Setup NGINX with official SSL certificate, we suggest you use Let’s Encrypt. Check
|
||||||
|
https://manual.seafile.com/deploy/https_with_nginx/
|
||||||
|
|
||||||
|
3) Secure server with iptables based firewall. For instance: UFW or shorewall
|
||||||
|
|
||||||
|
4) Implement a backup routine for your Seafile server.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Seafile support options
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
For free community support visit: https://bbs.seafile.com
|
||||||
|
For paid commercial support visit: https://seafile.com
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod 600 ${TOPDIR}/aio_seafile-server.log
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
|
cat ${TOPDIR}/aio_seafile-server.log
|
||||||
|
|
@ -0,0 +1,541 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# seafile-server-installer-cn/seafile-9.0_ubuntu
|
||||||
|
#
|
||||||
|
# Copyright 2015, Alexander Jackson <alexander.jackson@seafile.de>
|
||||||
|
# Copyright 2016, Zheng Xie <xie.zheng@seafile.com>
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
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 9.0.0"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
clear
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
This script installs the community/professional edition of the Seafile Server on a Ubuntu 18.04/20.04 64bit
|
||||||
|
- Newest Seafile server version, MariaDB, Memcached, NGINX -
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
This installer is meant to run on a freshly installed machine
|
||||||
|
only. If you run it on a production server things can and
|
||||||
|
probably will go terribly wrong and you will lose valuable
|
||||||
|
data!
|
||||||
|
|
||||||
|
For questions or suggestions please contact us at
|
||||||
|
support@seafile.com
|
||||||
|
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
Possible options:
|
||||||
|
1 = Seafile Community (Free) Edition (CE)
|
||||||
|
2 = Seafile Professional Edition (PRO)
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [[ ${SEAFILE_PRO} == "" ]]; then
|
||||||
|
PS3="Which Seafile version would you like to install? "
|
||||||
|
select SEAFILE_SERVER_VERSION in CE PRO ABORT; do
|
||||||
|
case "${SEAFILE_SERVER_VERSION}" in
|
||||||
|
ABORT)
|
||||||
|
echo "Aborting"
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"")
|
||||||
|
echo "$REPLY: Wrong value. Select 1 or 2."
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [[ ${SEAFILE_SERVER_VERSION} = "PRO" ]]; then
|
||||||
|
SEAFILE_PRO=1
|
||||||
|
else
|
||||||
|
SEAFILE_PRO=0
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
is_pro() {
|
||||||
|
if [[ "$SEAFILE_PRO" == "1" ]]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
echo
|
||||||
|
if is_pro; then
|
||||||
|
echo "This script will install Seafile Professional Edition for you."
|
||||||
|
else
|
||||||
|
echo "This script will install Seafile Community Edition for you."
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Vars
|
||||||
|
# -------------------------------------------
|
||||||
|
SEAFILE_ADMIN=admin@seafile.local
|
||||||
|
SEAFILE_SERVER_USER=seafile
|
||||||
|
SEAFILE_SERVER_HOME=/opt/seafile
|
||||||
|
IP_OR_DOMAIN=127.0.0.1
|
||||||
|
SEAFILE_VERSION=$1
|
||||||
|
TIME_ZONE=Asia/Shanghai
|
||||||
|
|
||||||
|
if is_pro; then
|
||||||
|
SEAFILE_SERVER_PACKAGE=seafile-pro-server_${SEAFILE_VERSION}_x86-64.tar.gz
|
||||||
|
if [[ ! -e /opt/$SEAFILE_SERVER_PACKAGE ]]; then
|
||||||
|
echo
|
||||||
|
echo "You must download \"$SEAFILE_SERVER_PACKAGE\" to the /opt/ folder before running this script!"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
INSTALLPATH=${SEAFILE_SERVER_HOME}/seafile-pro-server-${SEAFILE_VERSION}/
|
||||||
|
else
|
||||||
|
SEAFILE_SERVER_PACKAGE=seafile-server_${SEAFILE_VERSION}_x86-64.tar.gz
|
||||||
|
SEAFILE_SERVER_PACKAGE_URL=http://seafile-downloads.oss-cn-shanghai.aliyuncs.com/${SEAFILE_SERVER_PACKAGE}
|
||||||
|
INSTALLPATH=${SEAFILE_SERVER_HOME}/seafile-server-${SEAFILE_VERSION}/
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Ensure we are running the installer as root
|
||||||
|
# -------------------------------------------
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
echo " Aborting because you are not root" ; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Abort if directory SEAFILE_SERVER_HOME exists
|
||||||
|
# -------------------------------------------
|
||||||
|
if [[ -d "${SEAFILE_SERVER_HOME}" ]] ;
|
||||||
|
then
|
||||||
|
echo " Aborting because directory ${SEAFILE_SERVER_HOME} already exist" ; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Abort if seafile user exists
|
||||||
|
# -------------------------------------------
|
||||||
|
if getent passwd ${SEAFILE_SERVER_USER} > /dev/null 2>&1 ;
|
||||||
|
then
|
||||||
|
echo "Aborting because user ${SEAFILE_SERVER_USER} already exist" ; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Additional requirements
|
||||||
|
# -------------------------------------------
|
||||||
|
apt-get update
|
||||||
|
|
||||||
|
apt-get install -y python3 python3-setuptools python3-pip python3-ldap memcached openjdk-8-jre \
|
||||||
|
libmemcached-dev libreoffice-script-provider-python libreoffice pwgen curl nginx libmysqlclient-dev
|
||||||
|
|
||||||
|
pip3 install --timeout=3600 django==3.2.* future mysqlclient pymysql Pillow==9.4.0 pylibmc captcha markupsafe==2.0.1 jinja2 sqlalchemy==1.4.3 psd-tools django-pylibmc django-simple-captcha pycryptodome==3.12.0 cffi==1.14.0 lxml
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
service memcached start
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Setup Nginx
|
||||||
|
# -------------------------------------------
|
||||||
|
|
||||||
|
rm /etc/nginx/sites-enabled/*
|
||||||
|
|
||||||
|
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 <<EOF
|
||||||
|
[client]
|
||||||
|
user=root
|
||||||
|
password=$SQLROOTPW
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod 600 /root/.my.cnf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Seafile init script
|
||||||
|
# -------------------------------------------
|
||||||
|
cat > /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 <alexander.jackson@seafile.com.de>
|
||||||
|
|
||||||
|
# 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 <<EOF
|
||||||
|
[client]
|
||||||
|
user=seafile
|
||||||
|
password=$SQLSEAFILEPW
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod 600 /opt/seafile.my.cnf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Add seafile user
|
||||||
|
# -------------------------------------------
|
||||||
|
useradd --system --comment "${SEAFILE_SERVER_USER}" ${SEAFILE_SERVER_USER} --home-dir ${SEAFILE_SERVER_HOME}
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Go to /opt/seafile/seafile-pro-server-${SEAFILE_VERSION}
|
||||||
|
# -------------------------------------------
|
||||||
|
cd $INSTALLPATH
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Vars - Don't touch these unless you really know what you are doing!
|
||||||
|
# -------------------------------------------
|
||||||
|
TOPDIR=$(dirname "${INSTALLPATH}")
|
||||||
|
DEFAULT_CONF_DIR=${TOPDIR}/conf
|
||||||
|
SEAFILE_DATA_DIR=${TOPDIR}/seafile-data
|
||||||
|
DEST_SETTINGS_PY=${TOPDIR}/conf/seahub_settings.py
|
||||||
|
|
||||||
|
mkdir -p ${DEFAULT_CONF_DIR}
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Create ccnet, seafile, seahub conf using setup script
|
||||||
|
# -------------------------------------------
|
||||||
|
|
||||||
|
./setup-seafile-mysql.sh auto -u seafile -w ${SQLSEAFILEPW} -r ${SQLROOTPW}
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Configure Seafile WebDAV Server(SeafDAV)
|
||||||
|
# -------------------------------------------
|
||||||
|
sed -i 's/enabled = .*/enabled = true/' ${DEFAULT_CONF_DIR}/seafdav.conf
|
||||||
|
sed -i 's/share_name = .*/share_name = \/seafdav/' ${DEFAULT_CONF_DIR}/seafdav.conf
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Configuring seahub_settings.py
|
||||||
|
# -------------------------------------------
|
||||||
|
cat >> ${DEST_SETTINGS_PY} <<EOF
|
||||||
|
|
||||||
|
CACHES = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
|
||||||
|
'LOCATION': '127.0.0.1:11211',
|
||||||
|
},
|
||||||
|
'locmem': {
|
||||||
|
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
COMPRESS_CACHE_BACKEND = 'locmem'
|
||||||
|
|
||||||
|
# EMAIL_USE_TLS = False
|
||||||
|
# EMAIL_HOST = 'localhost'
|
||||||
|
# EMAIL_HOST_USER = ''
|
||||||
|
# EMAIL_HOST_PASSWORD = ''
|
||||||
|
# EMAIL_PORT = '25'
|
||||||
|
# DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
|
||||||
|
# SERVER_EMAIL = EMAIL_HOST_USER
|
||||||
|
|
||||||
|
TIME_ZONE = '${TIME_ZONE}'
|
||||||
|
SITE_BASE = 'http://${IP_OR_DOMAIN}'
|
||||||
|
SITE_NAME = 'Seafile Server'
|
||||||
|
SITE_TITLE = 'Seafile Server'
|
||||||
|
SITE_ROOT = '/'
|
||||||
|
ENABLE_SIGNUP = False
|
||||||
|
ACTIVATE_AFTER_REGISTRATION = False
|
||||||
|
SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER = True
|
||||||
|
SEND_EMAIL_ON_RESETTING_USER_PASSWD = True
|
||||||
|
CLOUD_MODE = False
|
||||||
|
FILE_PREVIEW_MAX_SIZE = 30 * 1024 * 1024
|
||||||
|
SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2
|
||||||
|
SESSION_SAVE_EVERY_REQUEST = False
|
||||||
|
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
|
||||||
|
|
||||||
|
SERVICE_URL = 'http://${IP_OR_DOMAIN}'
|
||||||
|
FILE_SERVER_ROOT = 'http://${IP_OR_DOMAIN}/seafhttp'
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Backup check_init_admin.py befor applying changes
|
||||||
|
# -------------------------------------------
|
||||||
|
cp ${INSTALLPATH}/check_init_admin.py ${INSTALLPATH}/check_init_admin.py.backup
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Set admin credentials in check_init_admin.py
|
||||||
|
# -------------------------------------------
|
||||||
|
SEAFILE_ADMIN_PW=$(pwgen)
|
||||||
|
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.
|
||||||
|
# -------------------------------------------
|
||||||
|
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R ${SEAFILE_SERVER_HOME}
|
||||||
|
|
||||||
|
su - seafile -c "${INSTALLPATH}/seafile.sh start"
|
||||||
|
wait
|
||||||
|
su - seafile -c "${INSTALLPATH}/seahub.sh start"
|
||||||
|
wait # sleep for a while, otherwise seahub will not be stopped
|
||||||
|
su - seafile -c "${INSTALLPATH}/seahub.sh stop"
|
||||||
|
wait
|
||||||
|
su - seafile -c "${INSTALLPATH}/seafile.sh stop"
|
||||||
|
wait
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Restore original check_init_admin.py
|
||||||
|
# -------------------------------------------
|
||||||
|
mv ${INSTALLPATH}/check_init_admin.py.backup ${INSTALLPATH}/check_init_admin.py
|
||||||
|
|
||||||
|
if is_pro; then
|
||||||
|
PRO_PY=${INSTALLPATH}/pro/pro.py
|
||||||
|
$PYTHON ${PRO_PY} setup --mysql --mysql_host=127.0.0.1 --mysql_port=3306 --mysql_user=seafile --mysql_password=${SQLSEAFILEPW} --mysql_db=seahub_db
|
||||||
|
fi
|
||||||
|
|
||||||
|
# kill all process
|
||||||
|
sleep 1
|
||||||
|
service seafile-server stop
|
||||||
|
wait
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Fix permissions
|
||||||
|
# -------------------------------------------
|
||||||
|
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R ${SEAFILE_SERVER_HOME}
|
||||||
|
if [[ -d /tmp/seafile-office-output/ ]]; then
|
||||||
|
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R /tmp/seafile-office-output/
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Start seafile server
|
||||||
|
# -------------------------------------------
|
||||||
|
echo "Starting productive Seafile server"
|
||||||
|
service seafile-server restart
|
||||||
|
wait
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------------------------
|
||||||
|
# Final report
|
||||||
|
# -------------------------------------------
|
||||||
|
cat > ${TOPDIR}/aio_seafile-server.log<<EOF
|
||||||
|
|
||||||
|
Your Seafile server is installed
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
Server Address: http://${IP_OR_DOMAIN}
|
||||||
|
|
||||||
|
Seafile Admin: ${SEAFILE_ADMIN}
|
||||||
|
Admin Password: ${SEAFILE_ADMIN_PW}
|
||||||
|
|
||||||
|
Seafile Data Dir: ${SEAFILE_DATA_DIR}
|
||||||
|
|
||||||
|
Seafile DB Credentials: Check /opt/seafile.my.cnf
|
||||||
|
Root DB Credentials: Check /root/.my.cnf
|
||||||
|
|
||||||
|
This report is also saved to ${TOPDIR}/aio_seafile-server.log
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Next you should manually complete the following steps
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
1) Log in to Seafile and configure your server domain via the system
|
||||||
|
admin area if applicable.
|
||||||
|
|
||||||
|
2) If this server is behind a firewall, you need to ensure that
|
||||||
|
tcp port 80 is open.
|
||||||
|
|
||||||
|
3) Check https://manual.seafile.com/config/sending_email/
|
||||||
|
for instructions on how to use an existing email account to send email via SMTP.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Optional steps
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
1) Check seahub_settings.py and customize it to fit your needs. Consult
|
||||||
|
https://manual.seafile.com/config/seahub_settings_py/ for possible switches.
|
||||||
|
|
||||||
|
2) Setup NGINX with official SSL certificate, we suggest you use Let’s Encrypt. Check
|
||||||
|
https://manual.seafile.com/deploy/https_with_nginx/
|
||||||
|
|
||||||
|
3) Secure server with iptables based firewall. For instance: UFW or shorewall
|
||||||
|
|
||||||
|
4) Implement a backup routine for your Seafile server.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Seafile support options
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
For free community support visit: https://bbs.seafile.com
|
||||||
|
For paid commercial support visit: https://seafile.com
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod 600 ${TOPDIR}/aio_seafile-server.log
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
|
cat ${TOPDIR}/aio_seafile-server.log
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
#/bin/bash
|
|
||||||
#set -x
|
|
||||||
# -------------------------------------------
|
|
||||||
# Save at /usr/local/sbin/seafile-server-change-address and set permissions with
|
|
||||||
# chmod 600 /usr/local/sbin/seafile-server-change-address
|
|
||||||
# -------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------------
|
|
||||||
# Vars
|
|
||||||
# -------------------------------------------
|
|
||||||
HOSTNAME=$(hostname -f)
|
|
||||||
SEAFILE_DIR=/opt/seafile
|
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------------
|
|
||||||
# Intro
|
|
||||||
# -------------------------------------------
|
|
||||||
clear
|
|
||||||
|
|
||||||
echo "Enter the new IP address or domain"
|
|
||||||
read -e -p "New domain address:" -i " ${HOSTNAME}" URL
|
|
||||||
|
|
||||||
cat <<EOF
|
|
||||||
|
|
||||||
New domain address is: ${URL}
|
|
||||||
|
|
||||||
-------------------------------------------
|
|
||||||
Continue with ENTER. Stop with CTRL-C...
|
|
||||||
|
|
||||||
EOF
|
|
||||||
read dummy
|
|
||||||
clear
|
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------------
|
|
||||||
# Change address in seahub_settings.py und ccnet.conf
|
|
||||||
# -------------------------------------------
|
|
||||||
sed -i "s/^FILE_SERVER_ROOT.*/FILE_SERVER_ROOT = '\http:\/\/${URL}\/seafhttp\'/g" ${SEAFILE_DIR}/seahub_settings.py
|
|
||||||
sed -i "s/^SERVICE_URL.*/SERVICE_URL = http:\/\/${URL}/g" ${SEAFILE_DIR}/ccnet/ccnet.conf
|
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------------
|
|
||||||
# restart seafile-server
|
|
||||||
# -------------------------------------------
|
|
||||||
service seafile-server restart
|
|
||||||
|
|
||||||
|
|
||||||
cat <<EOF
|
|
||||||
|
|
||||||
Finished! The seafile server restarted.
|
|
||||||
|
|
||||||
Now can visit seahub by http://${URL}.
|
|
||||||
|
|
||||||
EOF
|
|
||||||
|
|
@ -1,169 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# seafile-server-installer/startssl-certificate-generator
|
|
||||||
#
|
|
||||||
# Copyright 2015, Alexander Jackson <alexander.jackson@seafile.de>
|
|
||||||
#
|
|
||||||
# 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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#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
|
|
||||||
Loading…
Reference in New Issue