On Tuesday 18 February 2003 8:56 am, Alexander Futasz wrote:
> On Tue, 18 Feb 2003 08:48:17 -0500, Phil Barnett wrote:
> > What I miss in Gentoo is the simple format for services like found in
> > Redhat and many others, ie:
> >
> > service servicename stop/start/restart
> >
> > It eliminates needing to know where the service directory is or
> > including it every time.
> >
> > service httpd stop
> >
> > is a lot easier than any other incarnation and make any system easier
> > to admin.
>
> <shellscript>
> #!/bin/sh
> /etc/init.d/$1 $2
> </shellscript>
>
> put that in /usr/sbin or whereever you like, name it "service", give it
> the right permissions and you will have the functionality you described.
>
> i read that before on the list, so it must be somewhere on the archives
> too.

Well, there's two points to make here.

1. It should be part of Gentoo, not some hack that I put together.

2. The RH service script does a whole lot more than that, take a look, it's 
gpl...

[root@gizmo root]# cat /sbin/service
#!/bin/sh

# Set up a default search path.
PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"
export PATH

VERSION="`basename $0` ver. 0.91"
USAGE="Usage: `basename $0` < option > | --status-all | \
[ service_name [ command | --full-restart ] ]"
SERVICE=
SERVICEDIR="/etc/init.d"

if [ $# -eq 0 ]; then
   echo $"${USAGE}" >&2
   exit 1
fi

cd /
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-all" ]; then
          cd ${SERVICEDIR}
          for SERVICE in * ; do
            case "${SERVICE}" in
              functions | halt | killall | single| linuxconf| kudzu | \
                  *rpmorig | *rpmnew | *rpmsave | *~ | *.orig)
                  ;;
              *)
                if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
                  env -i LANG=$LANG PATH=$PATH "${SERVICEDIR}/${SERVICE}" 
status
                fi
                ;;
            esac
          done
          exit 0
       elif [ $# -eq 2 -a "${2}" = "--full-restart" ]; then
          SERVICE="${1}"
          if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
            env -i LANG=$LANG PATH=$PATH "${SERVICEDIR}/${SERVICE}" stop
            env -i LANG=$LANG PATH=$PATH "${SERVICEDIR}/${SERVICE}" start
            exit $?
          fi
       elif [ -z "${SERVICE}" ]; then
         SERVICE="${1}"
       else
         OPTIONS="${OPTIONS} ${1}"
       fi
       shift
       ;;
   esac
done

if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
   env -i LANG=$LANG PATH=$PATH "${SERVICEDIR}/${SERVICE}" ${OPTIONS}
else
   echo $"${SERVICE}: unrecognized service" >&2
   exit 1
fi


--
[EMAIL PROTECTED] mailing list

Reply via email to