web-logs: Use absolute path for rclone binary

This commit is contained in:
Timo Makinen 2021-09-19 09:49:32 +00:00
parent 74a75772c2
commit 663038ced2

View file

@ -6,6 +6,7 @@ umask 022
TARGET="/var/cache/sync-http-logs"
CONFIG="/etc/rclone/rclone.conf"
LOGDIR="/var/log/rclone"
RCLONE="/usr/local/bin/rclone"
timestamp="$(date +%Y%m%d%H%M%S)"
@ -14,14 +15,14 @@ if [ ! -d "$TARGET" ]; then
exit 1
fi
for host in $(rclone --config "$CONFIG" listremotes | tr -d ":") ; do
fqdn="$(rclone --config "$CONFIG" config show "$host" | \
for host in $("$RCLONE" --config "$CONFIG" listremotes | tr -d ":") ; do
fqdn="$("$RCLONE" --config "$CONFIG" config show "$host" | \
awk '{ if ($1 == "host") print $3 }')"
if [ ! -d "${TARGET}/${fqdn}" ]; then
mkdir "${TARGET}/${fqdn}"
fi
log="${LOGDIR}/${fqdn}.${timestamp}.log"
if ! rclone --config "$CONFIG" --log-file "$log" --log-level INFO \
if ! "$RCLONE" --config "$CONFIG" --log-file "$log" --log-level INFO \
sync "${host}:/" "${TARGET}/${fqdn}/"; then
cat "$log"
fi