On 3/15/21 4:53 PM, Scott Andrews wrote:
#! /bin/sh
VERSION="$(basename ${0}) verison: 2021-03-15"
USAGE="Usage: $(basename ${0}) < option > | --status | [ service_name [ command | 
--restart ] ]"
SERVICEDIR="/etc/init.d"
SERVICE=''
OPTIONS=''

if [ ${#} -eq 0 ]; then echo "${USAGE}" >&2; exit 1; fi
while [ ${#} -gt 0 ]; do
    case "${1}" in
       --help | -h | --h* ) echo "${USAGE}" >&2; exit 0; ;;
       --version | -V ) echo "${VERSION}" >&2; exit 0;   ;;
       *) if [ -z "${SERVICE}" -a ${#} -eq 1 -a "${1}" = "--status" ]; then
             cd ${SERVICEDIR}
             for SERVICE in * ; do
                case "${SERVICE}" in
                   checkfs) :; ;;
                   cleanfs) :; ;;
                   console) :; ;;
                   fake-hwclock) :; ;;
                   halt) :; ;;
                   localnet) :; ;;
                   modules) :; ;;
                   mountfs) :; ;;
                   mountvirtfs) :; ;;
                   network) :; ;;
                   rc) :; ;;
                   reboot) :; ;;
                   sendsignals) :; ;;
                   swap) :; ;;
                   switch-cpu-governor) :; ;;
                   sysctl) :; ;;
                   template) :; ;;
                   udev) :; ;;
                   udev_retry) :; ;;
                   *) if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
                         env-i PATH="$PATH" TERM="$TERM" 
"${SERVICEDIR}/${SERVICE}" status;
                      fi; ;;
                esac
             done
             exit 0
          elif [ ${#} -eq 2 -a "${2}" = "--restart" ]; then
             SERVICE="${1}"
             if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
                env -i PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" stop
                env -i PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" 
start exit ${?}
             fi
          elif [ -z "${SERVICE}" ]; then
             SERVICE="${1}"
          else
             OPTIONS="${OPTIONS} ${1}"
          fi
          shift
       ;;
    esac
done
if [ -f "${SERVICEDIR}/${SERVICE}" ]; then
    env -i PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" ${OPTIONS}
else
    echo $"${SERVICE}: unrecognized service" >&2
    exit 1
fi


Looks nice, care to explain a bit where this could go and how it should be called?

Bye
Tim
--
http://lists.linuxfromscratch.org/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Do not top post on this list.

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

http://en.wikipedia.org/wiki/Posting_style

Reply via email to