Fix quoting and escaping shellcheck errors
shellcheck was still complaining about a few SC1117 and SC2086 warnings. I ignored those that did not seem necessary and fixed the rest. The less linter noise the better.
This commit is contained in:
parent
731be98193
commit
d2b6094f7f
|
@ -83,7 +83,7 @@ test_server() {
|
||||||
else
|
else
|
||||||
# SSH connection failed
|
# SSH connection failed
|
||||||
new_error=$(printf "Failed to connect to \`%s' within %s seconds" "${item}" "${SSH_CONNECT_TIMEOUT}")
|
new_error=$(printf "Failed to connect to \`%s' within %s seconds" "${item}" "${SSH_CONNECT_TIMEOUT}")
|
||||||
SERVERS_SSH_ERRORS=$(printf "%s\n%s" "${SERVERS_SSH_ERRORS}" "${new_error}" | sed -e '/^$/d')
|
SERVERS_SSH_ERRORS=$(printf "%s\\n%s" "${SERVERS_SSH_ERRORS}" "${new_error}" | sed -e '/^$/d')
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -96,12 +96,12 @@ pick_server() {
|
||||||
if [ "${increment}" -ge "${list_length}" ]; then
|
if [ "${increment}" -ge "${list_length}" ]; then
|
||||||
# We've reached the end of the list
|
# We've reached the end of the list
|
||||||
new_error="No more server available"
|
new_error="No more server available"
|
||||||
SERVERS_SSH_ERRORS=$(printf "%s\n%s" "${SERVERS_SSH_ERRORS}" "${new_error}" | sed -e '/^$/d')
|
SERVERS_SSH_ERRORS=$(printf "%s\\n%s" "${SERVERS_SSH_ERRORS}" "${new_error}" | sed -e '/^$/d')
|
||||||
|
|
||||||
# Log errors to stderr
|
# Log errors to stderr
|
||||||
printf "%s\n" "${SERVERS_SSH_ERRORS}" >&2
|
printf "%s\\n" "${SERVERS_SSH_ERRORS}" >&2
|
||||||
# Log errors to logfile
|
# Log errors to logfile
|
||||||
printf "%s\n" "${SERVERS_SSH_ERRORS}" >> $LOGFILE
|
printf "%s\\n" "${SERVERS_SSH_ERRORS}" >> $LOGFILE
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -123,6 +123,8 @@ pick_server() {
|
||||||
if [ -e "${PIDFILE}" ]; then
|
if [ -e "${PIDFILE}" ]; then
|
||||||
pid=$(cat "${PIDFILE}")
|
pid=$(cat "${PIDFILE}")
|
||||||
# Does process still exist ?
|
# Does process still exist ?
|
||||||
|
# ignore check because multiple processes might exist
|
||||||
|
# shellcheck disable=SC2086
|
||||||
if kill -0 ${pid} 2> /dev/null; then
|
if kill -0 ${pid} 2> /dev/null; then
|
||||||
# Killing the childs of evobackup.
|
# Killing the childs of evobackup.
|
||||||
for ppid in $(pgrep -P "${pid}"); do
|
for ppid in $(pgrep -P "${pid}"); do
|
||||||
|
@ -130,7 +132,7 @@ if [ -e "${PIDFILE}" ]; then
|
||||||
done
|
done
|
||||||
# Then kill the main PID.
|
# Then kill the main PID.
|
||||||
kill -9 "${pid}"
|
kill -9 "${pid}"
|
||||||
printf "%s is still running (PID %s). Process has been killed" "$0" "${pid}\n" >&2
|
printf "%s is still running (PID %s). Process has been killed" "$0" "${pid}\\n" >&2
|
||||||
else
|
else
|
||||||
rm -f ${PIDFILE}
|
rm -f ${PIDFILE}
|
||||||
fi
|
fi
|
||||||
|
@ -299,7 +301,7 @@ if [ "${LOCAL_TASKS}" = "1" ]; then
|
||||||
|
|
||||||
## Dump findmnt(8) output
|
## Dump findmnt(8) output
|
||||||
FINDMNT_BIN=$(command -v findmnt)
|
FINDMNT_BIN=$(command -v findmnt)
|
||||||
if [ -x ${FINDMNT_BIN} ]; then
|
if [ -x "${FINDMNT_BIN}" ]; then
|
||||||
${FINDMNT_BIN} > ${LOCAL_BACKUP_DIR}/findmnt.txt
|
${FINDMNT_BIN} > ${LOCAL_BACKUP_DIR}/findmnt.txt
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
@ -366,6 +368,8 @@ if [ "${SYNC_TASKS}" = "1" ]; then
|
||||||
# Remote shell command
|
# Remote shell command
|
||||||
RSH_COMMAND="ssh -p ${SSH_PORT} -o 'ConnectTimeout ${SSH_CONNECT_TIMEOUT}'"
|
RSH_COMMAND="ssh -p ${SSH_PORT} -o 'ConnectTimeout ${SSH_CONNECT_TIMEOUT}'"
|
||||||
|
|
||||||
|
# ignore check because we want it to split the different arguments to $rep
|
||||||
|
# shellcheck disable=SC2086
|
||||||
rsync -avzh --stats --delete --delete-excluded --force --ignore-errors --partial \
|
rsync -avzh --stats --delete --delete-excluded --force --ignore-errors --partial \
|
||||||
--exclude "lost+found" \
|
--exclude "lost+found" \
|
||||||
--exclude ".nfs.*" \
|
--exclude ".nfs.*" \
|
||||||
|
@ -410,11 +414,11 @@ fi
|
||||||
|
|
||||||
END=$(/bin/date +"%d-%m-%Y ; %H:%M")
|
END=$(/bin/date +"%d-%m-%Y ; %H:%M")
|
||||||
|
|
||||||
printf "EvoBackup - %s - START %s ON %s (LOCAL_TASKS=%s SYNC_TASKS=%s)\n" \
|
printf "EvoBackup - %s - START %s ON %s (LOCAL_TASKS=%s SYNC_TASKS=%s)\\n" \
|
||||||
"${HOSTNAME}" "${BEGINNING}" "${SSH_SERVER}" "${LOCAL_TASKS}" "${SYNC_TASKS}" \
|
"${HOSTNAME}" "${BEGINNING}" "${SSH_SERVER}" "${LOCAL_TASKS}" "${SYNC_TASKS}" \
|
||||||
>> $LOGFILE
|
>> $LOGFILE
|
||||||
|
|
||||||
printf "EvoBackup - %s - STOP %s ON %s (LOCAL_TASKS=%s SYNC_TASKS=%s)\n" \
|
printf "EvoBackup - %s - STOP %s ON %s (LOCAL_TASKS=%s SYNC_TASKS=%s)\\n" \
|
||||||
"${HOSTNAME}" "${END}" "${SSH_SERVER}" "${LOCAL_TASKS}" "${SYNC_TASKS}" \
|
"${HOSTNAME}" "${END}" "${SSH_SERVER}" "${LOCAL_TASKS}" "${SYNC_TASKS}" \
|
||||||
>> $LOGFILE
|
>> $LOGFILE
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue