Make rc.d scripts shellcheck friendly.

This commit is contained in:
Darren 'Tadgy' Austin 2022-09-05 18:02:39 +01:00
commit a3322cb47f
6 changed files with 43 additions and 13 deletions

View file

@ -4,6 +4,8 @@
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# Licensed under the terms of the GNU General Public License version 3.
# shellcheck disable=SC2016
EXEC="/usr/sbin/in.tftpd"
ARGS=('-l' '-s' '-u' '${RUNUSER:-tftp}' '-P' '/run/tftpd.pid' '/data/tftpboot')
PIDFILE="/run/tftpd.pid"
@ -16,6 +18,7 @@ RUNUSER="tftp"
# RUNUSER="" # The username to run the tftp daemon as. Default: tftp.
# SLAY_DELAY="" # Delay between the SIGTERM and SIGKILL on a 'stop'. Default: 2s.
# RESTART_DELAY="" # Delay between stopping and starting on a 'restart'. Default: 2s.
# shellcheck disable=SC1090
[[ -e "/etc/default/${0##*rc.}" ]] && { source "/etc/default/${0##*rc.}" || return 1 2>/dev/null || exit 1; }
error() {
@ -32,10 +35,11 @@ checkconfigured() {
}
checkstatus() {
# shellcheck disable=SC2155
local RUNPIDS="$({ pgrep -f "$EXEC"; pgrep -F "$PIDFILE" 2>/dev/null; } | sort -u )"
if [[ ! -z "$RUNPIDS" ]]; then
if [[ -n "$RUNPIDS" ]]; then
printf "%s: %s: %s" "${BASH_SOURCE[0]##*/}" "${EXEC##*/}" "running"
if [[ ! -z "$PIDFILE" ]]; then
if [[ -n "$PIDFILE" ]]; then
if [[ ! -e "$PIDFILE" ]]; then
printf "%s" ", but .pid file does not exist"
elif ! grep "\<$(<"$PIDFILE")\>" <<<"$RUNPIDS" >/dev/null 2>&1; then
@ -61,7 +65,9 @@ startdaemon() {
error "not started - pre-start checks failed"
return 2
fi
# shellcheck disable=SC2048,SC2086
${ENVIRONMENT:+declare ${ENVIRONMENT[*]};} "$EXEC" ${ARGS[*]} ${EXTRA_ARGS[*]}
# shellcheck disable=SC2181
if (( $? != 0 )); then
error "error starting daemon"
return 2