diff --git a/scripts/seafile-server.sh b/scripts/seafile-server.sh index bd6b3c6..95a94eb 100755 --- a/scripts/seafile-server.sh +++ b/scripts/seafile-server.sh @@ -51,7 +51,7 @@ case "$1" in mkdir -p $SEAF/conf cp /etc/seafile/* $SEAF/conf/* -rf $0 run-upgrade - exit + exit $? else patch_seahub_conf for CMD in "${COMMANDS[@]}"; do @@ -81,6 +81,10 @@ case "$1" in run-upgrade) $0 upgrade RES=$? + if [ $RES -eq 1 ]; then + echo "Failed upgrade" + exit 1 + fi if [ $RES -eq 127 ]; then #No upgrade true @@ -109,6 +113,22 @@ case "$1" in /usr/local/sbin/upgrade main kill -SIGHUP $(pgrep -o nginx) #Reload nginx ;; + maintanance) + $0 stop + $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 diff --git a/scripts/upgrade.py b/scripts/upgrade.py index 5d649a0..ae92797 100755 --- a/scripts/upgrade.py +++ b/scripts/upgrade.py @@ -57,11 +57,11 @@ def perform_upgrade_command(version,mysql=False,yes=True): 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 - print("Running installer, please don't change any default values regarding ports.") + print("Running installer.") installer = os.path.join(seaf_home,"seafile-server-%s" % version,"setup-seafile%s.sh" % ("-mysql" if mysql else "")) - while not call(["sh","-c",installer],stdout=sys.stdout, stdin=sys.stdin): - pass - return 0 + if not call(["seafile-server","setup"],stdout=sys.stdout, stdin=sys.stdin): + sys.exit(1) + sys.exit(126) script_re = "^upgrade_(\d+).(\d+)_(\d+).(\d+)\.sh$" run = [] last = None @@ -114,15 +114,15 @@ def main_command(version="latest",page="https://www.seafile.com/en/download/"): install = dict(avail.items())[version] if version_int(current_version()) == version_int(version): print("%s(%s) is already installed" % (version,version_int(version))) - return 1 + sys.exit(126) if version in installed_versions(): return perform_upgrade_command(version) if install: print("Installing: %s" % version) - return install_command(install) + sys.exit(install_command(install)) else: print("Couldn't determine download for %s" % version) - return 1 + sys.exit(1) if __name__ == '__main__': import scriptine