чување e6d518f4e0e60216ecf0a62f17176b1453ef0ee9
родитељ 27cc005aee77455890de4eaf88cfc0f07c19c177
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Thu, 21 Jul 2022 17:43:21 +0200
Simplify sdhcp; add explanation for operation short forms
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 4, додавања: 33(+), брисања: 42(-)
diff --git a/bin/service b/bin/service
@@ -27,7 +27,7 @@ usage()
"sta(rt)|sto(p)|r(estart)] [service|all]\n" "${0##*/}" >&2
}
-if [ $# -lt 2 ]; then
+if [ $# -lt 1 ]; then
usage
exit 2
fi
@@ -47,7 +47,7 @@ doservice()
case "${cmd}" in
a*d) activated=1
- if [ "${service}" = "all" ]; then
+ if [ "${service}" = "all" ] || [ -z "${service}" ]; then
nooutcome=1
svc -a
else
diff --git a/man/man8/service.8 b/man/man8/service.8
@@ -12,6 +12,17 @@
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.
+.Pp
+Operation names can be abbreviated to the shortest distinctive form, eg. instead
+of
+.Cm activated ,
+one can use
+.Cm ad ,
+but not
+.Cm act ,
+as that is the abbreviation for
+.Cm activate .
+The parts which can be omitted are given here in brackets.
.
.Bl -tag -width ".Nm Fl a" -offset indent
.
@@ -80,7 +91,7 @@ and related commands were made by Cristoph Lohmann in 2012. The version used in
Galeb is heavily modified and documented by Strahinya Radich in 2022.
.Sh AUTHORS
.An "Cristoph Lohmann" Aq 20h@r-36.net ,
-2012-2014 original author
+2012-2014, original author
.An "Strahinya Radich" Aq contact@strahinja.org ,
2022, reorganized
.Xr svc
diff --git a/man/man8/svc.8 b/man/man8/svc.8
@@ -93,7 +93,7 @@ and related commands were made by Cristoph Lohmann in 2012. The version used in
Galeb is heavily modified and documented by Strahinya Radich in 2022.
.Sh AUTHORS
.An "Cristoph Lohmann" Aq 20h@r-36.net ,
-2012-2014 original author
+2012-2014, original author
.An "Strahinya Radich" Aq contact@strahinja.org ,
2022, reorganized
.Nm
diff --git a/svc.d/avail/sdhcp b/svc.d/avail/sdhcp
@@ -10,50 +10,30 @@ if [ -z "${PIDFILE}" ]; then
fi
case $1 in
- -e) set -x
- if [ ! -e "${PIDFILE}" ]; then
+ -e) if [ ! -e "${PIDFILE}" ]; then
exit 2
elif [ -z "$(ps -ef | awk '{print $2}' | \
grep $(<"${PIDFILE}"))" ]; then
exit 2
- fi
- set +x;;
- -s) ${svcbin} ${PARAMS} >/dev/null 2>&1 &;;
- -k) set -x
- if [ ! -e "${PIDFILE}" ]; then
- exit 1
- elif [ -z "$(ps -ef | awk '{print $2}' | \
- grep $(<"${PIDFILE}"))" ]
- then
- rm "${PIDFILE}"
- exit 1
- else
- kill $(<"${PIDFILE}") >/dev/null 2>&1
- if [ -n "$(ps -ef | awk '{print $2}' | \
- grep $(<"${PIDFILE}"))" ]
- then
- kill -9 $(<"${PIDFILE}") >/dev/null 2>&1 \
- || exit 2
- fi
- rm "${PIDFILE}"
- fi
- ps -ef | grep sdhcp
- set +x;;
- -r) if [ -e "${PIDFILE}" ]; then
- if [ -z "$(ps -ef | awk '{print $2}' | \
- grep $(<"${PIDFILE}"))" ]
- then
- rm "${PIDFILE}"
- else
- kill $(<"${PIDFILE}") >/dev/null 2>&1
+ fi;;
+ -s) svc -e ${svc}
+ case $? in
+ 0) return 1;;
+ 2) ${svcbin} ${PARAMS} >/dev/null 2>&1 &;;
+ *) return $?;;
+ esac;;
+ -k) svc -e ${svc}
+ case $? in
+ 2) return 1;;
+ 0) kill $(<"${PIDFILE}") >/dev/null 2>&1
if [ -n "$(ps -ef | awk '{print $2}' | \
grep $(<"${PIDFILE}"))" ]
then
- kill -9 $(<"${PIDFILE}") \
- >/dev/null 2>&1 || exit 2
+ kill -9 $(<"${PIDFILE}") >/dev/null \
+ 2>&1 || exit 2
fi
- rm "${PIDFILE}"
- fi
- fi
- ${svcbin} ${PARAMS} >/dev/null 2>&1 &;;
+ rm "${PIDFILE}";;
+ esac;;
+ -r) svc -k ${svc}
+ svc -s ${svc};;
esac