svc

Unnamed repository; edit this file 'description' to name the repository.
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 83a2bda17bb74f79d1ef607060cd2a7e4963bf3f
родитељ 5c01bbae598c2265d27a8f7852879f8d237d8613
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Thu, 21 Jul 2022 22:29:50 +0200

Fix options/manpages

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
Mbin/service | 16++++++++--------
Mbin/svc | 23++++++++++++++---------
Mman/man8/svc.8 | 37++++++++++++++++++++++++-------------
измењених датотека: 3, додавања: 46(+), брисања: 30(-)

diff --git a/bin/service b/bin/service @@ -49,27 +49,27 @@ doservice() a*d) activated=1 if [ "${service}" = "all" ] || [ -z "${service}" ]; then nooutcome=1 - svc -a + svc -a 2>/dev/null else msg serv "Service %s activated?\t\t\t" ${service##*/} - svc -ad "${service}" + svc -ad "${service}" 2>/dev/null fi;; a*) msg serv "Activating %s\t\t\t" ${service##*/} - svc -a "${service}";; + svc -a "${service}" 2>/dev/null;; d*) msg serv "Deactivating %s\t\t\t" ${service##*/} - svc -d "${service}";; + svc -d "${service}" 2>/dev/null;; e*) msg serv "Exists %s?\t\t\t" ${service##*/} exists=1 - svc -e "${service}";; + svc -e "${service}" 2>/dev/null;; l*) nooutcome=1 svc -l;; sta*) msg serv "Starting %s\t\t\t" ${service##*/} - svc -s "${service}";; + svc -s "${service}" 2>/dev/null;; sto*) stop=1 msg serv "Stopping %s\t\t\t" ${service##*/} - svc -k "${service}";; + svc -k "${service}" 2>/dev/null;; r*) msg serv "Restarting %s\t\t\t" ${service##*/} - svc -r "${service}";; + svc -r "${service}" 2>/dev/null;; *) msg serv "What to do with %s?\t\t\t" ${service##*/} seterrno 3;; esac diff --git a/bin/svc b/bin/svc @@ -39,10 +39,10 @@ runservice() { if [ $(stat -L -t "${dir}/${service}" | cut -d' ' -f 2) -eq 0 ]; then - "./bare.sh" "${service}" "${cmd}" >/dev/null 2>&1 + "./bare.sh" "${service}" "${cmd}" return $? else - "${dir}/${service}" "${cmd}" >/dev/null 2>&1 + "${dir}/${service}" "${cmd}" return $? fi } @@ -71,14 +71,15 @@ doservice() { } case "$1" in - -ad) if [ ! -L "run/$2" ]; then + -ad) if [ $# -lt 2 ]; then + printf "%s: No service given\n" "${BASENAME}" >&2 + exit 2 + elif [ ! -L "run/$2" ]; then exit 2 fi;; -a) if [ $# -gt 1 ] && [ -e "avail/$2" ]; then ln -sf "../avail/$2" "run/$2" - #printf "%s: '%s' activated.\n" \ - # "${BASENAME}" "$2" else cd run ls . @@ -87,17 +88,21 @@ case "$1" in [ -d "$BASEDIR/avail" ] || mkdir -p "$BASEDIR/avail" [ -d "$BASEDIR/default" ] || mkdir -p "$BASEDIR/default" [ -d "$BASEDIR/run" ] || mkdir -p "$BASEDIR/run";; - -d) if [ $# -gt 1 ] && [ -e "run/$2" ]; + -d) if [ $# -gt 1 ] && [ -L "run/$2" ]; then rm -f "run/$2" - #printf "%s: '%s' deactivated.\n" \ - # "$BASENAME" "$2" else printf "%s: No service given or service is not marked "\ "as to run.\n" "$BASENAME" >&2 exit 2 fi;; - -e|-k|-s|-r) + -e) if [ $# -lt 2 ]; then + printf "%s: No service given\n" "${BASENAME}" >&2 + exit 2 + else + doservice "$1" "$2" + fi;; + -k|-s|-r) doservice "$1" "$2";; -l) cd avail ls .;; diff --git a/man/man8/svc.8 b/man/man8/svc.8 @@ -7,11 +7,10 @@ .Sh SYNOPSIS .Nm .Op Fl acdeklrs | ad -.Op Ar service | Cm all +.Op Ar service .Sh DESCRIPTION -Most of the options accept either the service name or the special keyword -.Dq Cm all , -which applies the operation to all the related services. +Most of the options accept either the service name or, if omitted, apply the +operation to all the related services. . .Bl -tag -width ".Nm Fl a" -offset indent . @@ -19,7 +18,7 @@ which applies the operation to all the related services. lists all activated services in .Pa /bin/svc.d/run . . -.It Nm Fl a Op Ar service | Cm all +.It Nm Fl a Op Ar service activates the service .Dq Ar service . . @@ -35,30 +34,42 @@ configures by creating the necessary subdirectories of .Pa /bin/svc.d . . -.It Nm Fl d Op Ar service | Cm all +.It Nm Fl d Op Ar service deactivates the service .Dq Ar service . . -.It Nm Fl e Op Ar service | Cm all +.It Nm Fl e Op Ar service checks if the service .Dq Ar service is running .Pq Dq exists . . -.It Nm Fl k Op Ar service | Cm all +.It Nm Fl k stops .Pq Dq kills -the service. +all active services. +. +.It Nm Fl k Op Ar service +stops the service +.Dq Ar service . . .It Nm Fl l lists all available (not necessarily activated) services in the directory .Pa /bin/svc.d/avail . . -.It Nm Fl r Op Ar service | Cm all -restarts the service. +.It Nm Fl r +restarts all active services. +. +.It Nm Fl r Op Ar service +restarts the service +.Dq Ar service . +. +.It Nm Fl s +starts all active services. . -.It Nm Fl s Op Ar service | Cm all -starts the service. +.It Nm Fl s Op Ar service +starts the service +.Dq Ar service . .El .Sh FILES .Bl -tag -width ".Pa /bin/svc.d/bin"