Just something thrown together quickly for use with our Ubuntu 8.04 LTS systems to initialize the card and configure it on boot. You must set CONFIG to be your config file or else the script will just exit. This init script assumes you have only one card in the box and it is ntxc0. Don’t forget to create your symlinks S##napatech and K##napatech into your /etc/rc*.d/ directories. Also don’t forget to ensure that your IDS processes are starting up after this gets loaded or else the ntxc0:# streams won’t be available to monitor. The “status” command pulls the log entries from the card. If running that status command yeilds >>> Error: No adapters could be found., then the driver is not loaded.
#!/bin/sh -e #### BEGIN INT INFO # Provides: Napatech # Required-Start: mountkernfs $local_fs # Required-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: S 0 1 6 # Short-Description: Loads Napatech network card # Description: Napatech kernel driver and configuration ### END INIT INFO # # Author: Eoin Miller (eoin[dot]miller[at]trojanedbinaries[dot]com) # set -e
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/napatech/bin LOAD="/opt/napatech/bin/load_driver.sh" UNLOAD="/opt/napatech/bin/unload_driver.sh" UTIL="/opt/napatech/bin/bash_loadunload" CONFIG="/opt/napatech/config/customconfig.cfg" DRIVER="/opt/napatech/driver/ntki.ko"
if [ ! -x $LOAD ];then echo "File: $LOAD missing or not executable!" exit 1 fi if [ ! -x $UNLOAD ];then echo "File: $UNLOAD missing or not executable!" exit 1 fi if [ ! -e $UTIL ];then echo "File: $UTIL missing!" exit 1 fi if [ ! -e $CONFIG ];then echo "File: $CONFIG missing!" exit 1 fi if [ ! -e $DRIVER ];then echo "File: $DRIVER missing!" exit 1 fi
. /lib/lsb/init-functions
case "$1" in
start)
log_daemon_msg "Starting Napatech network card:" "Napatech"
$LOAD ntxc0=$CONFIG > /dev/null
log_end_msg $?
;;
stop)
log_daemon_msg "Stopping Napatech network card:" "Napatech"
$UNLOAD > /dev/null
log_end_msg $?
;;
status)
DriverLog -mask=0x04
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: /etc/init.d/napatech {start|stop|status|restart}"
exit 0
;;
esac
exit 0
After this file has been put into /etc/init.d/napatech, you can create your symbolic links as so to stop/start the card and driver as appropriate:
ln -s /etc/init.d/napatech /etc/rc2.d/S12napatech ln -s /etc/init.d/napatech /etc/rc3.d/S12napatech ln -s /etc/init.d/napatech /etc/rc4.d/S12napatech ln -s /etc/init.d/napatech /etc/rc5.d/S12napatech ln -s /etc/init.d/napatech /etc/rc0.d/K12napatech ln -s /etc/init.d/napatech /etc/rc1.d/K12napatech ln -s /etc/init.d/napatech /etc/rc6.d/K12napatech
