This commit is contained in:
parent
605b76798a
commit
e0491a5b45
@ -1,6 +1,6 @@
|
|||||||
FROM rust:1.34 AS riffol_build
|
FROM rust:1.34 AS riffol_build
|
||||||
|
|
||||||
RUN cargo install --git https:/github.com/riboseinc/riffol
|
RUN cargo install riffol
|
||||||
|
|
||||||
FROM nginx:mainline
|
FROM nginx:mainline
|
||||||
|
|
||||||
@ -27,7 +27,6 @@ COPY --from=riffol_build /usr/local/cargo/bin/riffol /usr/sbin/
|
|||||||
|
|
||||||
RUN ln -s /opt/seafile/seafile-server-latest/seafile.sh /usr/bin/seafile && \
|
RUN ln -s /opt/seafile/seafile-server-latest/seafile.sh /usr/bin/seafile && \
|
||||||
ln -s /opt/seafile/seafile-server-latest/seahub.sh /usr/bin/seahub && \
|
ln -s /opt/seafile/seafile-server-latest/seahub.sh /usr/bin/seahub && \
|
||||||
mkdir -p /var/run/seafile && \
|
|
||||||
ln -s /opt/seafile/pids /var/run/seafile
|
ln -s /opt/seafile/pids /var/run/seafile
|
||||||
|
|
||||||
COPY riffol.conf /etc/riffol.conf
|
COPY riffol.conf /etc/riffol.conf
|
||||||
|
17
riffol.conf
17
riffol.conf
@ -35,31 +35,48 @@ application setup {
|
|||||||
pass {
|
pass {
|
||||||
SEAF_UPGRADE_INTERVAL SEAF_UPGRADE_INTERVAL
|
SEAF_UPGRADE_INTERVAL SEAF_UPGRADE_INTERVAL
|
||||||
SEAF_VERSION SEAF_VERSION
|
SEAF_VERSION SEAF_VERSION
|
||||||
|
SEAF_NAME SEAF_NAME
|
||||||
|
SEAF_MYSQL SEAF_MYSQL
|
||||||
|
SEAF_MYSQL_HOST SEAF_MYSQL_HOST
|
||||||
|
SEAF_MYSQL_PORT SEAF_MYSQL_PORT
|
||||||
|
SEAF_MYSQL_USER SEAF_MYSQL_USER
|
||||||
|
SEAF_MYSQL_DB_SEAF SEAF_MYSQL_DB_SEAF
|
||||||
|
SEAF_MYSQL_DB_HUB SEAF_MYSQL_DB_HUB
|
||||||
|
SEAF_MYSQL_DB_CCNET SEAF_MYSQL_DB_CCNET
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
application seafile {
|
application seafile {
|
||||||
mode forking
|
mode forking
|
||||||
|
pidfile /var/run/seafile/seaf-server.pid
|
||||||
requires [ setup ]
|
requires [ setup ]
|
||||||
start [ /usr/bin/seafile, start ]
|
start [ /usr/bin/seafile, start ]
|
||||||
stop [ /usr/bin/seafile, stop ]
|
stop [ /usr/bin/seafile, stop ]
|
||||||
dir /opt/seafile
|
dir /opt/seafile
|
||||||
|
healthcheck [ server ]
|
||||||
|
healthcheckfail restart
|
||||||
}
|
}
|
||||||
|
|
||||||
application seahub {
|
application seahub {
|
||||||
mode forking
|
mode forking
|
||||||
requires [ setup ]
|
requires [ setup ]
|
||||||
|
pidfile /var/run/seafile/seahub.pid
|
||||||
start [ /usr/bin/seahub, start, 8000 ]
|
start [ /usr/bin/seahub, start, 8000 ]
|
||||||
stop [ /usr/bin/seahub, stop ]
|
stop [ /usr/bin/seahub, stop ]
|
||||||
dir /opt/seafile
|
dir /opt/seafile
|
||||||
|
healthcheck [ hub ]
|
||||||
|
healthcheckfail restart
|
||||||
}
|
}
|
||||||
|
|
||||||
application nginx {
|
application nginx {
|
||||||
mode forking
|
mode forking
|
||||||
|
pidfile /var/run/nginx.pid
|
||||||
requires [ setup, seahub ]
|
requires [ setup, seahub ]
|
||||||
start [ /usr/sbin/nginx ]
|
start [ /usr/sbin/nginx ]
|
||||||
dir /opt/seafile
|
dir /opt/seafile
|
||||||
|
healthcheck [ http, hub ]
|
||||||
|
healthcheckfail restart
|
||||||
}
|
}
|
||||||
|
|
||||||
healthchecks riffol {
|
healthchecks riffol {
|
||||||
|
@ -1,194 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
LATEST=$SEAF/seafile-server-latest
|
|
||||||
PIDS=$SEAF/pids
|
|
||||||
PIDFILES=("$PIDS" "$LATEST/runtime" "/var/run/nginx")
|
|
||||||
COMMANDS=("seaf-server $LATEST/seafile.sh start" "seahub $LATEST/seahub.sh ${SEAF_HUB_MODE:-start} 8000" "nginx /usr/sbin/nginx")
|
|
||||||
|
|
||||||
function stop {
|
|
||||||
#Kill when hitting CTRL+C repeatedly
|
|
||||||
trap stop_kill SIGTERM
|
|
||||||
$0 stop
|
|
||||||
}
|
|
||||||
function stop_kill {
|
|
||||||
$0 kill
|
|
||||||
}
|
|
||||||
function ext_url {
|
|
||||||
echo "${SEAF_URL:-http://$(hostname)}/seafhttp"
|
|
||||||
}
|
|
||||||
function patch_seahub_conf {
|
|
||||||
KEY="FILE_SERVER_ROOT"
|
|
||||||
ENTRY="$KEY = '$(ext_url)'"
|
|
||||||
CONF="$SEAF/conf/seahub_settings.py"
|
|
||||||
grep "$KEY" -i "$CONF"
|
|
||||||
if [ $? -eq 1 ]; then
|
|
||||||
echo "Patched seahub_settings.py: set $ENTRY"
|
|
||||||
echo -e "\n$ENTRY" >> "$CONF"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function last_update {
|
|
||||||
if [ -e "$LATEST/install_date" ]; then
|
|
||||||
date -d $(cat "$LATEST/install_date") "+%s"
|
|
||||||
else
|
|
||||||
echo 0
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function pid {
|
|
||||||
for LOC in ${PIDFILES[@]}; do
|
|
||||||
if [ -e "$LOC/$1.pid" ]; then
|
|
||||||
cat "$LOC/$1.pid"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
pgrep -f "/$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
run)
|
|
||||||
if [ ! -e "$LATEST" ]; then
|
|
||||||
(>&2 echo This appears to be the fist run, installing..)
|
|
||||||
mkdir -p $SEAF/conf
|
|
||||||
cp /etc/seafile/* $SEAF/conf/* -rf
|
|
||||||
$0 run-upgrade
|
|
||||||
exit $?
|
|
||||||
else
|
|
||||||
patch_seahub_conf
|
|
||||||
for CMD in "${COMMANDS[@]}"; do
|
|
||||||
INFO=($CMD)
|
|
||||||
$0 manage-component "${INFO[0]}" start "${INFO[1]}" "${INFO[@]:2}"
|
|
||||||
done
|
|
||||||
wait
|
|
||||||
fi
|
|
||||||
trap stop SIGINT SIGQUIT SIGTERM
|
|
||||||
LAST_UPGRADE=$(last_update)
|
|
||||||
UPGRADE=0
|
|
||||||
while eval "$0 status > /dev/null"; do
|
|
||||||
sleep 10;
|
|
||||||
SINCE_UPGRADE=$(((($(date "+%s") - $LAST_UPGRADE))/(60*60*24)))
|
|
||||||
if [ $LAST_UPGRADE -gt 0 ] && [ "0$SEAF_UPGRADE_INTERVAL" -gt 0 ] && [ $SINCE_UPGRADE -gt "0$SEAF_UPGRADE_INTERVAL" ]; then
|
|
||||||
echo "It's been $SINCE_UPGRADE days since the last Upgrade\nSTOPPING TO PERFORM UPGRADE NOW\nSet SEAF_UPGRADE_INTERVAL=0 disable automatic updates"
|
|
||||||
UPGRADE=1
|
|
||||||
$0 stop
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ $UPGRADE -eq 1 ]; then
|
|
||||||
$0 stop-upgrade-run
|
|
||||||
else
|
|
||||||
echo "Terminated"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
run-upgrade)
|
|
||||||
$0 upgrade
|
|
||||||
RES=$?
|
|
||||||
if [ $RES -eq 1 ]; then
|
|
||||||
echo "Failed upgrade"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ $RES -eq 127 ]; then
|
|
||||||
#No upgrade
|
|
||||||
true
|
|
||||||
fi
|
|
||||||
if [ $RES -eq 126 ] && [ ! -e "$LATEST/install_date" ]; then
|
|
||||||
date +%Y-%m-%d > "$LATEST/install_date"
|
|
||||||
fi
|
|
||||||
$0 run
|
|
||||||
;;
|
|
||||||
stop)
|
|
||||||
PIDS=""
|
|
||||||
for CMD in seafile-controller ccnet seafdav "${COMMANDS[@]}" seafile-controller ccnet; do
|
|
||||||
$0 manage-component $(echo $CMD | cut -d' ' -f1) stop &
|
|
||||||
PIDS="$PIDS $!"
|
|
||||||
done
|
|
||||||
wait $PIDS
|
|
||||||
;;
|
|
||||||
kill)
|
|
||||||
export SEAF_STOP_TRIES=0
|
|
||||||
$0 stop
|
|
||||||
;;
|
|
||||||
stop-upgrade-run)
|
|
||||||
$0 stop && $0 upgrade && $0 run
|
|
||||||
;;
|
|
||||||
upgrade)
|
|
||||||
/usr/local/sbin/upgrade main
|
|
||||||
kill -SIGHUP $(pgrep -o nginx) #Reload nginx
|
|
||||||
;;
|
|
||||||
maintanance)
|
|
||||||
$0 stop
|
|
||||||
if [ "$2" = "--fsck" ]; then
|
|
||||||
$LATEST/seaf-fsck.sh
|
|
||||||
fi
|
|
||||||
if [ "$2" = "--fsck-repair" ]; then
|
|
||||||
$LATEST/seaf-fsck.sh --repair
|
|
||||||
fi
|
|
||||||
$LATEST/seaf-gc.sh
|
|
||||||
$0 start
|
|
||||||
;;
|
|
||||||
setup)
|
|
||||||
INSTALLDIR=$2
|
|
||||||
SETUP_ARGS="auto -n ${SEAF_NAME:-$(hostname)} -i $(hostname) -p 8082"
|
|
||||||
if [ ! -z "$SEAF_MYSQL" ]; then
|
|
||||||
$INSTALLDIR/setup-seafile-mysql.sh $SETUP_ARGS -o $SEAF_MYSQL_HOST -t ${SEAF_MYSQL_PORT:-3306} -u "${SEAF_MYSQL_USER:-root}" \
|
|
||||||
-w "$SEAF_MYSQL_PASS" -r "${SEAF_MYSQL_ROOT_PASS:-$SEAF_MYSQL_PASS}" -c ${SEAF_MYSQL_DB_CCNET:-ccnet} -s ${SEAF_MYSQL_DB_SEAF:-seafile} \
|
|
||||||
-b ${SEAF_MYSQL_DB_HUB:-seahub}
|
|
||||||
else
|
|
||||||
$INSTALLDIR/setup-seafile.sh $SETUP_ARGS
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
status)
|
|
||||||
RUNNING=1
|
|
||||||
for CMD in seafile-controller ccnet "${COMMANDS[@]}"; do
|
|
||||||
SERVICE="$(echo $CMD | cut -d' ' -f1)"
|
|
||||||
echo -n "$SERVICE: "
|
|
||||||
$0 manage-component $SERVICE status
|
|
||||||
[ $? -eq 0 ] || [ $RUNNING -eq 0 ]
|
|
||||||
RUNNING=$?
|
|
||||||
done
|
|
||||||
[ $RUNNING -eq 0 ]
|
|
||||||
;;
|
|
||||||
manage-component)
|
|
||||||
mkdir -p /var/run/seafile
|
|
||||||
NAME="$2"
|
|
||||||
PID=$(pid $NAME)
|
|
||||||
case "$3" in
|
|
||||||
start)
|
|
||||||
CMD="$4"
|
|
||||||
ARGS="$5"
|
|
||||||
eval "$CMD $ARGS"
|
|
||||||
sleep 1
|
|
||||||
( ! eval "$0 $1 $NAME status" ) && ((>&2 echo Failed to start $NAME); exit 1)
|
|
||||||
;;
|
|
||||||
status)
|
|
||||||
(kill -0 $PID 2> /dev/null && echo Running) || (echo Stopped && exit 1)
|
|
||||||
;;
|
|
||||||
stop)
|
|
||||||
QUERY="$0 $1 $NAME status > /dev/null"
|
|
||||||
if eval "$QUERY"; then
|
|
||||||
kill $PID
|
|
||||||
TRIES=${SEAF_STOP_TRIES:-30}
|
|
||||||
while eval "$QUERY"; do
|
|
||||||
TRIES=$((TRIES - 1))
|
|
||||||
if [ $TRIES -lt 1 ]; then
|
|
||||||
(>&2 echo Failed to stop gracefully $NAME)
|
|
||||||
kill -9 $PID
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
kill $PID
|
|
||||||
[ $? -eq 1 ] && break
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
(>&2 echo $NAME has been stopped)
|
|
||||||
else
|
|
||||||
(>&2 echo $NAME is not running)
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "You're doing wrong pal"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
(>&2 echo Unknown option $1 options include: run, run-upgrade, upgrade, stop, stop-upgrade)
|
|
||||||
;;
|
|
||||||
esac
|
|
@ -1,5 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
LATEST=$SEAF/seafile-server-latest
|
LATEST=$SEAF/seafile-server-latest
|
||||||
|
|
||||||
function ext_url {
|
function ext_url {
|
||||||
@ -23,20 +25,51 @@ function last_update {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function timestamp {
|
||||||
|
date +%Y-%m-%d > "$LATEST/install_date"
|
||||||
|
}
|
||||||
|
|
||||||
|
function revert {
|
||||||
|
rm -rf "$LATEST"
|
||||||
|
}
|
||||||
|
|
||||||
### Setup ###
|
### Setup ###
|
||||||
|
|
||||||
if [ ! -e "$LATEST" ]; then
|
if [ ! -e "$LATEST" ]; then
|
||||||
(>&2 echo This appears to be the fist run, installing..)
|
(>&2 echo This appears to be the fist run, installing..)
|
||||||
|
trap revert ERR
|
||||||
mkdir -p $SEAF/conf
|
mkdir -p $SEAF/conf
|
||||||
cp /etc/seafile/* $SEAF/conf/* -rf
|
cp -f /etc/seafile/* /opt/seafile/conf/
|
||||||
/usr/local/sbin/upgrade main
|
/usr/local/sbin/upgrade main
|
||||||
exit $?
|
RES="$?"
|
||||||
|
if [ "$RES" -eq 126 ]; then
|
||||||
|
(>&2 echo Entering setup)
|
||||||
|
INSTALLDIR=$(cat $SEAF/ahead)
|
||||||
|
rm -rf $SEAF/ahead
|
||||||
|
SETUP_ARGS="auto -n ${SEAF_NAME:-$(hostname)} -i $(hostname) -p 8082"
|
||||||
|
if [ ! -z "$SEAF_MYSQL" ]; then
|
||||||
|
$INSTALLDIR/setup-seafile-mysql.sh $SETUP_ARGS -o $SEAF_MYSQL_HOST -t ${SEAF_MYSQL_PORT:-3306} -u "${SEAF_MYSQL_USER:-root}" \
|
||||||
|
-w "$SEAF_MYSQL_PASS" -r "${SEAF_MYSQL_ROOT_PASS:-$SEAF_MYSQL_PASS}" -c ${SEAF_MYSQL_DB_CCNET:-ccnet} -s ${SEAF_MYSQL_DB_SEAF:-seafile} \
|
||||||
|
-b ${SEAF_MYSQL_DB_HUB:-seahub}
|
||||||
|
else
|
||||||
|
$INSTALLDIR/setup-seafile.sh $SETUP_ARGS
|
||||||
|
fi
|
||||||
|
cp -f /etc/seafile/* /opt/seafile/conf/
|
||||||
|
timestamp
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
if [ ! "$RES" -eq 1 ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
(>&2 echo "Installation failed")
|
||||||
|
exit 1
|
||||||
else
|
else
|
||||||
LAST_UPGRADE=$(last_update)
|
LAST_UPGRADE=$(last_update)
|
||||||
SINCE_UPGRADE=$(((($(date "+%s") - $LAST_UPGRADE))/(60*60*24)))
|
SINCE_UPGRADE=$(((($(date "+%s") - $LAST_UPGRADE))/(60*60*24)))
|
||||||
if [ $LAST_UPGRADE -gt 0 ] && [ "0$SEAF_UPGRADE_INTERVAL" -gt 0 ] && [ $SINCE_UPGRADE -gt "0$SEAF_UPGRADE_INTERVAL" ]; then
|
if [ $LAST_UPGRADE -gt 0 ] && [ "0$SEAF_UPGRADE_INTERVAL" -gt 0 ] && [ $SINCE_UPGRADE -gt "0$SEAF_UPGRADE_INTERVAL" ]; then
|
||||||
echo "It's been $SINCE_UPGRADE days since the last Upgrade\nPERFORMING UPGRADE NOW\nSet SEAF_UPGRADE_INTERVAL=0 disable automatic updates"
|
(>&2 echo "It's been $SINCE_UPGRADE days since the last Upgrade\nPERFORMING UPGRADE NOW\nSet SEAF_UPGRADE_INTERVAL=0 disable automatic updates")
|
||||||
/usr/local/sbin/upgrade main
|
/usr/local/sbin/upgrade main
|
||||||
|
timestamp
|
||||||
fi
|
fi
|
||||||
patch_seahub_conf
|
patch_seahub_conf
|
||||||
fi
|
fi
|
||||||
|
@ -55,11 +55,13 @@ def perform_upgrade_command(version,mysql=False,yes=True):
|
|||||||
scripts = os.path.join(seaf_home,"seafile-server-%s" % version, "upgrade")
|
scripts = os.path.join(seaf_home,"seafile-server-%s" % version, "upgrade")
|
||||||
current = map(lambda x: int(x), current_version().split("."))
|
current = map(lambda x: int(x), current_version().split("."))
|
||||||
target = map(lambda x: int(x), version.split("."))
|
target = map(lambda x: int(x), version.split("."))
|
||||||
print len(current) == 1 and current[0] == 0
|
|
||||||
if len(current) == 1 and current[0] == 0: #Not installed
|
if len(current) == 1 and current[0] == 0: #Not installed
|
||||||
print("Running installer.")
|
#print("Running installer.")
|
||||||
if not call(["seafile-server","setup", os.path.join(seaf_home,"seafile-server-%s" % version) ],stdout=sys.stdout, stdin=sys.stdin):
|
#if not call(["seafile-server","setup", os.path.join(seaf_home,"seafile-server-%s" % version) ],stdout=sys.stdout, stdin=sys.stdin):
|
||||||
sys.exit(1)
|
# sys.exit(1)
|
||||||
|
crumb = open(seaf_home + "/ahead", 'w')
|
||||||
|
crumb.write(os.path.join(seaf_home,"seafile-server-%s" % version))
|
||||||
|
crumb.close()
|
||||||
sys.exit(126)
|
sys.exit(126)
|
||||||
script_re = "^upgrade_(\d+).(\d+)_(\d+).(\d+)\.sh$"
|
script_re = "^upgrade_(\d+).(\d+)_(\d+).(\d+)\.sh$"
|
||||||
run = []
|
run = []
|
||||||
@ -93,6 +95,7 @@ def download(url, version):
|
|||||||
return dest
|
return dest
|
||||||
else:
|
else:
|
||||||
print("Download failed")
|
print("Download failed")
|
||||||
|
sys.exit(1)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def install_command(url, version):
|
def install_command(url, version):
|
||||||
|
@ -19,8 +19,7 @@ Environment=SEAF_UPGRADE_INTERVAL=10
|
|||||||
ExecStartPre=/bin/mkdir -p ${ROOT_DIR}
|
ExecStartPre=/bin/mkdir -p ${ROOT_DIR}
|
||||||
ExecStart=/usr/bin/rkt --insecure-options=image run --uuid-file-save=${ROOT_DIR}/container.uuid --dns 8.8.8.8 --inherit-env --volume volume-opt-seafile,kind=host,source=${ROOT_DIR} --port 80-tcp:8080 \
|
ExecStart=/usr/bin/rkt --insecure-options=image run --uuid-file-save=${ROOT_DIR}/container.uuid --dns 8.8.8.8 --inherit-env --volume volume-opt-seafile,kind=host,source=${ROOT_DIR} --port 80-tcp:8080 \
|
||||||
docker://repo.shimun.net/shimun/seafile --environment=SEAF_UPGRADE_INTERVAL=${SEAF_UPGRADE_INTERVAL}
|
docker://repo.shimun.net/shimun/seafile --environment=SEAF_UPGRADE_INTERVAL=${SEAF_UPGRADE_INTERVAL}
|
||||||
ExecStartPost=/bin/bash -c "echo 'rkt enter --app=seafile $(cat '${ROOT_DIR}'/container.uuid)' > ${ROOT_DIR}/enter.sh && chmod +x ${ROOT_DIR}/enter.sh"
|
ExecStartPost=/bin/bash -c "echo 'rkt enter --app=seafile $(cat '${ROOT_DIR}'/container.uuid)' > ${ROOT_DIR}/enter.sh && chmod +x ${ROOT_DIR}/enter.sh"
|
||||||
ExecStopPre=/bin/bash -c "rkt enter --app=seafile $(cat ${ROOT_DIR}/container.uuid) 'seafile-server stop'"
|
|
||||||
ExecStopPost=/bin/bash -c "rkt rm $(cat ${ROOT_DIR}/container.uuid)"
|
ExecStopPost=/bin/bash -c "rkt rm $(cat ${ROOT_DIR}/container.uuid)"
|
||||||
ExecStopPost=/bin/rm ${ROOT_DIR}/container.uuid
|
ExecStopPost=/bin/rm ${ROOT_DIR}/container.uuid
|
||||||
KillMode=mixed
|
KillMode=mixed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user