Commit 7c205ba7 authored by anderson's avatar anderson

update

parent 1b247749
FROM amd64/nginx:latest
ENV SEAFILE_DOWNLOAD=https://download.seafile.com/d/6e5297246c/files \
SEAFILE_SERVER_STATUS=/opt/seafile/server-status \
SEAFILE_SERVER_STATUS=/opt/seafile/seafile-server.ini \
SEAFILE_ADDRESS= \
DEBIAN_FRONTEND=noninteractive \
DEBBASE_TIMEZONE=America/Sao_Paulo
......@@ -36,7 +36,7 @@ ADD conf/nginx /etc/nginx/conf.d/default.conf
RUN mkdir -p /opt/seafile; \
useradd -d /opt/seafile -M -s /bin/bash -c "Seafile User" seafile; \
chown -R seafile:seafile /opt/seafile -R; \
chown -R seafile:seafile /opt/seafile /cloud -R; \
chmod 777 /usr/local/bin/*
EXPOSE 80
......
#!/bin/bash
#!/usr/bin/dumb-init /bin/bash
set -e
set -u
set -o pipefail
......@@ -9,7 +10,12 @@ if [ -n "$DEBBASE_TIMEZONE" ]; then
cp -v "/usr/share/zoneinfo/$DEBBASE_TIMEZONE" /etc/localtime
fi
seafile_setenv() {
if [ ${SEAFILE_VERSION} == "" ]
then
echo "Error.. No seafile version env!"
exit 3
fi
BASEPATH=${BASEPATH:-"/opt/seafile"}
DATADIR=${DATADIR:-"/cloud"}
......@@ -20,14 +26,6 @@ SEAFILE_DATA_DIR=${SEAFILE_DATA_DIR:-"${DATADIR}/seafile-data"}
SEAFILE_PORT=${SEAFILE_PORT:-8082}
SEAFILE=${SEAFILE:-"$(echo $INSTALLPATH | grep -oE 'seafile-[pro-server]+')"}
prepare_env
if [ ${SEAFILE_VERSION} == "" ]
then
echo "Error.. No seafile version env!"
exit 3
fi
SEAHUB_DB_DIR=${SEAHUB_DB_DIR:-}
SEAHUB=${SEAHUB:-"${INSTALLPATH}/seahub"}
SEAHUB_EXT=${SEAHUB_EXT:-}
......@@ -40,10 +38,17 @@ else
SEAHUB_EXT=${SEAHUB_EXT:-"seahub-pro"}
fi
seafile_version
}
cat << _EOF_ > /tmp/seafile.env
export LANG='pt_BR.UTF-8'
export LC_ALL='pt_BR.UTF-8'
export CCNET_CONF_DIR="${BASEPATH}/ccnet"
export SEAFILE_CONF_DIR="${SEAFILE_DATA_DIR}"
export SEAFILE_CENTRAL_CONF_DIR="${BASEPATH}/conf"
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python2.6/site-packages:${INSTALLPATH}/seafile/lib64/python2.6/site-packages:${INSTALLPATH}/seahub:${INSTALLPATH}/seahub/thirdpart:${INSTALLPATH}/seafile/lib/python2.7/site-packages:${INSTALLPATH}/seafile/lib64/python2.7/site-packages:${PYTHONPATH:-}
export SEAFILE_SERVER_PATH=/opt/seafile/seafile-pro-server-${SEAFILE_VERSION}
_EOF_
seafile_version(){
check_seafile(){
crudini --set ${SEAFILE_SERVER_STATUS} seafile-server VERSION ${SEAFILE_VERSION}
if [ ! -e ${SEAFILE_SERVER_STATUS} ]
......@@ -52,7 +57,7 @@ then
else
if [ ! -d ${INSTALLPATH} ]
then
crudini --set ${SEAFILE_SERVER_STATUS} seafile-server DOWNLOADED false
download_seafile
else
crudini --set ${SEAFILE_SERVER_STATUS} seafile-server DOWNLOADED true
fi
......@@ -82,30 +87,24 @@ then
rm -rf ${DATADIR}/${SEAHUB_EXT}
move_and_link
chown seafile:seafile ${DATADIR}/${SEAHUB_EXT} -R
else
DOWNLOADED=`crudini --get ${SEAFILE_SERVER_STATUS} seafile-server DOWNLOADED`
if [ ${DOWNLOADED} == "false" ]
then
echo; echo "seafile server not found!"; echo "Downloading... ${SEAFILE} v${SEAFILE_VERSION}"; echo; sleep 2
download_seafile
fi
fi
fi
crudini --set ${SEAFILE_SERVER_STATUS} seafile-server VERSION ${SEAFILE_VERSION}
# crudini --set ${SEAFILE_SERVER_STATUS} seafile-server VERSION ${SEAFILE_VERSION}
}
download_seafile(){
if [ ! -d ${SEAFILE_SERVER_PATH} ]
then
mkdir ${SEAFILE_SERVER_PATH}
fi
SEAFILE_TARGZ="seafile-pro-server_"${SEAFILE_VERSION}"_x86-64.tar.gz&dl=1"
echo "Download Seafile link: "${SEAFILE_DOWNLOAD}"/?p=/pro/seafile-pro-server_"${SEAFILE_VERSION}"_x86-64.tar.gz&dl=1"
if [ ! -d ${SEAFILE_SERVER_PATH} ]
then
mkdir ${SEAFILE_SERVER_PATH}
fi
SEAFILE_TARGZ="seafile-pro-server_"${SEAFILE_VERSION}"_x86-64.tar.gz&dl=1"
echo; echo "seafile server not found!"; echo "Downloading... ${SEAFILE} v${SEAFILE_VERSION}";
echo "Download Seafile link: "${SEAFILE_DOWNLOAD}"/?p=/pro/seafile-pro-server_"${SEAFILE_VERSION}"_x86-64.tar.gz&dl=1"; sleep 2; echo
sync; wget -O - ${SEAFILE_DOWNLOAD}/?p=/pro/${SEAFILE_TARGZ} | tar xzf - --strip-components=1 -C ${SEAFILE_SERVER_PATH};
sync; wget -O - ${SEAFILE_DOWNLOAD}/?p=/pro/${SEAFILE_TARGZ} | tar xzf - --strip-components=1 -C ${SEAFILE_SERVER_PATH};
crudini --set ${SEAFILE_SERVER_STATUS} seafile-server DOWNLOADED true
chown seafile:seafile ${SEAFILE_SERVER_PATH} -R
crudini --set ${SEAFILE_SERVER_STATUS} seafile-server DOWNLOADED true
chown seafile:seafile ${SEAFILE_SERVER_PATH} -R
}
trapped() {
......@@ -116,7 +115,7 @@ trapped() {
autorun() {
# If there's an existing seafile config, link the dirs
move_and_link
# Try an initial setup on error
if [ ${INSTALLED} == "false" ]
then
......@@ -323,52 +322,35 @@ fi
ln -sf ${DATADIR}/${SEAHUB_EXT} ${SEAHUB}
}
control_nginx() {
echo "root "${SEAHUB}";" > /tmp/seahub_location.conf
echo "Starting nginx..."
nginx -g "daemon off;" &
sync; sleep 2
}
keep_in_foreground() {
echo; echo "Seafile Server Path: ${SEAFILE_SERVER_PATH}"
cat ${SEAFILE_SERVER_STATUS}
echo
echo 'crontab daily GC'
ln -sf ${INSTALLPATH}/seaf-gc.sh /usr/local/bin/seaf-gc
echo '0 3 * * * seafile seaf-gc' > /etc/cron.d/seafile-gc
control_nginx
while sleep 60; do
ps aux |grep nginx |grep -q -v grep
PROCESS_1_STATUS=$?
ps aux |grep seaf-server |grep -q -v grep
PROCESS_2_STATUS=$?
ps aux |grep ccnet-server |grep -q -v grep
PROCESS_3_STATUS=$?
if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 -o $PROCESS_3_STATUS -ne 0 ]; then
echo "One of the processes has already exited."
exit 1
fi
done
}
prepare_env() {
cat << _EOF_ > /tmp/seafile.env
export LANG='pt_BR.UTF-8'
export LC_ALL='pt_BR.UTF-8'
export CCNET_CONF_DIR="${BASEPATH}/ccnet"
export SEAFILE_CONF_DIR="${SEAFILE_DATA_DIR}"
export SEAFILE_CENTRAL_CONF_DIR="${BASEPATH}/conf"
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python2.6/site-packages:${INSTALLPATH}/seafile/lib64/python2.6/site-packages:${INSTALLPATH}/seahub:${INSTALLPATH}/seahub/thirdpart:${INSTALLPATH}/seafile/lib/python2.7/site-packages:${INSTALLPATH}/seafile/lib64/python2.7/site-packages:${PYTHONPATH:-}
export SEAFILE_SERVER_PATH=/opt/seafile/seafile-pro-server-${SEAFILE_VERSION}
_EOF_
keep_in_foreground() {
echo; echo "Seafile Server Path: ${SEAFILE_SERVER_PATH}"
cat ${SEAFILE_SERVER_STATUS}
echo
ln -sf ${INSTALLPATH}/seaf-gc.sh /usr/local/bin/seaf-gc
echo '0 3 * * * seafile seaf-gc' > /etc/cron.d/seafile-gc
echo "Starting Cron"; echo "Enable Garbage Collection [seaf-gc] 3:00am"; echo
/etc/init.d/cron start
echo "Starting nginx..."; echo
echo "root "${SEAHUB}";" > /tmp/seahub_location.conf
nginx -g "daemon off;" &
sync; sleep 2
while sleep 60; do
ps aux |grep nginx |grep -q -v grep
PROCESS_1_STATUS=$?
ps aux |grep seaf-server |grep -q -v grep
PROCESS_2_STATUS=$?
ps aux |grep ccnet-server |grep -q -v grep
PROCESS_3_STATUS=$?
if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 -o $PROCESS_3_STATUS -ne 0 ]; then
echo "One of the processes has already exited."
exit 1
fi
done
}
prepare_seafdav() {
......@@ -382,7 +364,7 @@ fastcgi = true
EOL
}
seafile_setenv
check_seafile
# Fill vars with defaults if empty
MODE=${1:-"run"}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment