for pro-7.0.0

This commit is contained in:
Hulk 2019-05-17 16:31:34 +08:00
parent 3ab63f30e7
commit 11830e8bba
2 changed files with 122 additions and 82 deletions

View File

@ -30,7 +30,7 @@ set -e
if [[ "$#" -ne 1 ]]; then
echo "You must specif Seafile version to install"
echo "Like: $0 4.4.2"
echo "Like: $0 7.0.0"
exit 1
fi
@ -99,6 +99,8 @@ 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
@ -111,11 +113,11 @@ if is_pro; then
echo
exit 1
fi
INSTALLPATH=/opt/seafile/seafile-pro-server-${SEAFILE_VERSION}/
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=/opt/seafile/seafile-server-${SEAFILE_VERSION}/
INSTALLPATH=${SEAFILE_SERVER_HOME}/seafile-server-${SEAFILE_VERSION}/
fi
@ -130,9 +132,17 @@ fi
# -------------------------------------------
# Abort if directory /opt/seafile/ exists
# -------------------------------------------
if [[ -d "/opt/seafile/" ]] ;
if [[ -d "${SEAFILE_SERVER_HOME}" ]] ;
then
echo " Aborting because directory /opt/seafile/ already exist" ; exit 1
echo " Aborting because directory ${SEAFILE_SERVER_HOME} already exist" ; exit 1
fi
# -------------------------------------------
# Abort if directory /opt/seafile/ exists
# -------------------------------------------
if getent passwd ${SEAFILE_SERVER_USER} > /dev/null 2>&1 ;
then
echo "Aborting because user ${SEAFILE_SERVER_USER} already exist" ; exit 1
fi
# -------------------------------------------
@ -162,7 +172,7 @@ systemctl status firewalld &> /dev/null \
yum install epel-release -y
yum upgrade -y
yum install python-setuptools MySQL-python memcached python-urllib3 \
pwgen curl openssl python-ldap java-1.7.0-openjdk poppler-utils libreoffice python-requests \
pwgen curl openssl python-ldap java-1.8.0-openjdk poppler-utils libreoffice python-requests \
libreoffice-headless libreoffice-pyuno wqy-microhei-fonts wqy-zenhei-fonts wqy-unibit-fonts \
gcc libffi-devel python-devel openssl-devel libmemcached libmemcached-devel python2-pip -y
pip install pylibmc==1.6.0 django-pylibmc==0.6.1
@ -179,20 +189,20 @@ yum install nginx -y
systemctl enable nginx
rm -rf /etc/nginx/conf.d/*
cat > /etc/nginx/conf.d/seafile.conf <<'EOF'
cat > /etc/nginx/conf.d/seafile.conf << EOF
server {
listen 80;
server_name seafile.example.com;
proxy_set_header X-Forwarded-For $remote_addr;
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_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
@ -203,30 +213,30 @@ server {
}
location /seafhttp {
rewrite ^/seafhttp(.*)$ $1 break;
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_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_connect_timeout 36000s;
proxy_read_timeout 36000s;
proxy_request_buffering off;
}
location /media {
root /opt/seafile/seafile-server-latest/seahub;
root ${SEAFILE_SERVER_HOME}/seafile-server-latest/seahub;
}
location /seafdav {
fastcgi_pass 127.0.0.1:8080;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_param PATH_INFO \$fastcgi_script_name;
fastcgi_param SERVER_PROTOCOL \$server_protocol;
fastcgi_param QUERY_STRING \$query_string;
fastcgi_param REQUEST_METHOD \$request_method;
fastcgi_param CONTENT_TYPE \$content_type;
fastcgi_param CONTENT_LENGTH \$content_length;
fastcgi_param SERVER_ADDR \$server_addr;
fastcgi_param SERVER_PORT \$server_port;
fastcgi_param SERVER_NAME \$server_name;
fastcgi_param REMOTE_ADDR \$remote_addr;
client_max_body_size 0;
@ -282,6 +292,11 @@ http {
include /etc/nginx/conf.d/*.conf;
}
ENDOFFILE
# Fix NGINX worker_processes to number of CPU cores
CPUS=$(cat /proc/cpuinfo | grep processor | wc | awk '{ print $1 }')
eval "sed -i 's/worker_processes.*/worker_processes $CPUS;/g' /etc/nginx/nginx.conf"
systemctl restart nginx
# -------------------------------------------
@ -313,34 +328,34 @@ fi
# -------------------------------------------
# Seafile init script
# -------------------------------------------
cat > /etc/systemd/system/seafile.service <<'EOF'
cat > /etc/systemd/system/seafile.service << EOF
[Unit]
Description=Seafile Server
After=network.target mariadb.service
[Service]
ExecStart=${SEAFILE_SERVER_HOME}/seafile-server-latest/seafile.sh start
ExecStop=${SEAFILE_SERVER_HOME}/seafile-server-latest/seafile.sh stop
User=${SEAFILE_SERVER_USER}
Group=${SEAFILE_SERVER_USER}
Type=oneshot
ExecStart=/opt/seafile/seafile-server-latest/seafile.sh start
ExecStop=/opt/seafile/seafile-server-latest/seafile.sh stop
RemainAfterExit=yes
User=root
Group=root
[Install]
WantedBy=multi-user.target
EOF
systemctl enable seafile
cat > /etc/systemd/system/seahub.service <<'EOF'
cat > /etc/systemd/system/seahub.service << EOF
[Unit]
Description=Seafile Seahub
After=network.target seafile.service
[Service]
ExecStart=/opt/seafile/seafile-server-latest/seahub.sh start 8000
ExecStop=/opt/seafile/seafile-server-latest/seahub.sh stop
User=root
Group=root
ExecStart=${SEAFILE_SERVER_HOME}/seafile-server-latest/seahub.sh start
ExecStop=${SEAFILE_SERVER_HOME}/seafile-server-latest/seahub.sh stop
User=${SEAFILE_SERVER_USER}
Group=${SEAFILE_SERVER_USER}
Type=oneshot
RemainAfterExit=yes
@ -363,8 +378,8 @@ chmod 700 /usr/local/sbin/seafile-server-restart
# -------------------------------------------
# Seafile
# -------------------------------------------
mkdir -p /opt/seafile/installed
cd /opt/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
@ -394,6 +409,11 @@ 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}
# -------------------------------------------
@ -499,6 +519,12 @@ if is_pro; then
$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
# -------------------------------------------
# Fix permissions
# -------------------------------------------
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R ${SEAFILE_SERVER_HOME}
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R /tmp/seafile-office-output/
# -------------------------------------------
# Restart seafile server
# -------------------------------------------

View File

@ -31,7 +31,7 @@ set -e
if [[ "$#" -ne 1 ]]; then
echo "You must specif Seafile version to install"
echo "Like: $0 4.4.2"
echo "Like: $0 7.0.0"
exit 1
fi
@ -100,6 +100,8 @@ 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
@ -112,11 +114,11 @@ if is_pro; then
echo
exit 1
fi
INSTALLPATH=/opt/seafile/seafile-pro-server-${SEAFILE_VERSION}/
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=/opt/seafile/seafile-server-${SEAFILE_VERSION}/
INSTALLPATH=${SEAFILE_SERVER_HOME}/seafile-server-${SEAFILE_VERSION}/
fi
@ -129,11 +131,11 @@ fi
# -------------------------------------------
# Abort if directory /opt/seafile/ exists
# Abort if directory SEAFILE_SERVER_HOME exists
# -------------------------------------------
if [[ -d "/opt/seafile/" ]] ;
if [[ -d "${SEAFILE_SERVER_HOME}" ]] ;
then
echo " Aborting because directory /opt/seafile/ already exist" ; exit 1
echo " Aborting because directory ${SEAFILE_SERVER_HOME} already exist" ; exit 1
fi
# -------------------------------------------
@ -150,20 +152,20 @@ pip install psd-tools==1.4
rm /etc/nginx/sites-enabled/*
cat > /etc/nginx/sites-available/seafile.conf <<'EOF'
cat > /etc/nginx/sites-available/seafile.conf << EOF
server {
listen 80;
server_name seafile.example.com;
proxy_set_header X-Forwarded-For $remote_addr;
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_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
@ -174,30 +176,30 @@ server {
}
location /seafhttp {
rewrite ^/seafhttp(.*)$ $1 break;
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_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_connect_timeout 36000s;
proxy_read_timeout 36000s;
proxy_request_buffering off;
}
location /media {
root /opt/seafile/seafile-server-latest/seahub;
root ${SEAFILE_SERVER_HOME}/seafile-server-latest/seahub;
}
location /seafdav {
fastcgi_pass 127.0.0.1:8080;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_param PATH_INFO \$fastcgi_script_name;
fastcgi_param SERVER_PROTOCOL \$server_protocol;
fastcgi_param QUERY_STRING \$query_string;
fastcgi_param REQUEST_METHOD \$request_method;
fastcgi_param CONTENT_TYPE \$content_type;
fastcgi_param CONTENT_LENGTH \$content_length;
fastcgi_param SERVER_ADDR \$server_addr;
fastcgi_param SERVER_PORT \$server_port;
fastcgi_param SERVER_NAME \$server_name;
fastcgi_param REMOTE_ADDR \$remote_addr;
client_max_body_size 0;
@ -238,12 +240,12 @@ fi
# -------------------------------------------
# Seafile init script
# -------------------------------------------
cat > /etc/init.d/seafile-server <<'EOF'
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
# 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
@ -253,24 +255,25 @@ cat > /etc/init.d/seafile-server <<'EOF'
# Author: Alexander Jackson <alexander.jackson@seafile.com.de>
# Change the value of "seafile_dir" to your path of seafile installation
seafile_dir=/opt/seafile
script_path=${seafile_dir}/seafile-server-latest
seafile_init_log=${seafile_dir}/logs/seafile.init.log
seahub_init_log=${seafile_dir}/logs/seahub.init.log
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
case "\$1" in
start)
${script_path}/seafile.sh start >> ${seafile_init_log}
${script_path}/seahub.sh start >> ${seahub_init_log}
sudo -u \${user} \${script_path}/seafile.sh start >> \${seafile_init_log}
sudo -u \${user} \${script_path}/seahub.sh start >> \${seahub_init_log}
;;
restart)
${script_path}/seafile.sh restart >> ${seafile_init_log}
${script_path}/seahub.sh restart >> ${seahub_init_log}
sudo -u \${user} \${script_path}/seafile.sh restart >> \${seafile_init_log}
sudo -u \${user} \${script_path}/seahub.sh restart >> \${seahub_init_log}
;;
stop)
${script_path}/seafile.sh $1 >> ${seafile_init_log}
${script_path}/seahub.sh $1 >> ${seahub_init_log}
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}"
@ -286,8 +289,8 @@ update-rc.d seafile-server defaults
# -------------------------------------------
# Seafile
# -------------------------------------------
mkdir -p /opt/seafile/installed
cd /opt/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
@ -317,6 +320,11 @@ 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}
# -------------------------------------------
@ -422,6 +430,12 @@ if is_pro; then
$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
# -------------------------------------------
# Fix permissions
# -------------------------------------------
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R ${SEAFILE_SERVER_HOME}
chown ${SEAFILE_SERVER_USER}:${SEAFILE_SERVER_USER} -R /tmp/seafile-office-output/
# -------------------------------------------
# Start seafile server
# -------------------------------------------