From eea0514f13d5895f0aa28de82fcb91945406cbfb Mon Sep 17 00:00:00 2001 From: sandb Date: Fri, 5 Feb 2010 00:36:01 +0100 Subject: [PATCH] pamela (ubuntu) start/stop script for the scanner --- extras/pamela | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100755 extras/pamela diff --git a/extras/pamela b/extras/pamela new file mode 100755 index 0000000..1660773 --- /dev/null +++ b/extras/pamela @@ -0,0 +1,128 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: skeleton +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Pamela arp scanner +# Description: Scans the mac adresses in the local network every +# 120 secs and uploads to pamela on hackerspace.be +### END INIT INFO + +# Author: sandb +# +# Please remove the "Author" lines above and replace them +# with your own name if you copy and modify this script. + +<. + +LICENSE + +# Do NOT "set -e" + +# PATH should only include /usr/* if it runs after the mountnfs.sh script +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="Pamela arp-scanner" +NAME=pamela-scanner.sh +DAEMON=/opt/pamela/$NAME +DAEMON_ARGS="-i wlan0" +PID="$(pidof pamela-scanner.sh)" +SCRIPTNAME=/etc/init.d/$NAME +LOGFILE=/opt/pamela/pamela.log + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + do_stop + $DAEMON $DAEMON_ARGS 2>&1 >> $LOGFILE & +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + killall -q "$NAME" || return 1 +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + restart|force-reload) + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: