Cosmetic changes.

This commit is contained in:
Darren 'Tadgy' Austin 2022-08-24 00:46:57 +01:00
commit 11a892a1c1
2 changed files with 14 additions and 15 deletions

View file

@ -1,5 +1,4 @@
#!/bin/sh
# /etc/rc.d/rc.modules.local - Load locally configured kernel modules.
# Copyright (c) 2005-2022:
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# Licensed under the terms of the GNU General Public License version 3.

View file

@ -13,14 +13,14 @@ RUNUSER="seeder"
# Allow configuration in /etc/default to override.
# Additional available variables:
# ENVIRONMENT=() # Extra environment passed to $SCREEN_EXEC. Must be an array.
# RUNUSER="" # The username of the seeding user account. Default: seeder.
# SEEDS=() # The seeding sessions to start. 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.
# RUNUSER="" # The username of the seeding user account. Default: seeder.
[[ -e "/etc/default/${0##*rc.}" ]] && source "/etc/default/${0##*rc.}"
[[ -e "/etc/default/${0##*rc.}" ]] && { source "/etc/default/${0##*rc.}" || return 1 2>/dev/null || exit 1; }
error() {
printf "%s: %s\\n" "${BASH_SOURCE##*/}" "$*" >&2
printf "%s: %s\\n" "${BASH_SOURCE[0]##*/}" "$*" >&2
}
checkconfigured() {
@ -38,15 +38,15 @@ checkstatus() {
if [[ ! -z "$(su - "${RUNUSER:-seeder}" -c "\"$DAEMON_EXEC\" --list 2>/dev/null")" ]]; then
for SEED in "$@"; do
if su - "${RUNUSER:-seeder}" -c "\"$DAEMON_EXEC\" --running -n \"seeder-$SEED\""; then
printf "%s: %s: %s\\n" "${BASH_SOURCE##*/}" "seed '$SEED'" "running"
printf "%s: %s: %s\\n" "${BASH_SOURCE[0]##*/}" "seed '$SEED'" "running"
RET=${RET:+2}
else
printf "%s: %s: %s\\n" "${BASH_SOURCE##*/}" "seed '$SEED'" "stopped"
printf "%s: %s: %s\\n" "${BASH_SOURCE[0]##*/}" "seed '$SEED'" "stopped"
RET=${RET:-1}
fi
done
else
printf "%s: %s\\n" "${BASH_SOURCE##*/}" "all seeds stopped"
printf "%s: %s\\n" "${BASH_SOURCE[0]##*/}" "all seeds stopped"
RET=1
fi
return $RET
@ -57,16 +57,16 @@ startdaemon() {
local EXEC SEED ERR RET
checkconfigured || {
error "seeding not started - pre-start checks failed"
return 1
return 2
}
for EXEC in "$SCREEN_EXEC" "$(su - "${RUNUSER:-seeder}" -c "printf \"%s\" \"$RTORRENTWRAPPER_EXEC\"")"; do
[[ ! -e "$EXEC" ]] && {
error "$EXEC:" "not found"
return 1
return 2
}
[[ ! -x "$EXEC" ]] && {
error "$EXEC:" "not executable"
return 1
return 2
}
done
su - "${RUNUSER:-seeder}" -c "${ENVIRONMENT:+declare ${ENVIRONMENT[*]};} \"$SCREEN_EXEC\" ${SCREEN_ARGS[*]} -ls" | grep -iv "dead" >/dev/null || {
@ -74,7 +74,7 @@ startdaemon() {
ERR=$?
(( ERR != 0 )) && {
error "failed to start background screen:" "Error code = $ERR"
return $ERR
return 2
}
sleep 2
}
@ -83,7 +83,7 @@ startdaemon() {
ERR=$?
(( ERR != 0 )) && {
error "failed to add screen for '$SEED':" "Error code = $ERR"
RET=1
RET=2
continue
}
sleep 1
@ -129,7 +129,7 @@ case "$OPT" in
'start')
if checkstatus "${@:-${SEEDS[@]}}" >/dev/null; then
error "seeds already running"
printf " %s\\n" "Try: $BASH_SOURCE status $@" >&2
printf " %s\\n" "Try: ${BASH_SOURCE[0]} status $@" >&2
RET=1
else
startdaemon "${@:-${SEEDS[@]}}"
@ -144,7 +144,7 @@ case "$OPT" in
RET=$?
elif (( ERR == 1 )); then
error "seeds already stopped"
printf " %s\\n" "Try: $BASH_SOURCE status" >&2
printf " %s\\n" "Try: ${BASH_SOURCE[0]} status" >&2
RET=1
else
error "unhandled status: $ERR"
@ -174,7 +174,7 @@ case "$OPT" in
RET=$?
;;
*)
printf "%s\\n" "Usage: $BASH_SOURCE <start|stop|restart|status> [seeding session] ..." >&2
printf "%s\\n" "Usage: ${BASH_SOURCE[0]} <start|stop|restart|status> [seeding session] ..." >&2
RET=1
;;
esac