Make rc.d scripts shellcheck friendly.
This commit is contained in:
parent
9b4ac20589
commit
a3322cb47f
6 changed files with 43 additions and 13 deletions
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# Version: 0.3.0
|
||||
# Version: 0.3.1
|
||||
# Copyright (c) 2005-2022:
|
||||
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
|
||||
# Licensed under the terms of the GNU General Public License version 3.
|
||||
|
|
@ -14,6 +14,7 @@ PIDFILE=""
|
|||
# EXTRA_ARGS=() # Extra arguments passed to $EXEC. Must be an array.
|
||||
# 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() {
|
||||
|
|
@ -29,10 +30,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
|
||||
|
|
@ -58,7 +60,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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue