Prevent initializing/synchronizing if container is restarted and not deleted, see #14

This commit is contained in:
flow.gunso
2020-03-10 14:13:39 +01:00
parent 4b0af17cec
commit 8d46c1de76
2 changed files with 27 additions and 20 deletions

View File

@@ -16,30 +16,37 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Safely initialise the Seafile client.
seafile_ini=~/.ccnet/seafile.ini
/usr/bin/seaf-cli init -d ~/.seafile
while [ ! -f $seafile_ini ]; do sleep 1; done
# Initialise the Seafile client, if not already initialised.
seafile_ini="$HOME/.ccnet/seafile.ini"
if [ ! -f "$seafile_ini" ]; then
echo "Initializing Seafile client..."
seaf-cli init -d ~/.seafile
while [ ! -f "$seafile_ini" ]; do sleep 1; done
fi
# Safely start the Seafile daemon.
seafile_sock=~/.seafile/seafile-data/seafile.sock
/usr/bin/seaf-cli start
while [ ! -S $seafile_sock ]; do sleep 1; done
# Start the Seafile daemon.
echo "Starting Seafile client..."
seaf-cli start
while [ ! -S "$HOME/.seafile/seafile-data/seafile.sock" ]; do sleep 1; done
# Set the disable_verify_certificate key to true only if the environment variable exists.
[[ "$SEAF_SKIP_SSL_CERT" ]] && seaf-cli config -k disable_verify_certificate -v true
# Synchronize the library, if not already synchronized.
if [ -z "$(seaf-cli status | grep -v ^\#)" ]; then
echo "Synchronizing Seafile library..."
# Set the disable_verify_certificate key to true only if the environment variable exists.
[[ "$SEAF_SKIP_SSL_CERT" ]] && seaf-cli config -k disable_verify_certificate -v true
# Set the upload/download limits
[[ "$SEAF_UPLOAD_LIMIT" ]] && seaf-cli config -k upload_limit -v $SEAF_UPLOAD_LIMIT
[[ "$SEAF_DOWNLOAD_LIMIT" ]] && seaf-cli config -k download_limit -v $SEAF_DOWNLOAD_LIMIT
# Set the upload/download limits
[[ "$SEAF_UPLOAD_LIMIT" ]] && seaf-cli config -k upload_limit -v $SEAF_UPLOAD_LIMIT
[[ "$SEAF_DOWNLOAD_LIMIT" ]] && seaf-cli config -k download_limit -v $SEAF_DOWNLOAD_LIMIT
# Build the seaf-cli sync command.
cmd="seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /library"
[[ "$SEAF_2FA_SECRET" ]] && cmd+=" -a $(oathtool --base32 --totp $SEAF_2FA_SECRET)"
[[ "$SEAF_LIBRARY_PASSWORD" ]] && cmd+=" -e $SEAF_LIBRARY_PASSWORD"
# Build the seaf-cli sync command.
cmd="seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /library"
[[ "$SEAF_2FA_SECRET" ]] && cmd+=" -a $(oathtool --base32 --totp $SEAF_2FA_SECRET)"
[[ "$SEAF_LIBRARY_PASSWORD" ]] && cmd+=" -e $SEAF_LIBRARY_PASSWORD"
# Run it.
if ! eval $cmd; then echo "Failed to synchronize."; exit 1; fi
# Run it.
if ! eval $cmd; then echo "Failed to synchronize."; exit 1; fi
fi
# Continously print the log, infinitely.
while true; do

View File

@@ -17,7 +17,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
failures=()
binaries=(seaf-cli oathtool)
binaries=(seaf-cli oathtool grep)
for binary in "${binaries[@]}"; do
if ! [ -x "$(command -v $binary)" ]; then