Switch to double bracket tests, improve readability

This commit is contained in:
flow.gunso
2020-01-06 18:38:20 +01:00
parent fc271c8722
commit 59cf0d11ac

View File

@@ -16,32 +16,30 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# Define variable shortcuts for readability purposes.
seafile_ini=~/.ccnet/seafile.ini
seafile_sock=~/.seafile/seafile-data/seafile.sock
# Safely initialise the Seafile client. # Safely initialise the Seafile client.
seafile_ini=~/.ccnet/seafile.ini
/usr/bin/seaf-cli init -d ~/.seafile /usr/bin/seaf-cli init -d ~/.seafile
while [ ! -f $seafile_ini ]; do sleep 1; done while [ ! -f $seafile_ini ]; do sleep 1; done
# Safely start the Seafile daemon. # Safely start the Seafile daemon.
seafile_sock=~/.seafile/seafile-data/seafile.sock
/usr/bin/seaf-cli start /usr/bin/seaf-cli start
while [ ! -S $seafile_sock ]; do sleep 1; done while [ ! -S $seafile_sock ]; do sleep 1; done
# Set the disable_verify_certificate key to true only if the environment variable is true. # Set the disable_verify_certificate key to true only if the environment variable exists.
test "$SEAF_SKIP_SSL_CERT" = true && seaf-cli config -k disable_verify_certificate -v true [[ "$SEAF_SKIP_SSL_CERT" ]] && seaf-cli config -k disable_verify_certificate -v true
# Set the upload/download limits # Set the upload/download limits
test -n "$SEAF_PLOAD_LIMIT" && seaf-cli config -k upload_limit -v $SEAF_UPLOAD_LIMIT [[ "$SEAF_UPLOAD_LIMIT" ]] && seaf-cli config -k upload_limit -v $SEAF_UPLOAD_LIMIT
test -n "$SEAF_DOWNLOAD_LIMIT" && seaf-cli config -k download_limit -v $SEAF_DOWNLOAD_LIMIT [[ "$SEAF_DOWNLOAD_LIMIT" ]] && seaf-cli config -k download_limit -v $SEAF_DOWNLOAD_LIMIT
# Build the seaf-cli sync command. # Build the seaf-cli sync command.
cmd="seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID" cmd="seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume"
test $SEAF_2FA_SECRET && cmd+=" -a $(oathlib --base32 --totp $SEAF_2FA_SECRET)" [[ "$SEAF_2FA_SECRET" ]] && cmd+=" -a $(oathtool --base32 --totp $SEAF_2FA_SECRET)"
test $SEAF_LIBRARY_PASSWORD && cmd+=" -e $SEAF_LIBRARY_PASSWORD" [[ "$SEAF_LIBRARY_PASSWORD" ]] && cmd+=" -e $SEAF_LIBRARY_PASSWORD"
# Run it. # Run it.
if ! eval $cmd; then echo "Failed to sync"; exit 1; fi if ! eval $cmd; then echo "Failed to synchronize."; exit 1; fi
# Continously print the log. # Continously print the log.
tail -f ~/.ccnet/logs/seafile.log tail -f ~/.ccnet/logs/seafile.log