[Prelude Hybrid IDS] #190: Bare bones redhat-style init script for prelude-lml
"Prelude Hybrid IDS" <[email protected]>
| Newsgroups | gmane.comp.security.ids.prelude.devel |
|---|---|
| Message-ID | <[email protected]> |
#190: Bare bones redhat-style init script for prelude-lml
-------------------------+--------------------------------------------------
Reporter: anonymous | Owner: yoann
Type: enhancement | Status: new
Priority: low | Milestone: Prelude-LML 0.9.9
Component: prelude-lml | Version: 0.9
Severity: minor | Keywords:
-------------------------+--------------------------------------------------
#!/bin/sh[[BR]]
#[[BR]]
# A barebones redhat-style startup script for prelude-lml [[BR]]
#[[BR]]
# chkconfig: 345 99 10[[BR]]
# description: Start/Stop prelude-lml as a daemon server[[BR]]
# pidfile: /var/run/prelude-lml.pid[[BR]]
# lockfile: /var/lock/subsys/prelude-lml[[BR]]
#[[BR]]
# Usage /etc/init.d/prelude-lml
{start|stop|restart|status|condrestart}[[BR]]
[[BR]]
prog=prelude-lml[[BR]]
exe=/usr/local/bin/prelude-lml[[BR]]
PIDFILE=/var/run/${prog}.pid[[BR]]
LOCKFILE=/var/lock/subsys/${prog}[[BR]]
[[BR]]
# Source function library.[[BR]]
. /etc/rc.d/init.d/functions[[BR]]
[[BR]]
# Source networking configuration.[[BR]]
. /etc/sysconfig/network[[BR]]
[[BR]]
# Check that networking is up.[[BR]]
[ ${NETWORKING} = "no" ] && exit 0[[BR]]
[[BR]]
# Minimize PATH passed on[[BR]]
PATH=/bin:/sbin[[BR]]
export PATH[[BR]]
[[BR]]
[[BR]]
start()[[BR]]
{
echo -ne "\rStarting ${prog} : "[[BR]]
if [ -f ${LOCKFILE} ] ; then[[BR]]
echo -ne "Lock file exists :" && echo_failure[[BR]]
echo[[BR]]
exit -1;[[BR]]
fi[[BR]]
touch ${LOCKFILE} >> /dev/null 2>&1[[BR]]
if [ ! -f ${LOCKFILE} ] ; then[[BR]]
echo -ne "Cannot create lock file :" && echo_failure[[BR]]
echo[[BR]]
exit -1;[[BR]]
fi[[BR]]
$exe --daemon --pidfile=${PIDFILE} && echo_success[[BR]]
echo[[BR]]
return $RETVAL[[BR]]
}
[[BR]]
stop()[[BR]]
{[[BR]]
echo -ne "\rStopping ${prog} :"[[BR]]
killproc ${exe}[[BR]]
RETVAL=${?}[[BR]]
[ ${RETVAL} = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}[[BR]]
echo[[BR]]
return ${RETVAL}[[BR]]
}[[BR]]
[[BR]]
[[BR]]
condrestart()[[BR]]
{[[BR]]
[ -e ${LOCKFILE} ] && restart || :[[BR]]
}[[BR]]
[[BR]]
[[BR]]
[[BR]]
if [ ! -x ${exe} ] ; then[[BR]]
echo -n "No such service ${prog} : "[[BR]]
if [ ! -f ${exe} ] ; then[[BR]]
echo -n "No such executable ${exe}" && echo_failure[[BR]]
else[[BR]]
echo -n "Insufficient permissions for ${exe}" &&
echo_failure[[BR]]
fi[[BR]]
exit -1[[BR]]
fi[[BR]]
[[BR]]
case "${1}" in[[BR]]
start)[[BR]]
start[[BR]][[BR]]
;;[[BR]]
[[BR]]
stop)[[BR]]
stop[[BR]]
;;[[BR]]
[[BR]]
restart)[[BR]]
stop[[BR]]
start[[BR]]
;;[[BR]]
[[BR]]
status)[[BR]]
status ${exe}[[BR]]
RETVAL=${?}[[BR]]
;;[[BR]]
[[BR]]
condrestart)[[BR]]
condrestart[[BR]]
;;[[BR]]
[[BR]]
*)[[BR]]
echo "Usage: /etc/init.d/${prog}
{start|stop|restart|status|condrestart}"[[BR]]
exit -1[[BR]]
esac[[BR]]
[[BR]]
exit ${RETVAL}[[BR]]
--
Ticket URL: <https://trac.prelude-ids.org/ticket/190>
Prelude Hybrid IDS <http://www.prelude-ids.org>
The Prelude Hybrid Intrusion Detection System suite
_______________________________________________
Prelude-devel site list
[email protected]
http://www.prelude-ids.org/mailman/listinfo/prelude-devel