dot

packages and services management
Log | Files | Refs | README

commit ca6a32450a9a15f341e9e9829d0fedcaa2f78865
parent c26557369fda2cce78bd69760c299ad79f2625ab
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Sun, 13 Aug 2017 21:31:43 +0200

rc: added $RUN and $SRV

Diffstat:
Mpkg/bin/pkg-service | 22+++++++++++-----------
Mrc | 2++
2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/pkg/bin/pkg-service b/pkg/bin/pkg-service @@ -14,17 +14,17 @@ case "$cmd" in printf '%s (start | stop | restart | status) <pkg>\n' "${0##*/}" esac -mkdir -p "$VAR/pid" "$VAR/log" +mkdir -p "$RUN/pid" "$RUN/log" -[ -d "$VAR/pid/$srv" ] && for pid in $(ls "$VAR/pid/$srv") +[ -d "$RUN/pid/$srv" ] && for pid in $(ls "$RUN/pid/$srv") do for arg in "$@" - do grep -qF "$arg" "$VAR/pid/$srv/$pid" || continue 2 + do grep -qF "$arg" "$RUN/pid/$srv/$pid" || continue 2 done - if cmp "$VAR/pid/$srv/$pid" "/proc/$pid/cmdline" 2> /dev/null + if cmp "$RUN/pid/$srv/$pid" "/proc/$pid/cmdline" 2> /dev/null then - acted=1 cmdline="$(tr '\0' ' ' < "$VAR/pid/$srv/$pid")" + acted=1 cmdline="$(tr '\0' ' ' < "$RUN/pid/$srv/$pid")" if [ "$cmd" = stop ] || [ "$cmd" = restart ] then @@ -41,17 +41,17 @@ done if [ "$running" = 0 ] && [ "$cmd" = start ] || [ "$cmd" = restart ] then - mkdir -p "$VAR/pid/$srv" - . "$PKG/$srv/start" "$@" >> "$VAR/log/$srv" 2>&1 && - cp "/proc/$PID/cmdline" "$VAR/pid/$srv/$PID" || exit 1 + mkdir -p "$RUN/pid/$srv" + . "$PKG/$srv/start" "$@" >> "$RUN/log/$srv" 2>&1 && + cp "/proc/$PID/cmdline" "$RUN/pid/$srv/$PID" || exit 1 printf '%-15s [started] ' "$srv" - tr '\0' ' ' < "$VAR/pid/$srv/$PID" + tr '\0' ' ' < "$RUN/pid/$srv/$PID" printf '\n' fi -find "$VAR/pid" -type f | while IFS='' read path +find "$RUN/pid" -type f | while IFS='' read path do cmp "$path" "/proc/${path##*/}/cmdline" 2> /dev/null || rm -f "$path" done -find "$VAR/pid" -depth -type d -exec rmdir {} + 2> /dev/null || true +find "$RUN/pid" -depth -type d -exec rmdir {} + 2> /dev/null || true diff --git a/rc b/rc @@ -5,6 +5,8 @@ export OPT="$ROOT/opt" export SRC="$ROOT/src" export GIT="$ROOT/git" export VAR="$ROOT/var" +export RUN="$ROOT/run" +export SRV="$ROOT/srv" export PATH="$ROOT/bin:$PATH" export MANPATH="$ROOT/man:$MANPATH"