Port of "service" command
Freddie Cash
fjwcash at gmail.com
Tue Jun 9 18:54:04 UTC 2009
On Tue, Jun 9, 2009 at 10:46 AM, Edwin Shao <eshao at ring0.org> wrote:
> I was wondering if there was a port of the Linux/UNIX service
> <http://www.manpagez.com/man/8/service/>,
> <http://linux.die.net/man/8/service> command? If not, is there any
> philosophical reason or roadblock to my creating one?
>
What's there to port? A simple shell script like the following will work:
#!/bin/sh
if [ -z "$2" ]; then
echo "Missing action."
echo "Usage: $( basename ${0} ) {service}
{start|stop|restart|reload|status}"
exit 2
elif [ -z "$1" ]; then
echo "Missing service name."
echo "Usage: $( basename ${0} ) {service}
{start|stop|restart|reload|status}"
exit 1
fi
if [ -x /usr/local/etc/rc.d/${1}.sh ]; then
runcmd="/usr/local/etc/rc.d/${1}.sh ${2}"
elif [ -x /usr/local/etc/rc.d/${1} ]; then
runcmd="/usr/local/etc/rc.d/${1} ${2}"
elif [ -x /etc/rc.d/${1}.sh ]; then
runcmd="/etc/rc.d/${1}.sh ${2}"
elif [ -x /etc/rc.d/${1} ]; then
runcmd="/etc/rc.d/${1} ${2}"
else
runcmd=""
fi
if [ -n "${runcmd}" ]; then
echo "Running command: ${runcmd}"
${runcmd}
retval=$?
else
echo "No rc.d script found for ${1}"
retval=3
fi
exit ${retval}
I'm pretty sure something like this was discussed on one of the mailing
lists in the past year, as well. You may want to search the archives for
ports@, hackers@, and stable at .
--
Freddie Cash
fjwcash at gmail.com
More information about the freebsd-ports
mailing list