dot

packages and services management
Log | Files | Refs | README

commit c65f469335b0a3363c151ed4935930e765512d43
parent 164857cab926ed61203ffb4725a1689abf53a059
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Mon, 19 Jun 2017 17:49:26 +0200

Processes.  Layer 15

Diffstat:
MSERVICE | 31+++++++++++++++----------------
Mngircd/start | 3+--
Mshell/.bashrc | 1+
Mshell/.mkshrc | 1+
Mshell/.profile | 1+
Mshell/.zshrc | 1+
6 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/SERVICE b/SERVICE @@ -8,11 +8,12 @@ die() } -check() +status() { - [ -f "$ETC/$1/pid" ] && read pid < "$VAR/$1/pid" || pid='' - - ps "$pid" > /dev/null + [ -f "$VAR/pid/$1" ] && + grep -qF "$1" "/proc/$(cat "$VAR/pid/$1")/cmdline" && + printf '%-20s [running]\n' "$1" && return 0 || + printf '%-20s [stopped]\n' "$1" && rm -f "$VAR/$1/pid" && return 1 } @@ -20,28 +21,26 @@ start() { [ -f "$ETC/$1/start" ] || die "no start script in $ETC/$1" - printf %s $$ > "$VAR/pid/$1" - service="$1" shift - sh "$ETC/$service/start" "$@" & + . "$ETC/$service/start" "$@" > "$VAR/log/$service" 2>&1 + printf %s $! > "$VAR/pid/$service" } stop() { - [ -f "$ETC/$1/stop" ] || echo "no stop script in $ETC/$1" && exit 1 + status "$1" || exit 1 - [ -f "$ETC/$1/pid" ] && read pid < "$VAR/$1/pid" || pid='' + read pid < "$VAR/pid/$1" - sh "$ETC/$2/stop" -} + if [ -f "$ETC/$1/stop" ] + then sh "$ETC/$2/stop" + else kill -14 "$pid" + fi && rm "$VAR/pid/$1" - -status() -{ - : + status "$1" || exit 0 } @@ -65,6 +64,6 @@ case "$command" in ( start ) start "$@" ;; ( stop ) stop "$@" ;; ( restart ) stop "$@" && start "$@" ;; -( status ) status ;; +( status ) status "$1" ;; ( * ) usage ;; esac diff --git a/ngircd/start b/ngircd/start @@ -1,2 +1 @@ -echo "$$" -exec ngircd -f "$ETC/ngircd/ngircd.conf" -n +ngircd -f "$ETC/ngircd/ngircd.conf" -n & diff --git a/shell/.bashrc b/shell/.bashrc @@ -5,6 +5,7 @@ export NICK='josuah' export MAIL="$VAR/mail/INBOX" export EMAIL='mail@josuah.net' export TZ='Europe/Paris' +export LC_ALL='en_US.UTF-8' export EDITOR='mg' export VISUAL='mg' diff --git a/shell/.mkshrc b/shell/.mkshrc @@ -5,6 +5,7 @@ export NICK='josuah' export MAIL="$VAR/mail/INBOX" export EMAIL='mail@josuah.net' export TZ='Europe/Paris' +export LC_ALL='en_US.UTF-8' export EDITOR='mg' export VISUAL='mg' diff --git a/shell/.profile b/shell/.profile @@ -5,6 +5,7 @@ export NICK='josuah' export MAIL="$VAR/mail/INBOX" export EMAIL='mail@josuah.net' export TZ='Europe/Paris' +export LC_ALL='en_US.UTF-8' export EDITOR='mg' export VISUAL='mg' diff --git a/shell/.zshrc b/shell/.zshrc @@ -5,6 +5,7 @@ export NICK='josuah' export MAIL="$VAR/mail/INBOX" export EMAIL='mail@josuah.net' export TZ='Europe/Paris' +export LC_ALL='en_US.UTF-8' export EDITOR='mg' export VISUAL='mg'