[root]# vim /etc/rc.d/init.d/snortd
#!/bin/sh # chkconfig: 35 91 35 # description: snort start or stop SERVICE='/usr/local/bin/snort' OPTION='-A fast -c /etc/snort/etc/snort.conf -l /var/log/snort --pid-path /var/log/snort -b -d -g snort -u snort -D' PIDFILE='/var/log/snort/snort_eth0.pid' if [ ! -x $SERVICE ]; then exit 1 fi function start () { $SERVICE $OPTION echo 'snort start...' RETVAL=$? } function stop () { kill `cat $PIDFILE` echo 'snort stop...' RETVAL=$? } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; *) echo $"Usage: $0 {start|stop|restart}" RETVAL=1 ;; esac exit $RETVAL・パーミッション変更
[root]# chmod 755 /etc/rc.d/init.d/snortd
・起動/停止[root]# service snortd { start stop restart }
・自動起動/停止[root]# chkconfig --add snortd
[root]# chkconfig snortd { on off }