| Make annna-start and annna-stop more flexible. - annna - Annna the nice friendl… | |
| git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6… | |
| Log | |
| Files | |
| Refs | |
| Tags | |
| README | |
| --- | |
| commit 86ed7ccd5559dd7814aa60659031f03ce9d198cd | |
| parent 7a7a2a9db786688ba9aedf387f56b8fe267f32b5 | |
| Author: Annna Robert-Houdin <[email protected]> | |
| Date: Tue, 14 Oct 2025 21:06:34 +0200 | |
| Make annna-start and annna-stop more flexible. | |
| Diffstat: | |
| M annna-start | 22 +++++++++++++++++----- | |
| M annna-stop | 31 +++++++++++++++++++++++++++--… | |
| 2 files changed, 44 insertions(+), 9 deletions(-) | |
| --- | |
| diff --git a/annna-start b/annna-start | |
| @@ -1,14 +1,13 @@ | |
| #!/bin/sh | |
| -set -x | |
| - | |
| if [ $# -lt 1 ]; | |
| then | |
| - printf "usage: %s cfgdir\n" "$(basename "$0")" >&2 | |
| + printf "usage: %s cfgdir [server ...]\n" "$(basename "$0")" >&2 | |
| exit 1 | |
| fi | |
| export ANNNA_BASE="$1" | |
| +shift 1 | |
| [ ! -d "${ANNNA_BASE}" ] && printf "%s not a directory.\n" "${ANNNA_BASE}" >&2… | |
| [ ! -e "${ANNNA_BASE}/binbase" ] && printf "No /binbase exists.\n" >&2 && exit… | |
| @@ -27,10 +26,23 @@ export PATH="$PATH:${ANNNA_BINBASE}" | |
| cd "${ANNNA_BASE}" | |
| touch running | |
| -for server in $(find . -maxdepth 1 -type d | cut -c 3-); | |
| + | |
| +if [ $# -gt 1 ]; | |
| +then | |
| + servers="$@" | |
| +else | |
| + servers="$(find . -maxdepth 1 -type d | cut -c 3-)"; | |
| +fi | |
| +for server in ${servers}; | |
| do | |
| [ -z "$server" ] && continue | |
| export IRC_SERVER="${server}" | |
| + if [ -f "${IRC_SERVER}.pid" ]; | |
| + then | |
| + printf "%s already running.\n" "${IRC_SERVER}" | |
| + continue | |
| + fi | |
| + | |
| [ ! -f ${server}/autoconnect ] && continue | |
| export IRC_CHANNELS="$(cat ${server}/channels | tr '\n' ' ')" | |
| export IRC_TLS=0 | |
| @@ -45,7 +57,7 @@ do | |
| [ -f ${server}/name ] && export IRC_NAME="$(cat ${server}/name)" | |
| annna-start-server & | |
| - printf "%s\n" "$!" > "$IRC_SERVER.pid" | |
| + printf "%s\n" "$!" > "${IRC_SERVER}.pid" | |
| done | |
| printf "%s is ALIVE. Have fun! :-)\n" "${IRC_USER}" | |
| diff --git a/annna-stop b/annna-stop | |
| @@ -5,24 +5,47 @@ | |
| if [ $# -lt 1 ]; | |
| then | |
| - printf "usage: %s cfgdir\n" "$(basename "$0")" >&2 | |
| + printf "usage: %s cfgdir [server]\n" "$(basename "$0")" >&2 | |
| exit 1 | |
| fi | |
| export ANNNA_BASE="$1" | |
| +shift 1 | |
| [ ! -d "${ANNNA_BASE}" ] && printf "%s not a directory.\n" "${ANNNA_BASE}" >&2… | |
| + | |
| [ ! -e "${ANNNA_BASE}/binbase" ] && printf "No /binbase exists.\n" >&2 && exit… | |
| export ANNNA_BINBASE="$(cat "${ANNNA_BASE}/binbase")" | |
| [ ! -d "${ANNNA_BINBASE}" ] && printf "%s not a directory.\n" "${ANNNA_BINBASE… | |
| + | |
| +[ ! -e "${ANNNA_BASE}/ircbase" ] && printf "No /ircbase exists.\n" >&2 && exit… | |
| +export ANNNA_IRCBASE="$(cat "${ANNNA_BASE}/ircbase")" | |
| +[ ! -d "${ANNNA_IRCBASE}" ] && printf "%s not a directory.\n" "${ANNNA_IRCBASE… | |
| + | |
| export PATH="$PATH:${ANNNA_BINBASE}" | |
| -annna-die | |
| cd "${ANNNA_BASE}" | |
| -for pidfile in $(find . -maxdepth 1 -type f -name "*.pid" | cut -c 3-); | |
| +if [ $# -gt 1 ]; | |
| +then | |
| + servers="$@" | |
| +else | |
| + servers="$(find . -maxdepth 1 -type d | cut -c 3-)" | |
| +fi | |
| +for server in ${servers}; | |
| do | |
| + [ -z "${server}" ] && continue | |
| + pidfile="${server}.pid" | |
| + [ ! -f "${pidfile}" ] && continue | |
| serverpid="$(cat "${pidfile}")" | |
| [ -z "${serverpid}" ] && continue | |
| - kill -0 "${serverpid} && kill -KILL "${serverpid}" | |
| + if kill -0 "${serverpid}"; | |
| + then | |
| + pkill -P "${serverpid}" | |
| + kill -KILL "${serverpid}" | |
| + fi | |
| rm "${pidfile}" | |
| + rm -rf "${ANNNA_IRCBASE}/${server}" | |
| done | |
| +# Nothing is left running, so annna running can be removed. | |
| +[ -z "$(find . -maxdepth 1 -type f -name "*.pid")" ] && annna-die | |
| + |