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