This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
|
||||
LATEST=$SEAF/seafile-server-latest
|
||||
|
||||
function ext_url {
|
||||
@@ -23,20 +25,51 @@ function last_update {
|
||||
fi
|
||||
}
|
||||
|
||||
function timestamp {
|
||||
date +%Y-%m-%d > "$LATEST/install_date"
|
||||
}
|
||||
|
||||
function revert {
|
||||
rm -rf "$LATEST"
|
||||
}
|
||||
|
||||
### Setup ###
|
||||
|
||||
if [ ! -e "$LATEST" ]; then
|
||||
(>&2 echo This appears to be the fist run, installing..)
|
||||
trap revert ERR
|
||||
mkdir -p $SEAF/conf
|
||||
cp /etc/seafile/* $SEAF/conf/* -rf
|
||||
cp -f /etc/seafile/* /opt/seafile/conf/
|
||||
/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
|
||||
LAST_UPGRADE=$(last_update)
|
||||
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\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
|
||||
timestamp
|
||||
fi
|
||||
patch_seahub_conf
|
||||
fi
|
||||
|
Reference in New Issue
Block a user