refactor gc.sh

This commit is contained in:
Gerrit Gogel 2021-02-01 12:57:36 +01:00
parent 049ecf457f
commit f14e2393a3

View file

@ -1,37 +1,25 @@
#!/bin/bash #!/bin/bash
set -e set -e
# Before
SEAFILE_DIR=/opt/seafile/seafile-server-latest SEAFILE_DIR=/opt/seafile/seafile-server-latest
if [[ $SEAFILE_SERVER != *"pro"* ]]; then if [[ $SEAFILE_SERVER != *"pro"* ]]; then
echo "Seafile CE: Stop Seafile to perform offline garbage collection." echo "Seafile CE: Stop Seafile to perform offline garbage collection."
$SEAFILE_DIR/seafile.sh stop $SEAFILE_DIR/seafile.sh stop
echo "Waiting for the server to shut down properly..."
echo "Waiting for the server to shut down properly..." sleep 5
sleep 5
else else
echo "Seafile Pro: Perform online garbage collection." echo "Seafile Pro: Perform online garbage collection."
fi fi
# Do it
( (
set +e set +e
$SEAFILE_DIR/seaf-gc.sh "$@" | tee -a /var/log/gc.log $SEAFILE_DIR/seaf-gc.sh "$@" | tee -a /var/log/gc.log
# We want to presevent the exit code of seaf-gc.sh
exit "${PIPESTATUS[0]}" exit "${PIPESTATUS[0]}"
) ) gc_exit_code=$?
gc_exit_code=$?
# After
if [[ $SEAFILE_SERVER != *"pro"* ]]; then if [[ $SEAFILE_SERVER != *"pro"* ]]; then
echo "Giving the server some time..." echo "Giving the server some time..."
sleep 3 sleep 3
$SEAFILE_DIR/seafile.sh start
$SEAFILE_DIR/seafile.sh start
fi fi
exit $gc_exit_code exit $gc_exit_code