kelsowx
Posts: 3
Joined: Sun Apr 21, 2013 12:49 pm

Run Levels and Daemon

Sun Apr 21, 2013 1:02 pm

Hi all. I am a new user of Raspberry Pi and new to Linux/Debian, but used to using terminal etc on Macs.

I bought a new RaspberryPi to use to detect lightning using some specialised kits. I have installed Raspbian Wheezy and the R Pi is working fine.

The script I need to install and run is here
http://www.google.com/translate?hl=en&i ... 3Fp%3D1289 (original in German)

I have managed to download the script but can't tell if it is running or of the script needs modification. I changed its name from flashtd.txt to flashtd.

The script is reproduced below. I have copied it to flashtd in etc/init.d. I attempted to enable it with "chkconfig flashtd on" but that command does not work so I used "update-rc.d flashtd enable" which gives me this error "update-rc.d: error: flashtd Default-Start contains no runlevels, aborting."

Can anyone assist me with this?

David

#!/bin/sh
#
### BEGIN INIT INFO
# Provides: flashtd
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: flashtd
# Description: Blitzortung.org Flash-Tracker-Daemon
### END INIT INFO

# chkconfig: 2345 99 01
# Author: Stefan Rueetschli ([email protected], http://www.steffr.ch)
# File: flashtd
# Date: 15.11.2012
#
# Edit the variables to your needs and
# copy this script to /etc/init.d
# Register with "chkconfig <scriptname> on"
#
###############################################################

PROGDIR="/home/pi/blitzortung/" # Path to the blitzortung-tracker program
PROGNAME="blitzortung_tracker" # Name of the blitzortung-tracker program
LOGFILE="-ll /var/log/blitzortung.log" # Path and Logfile name
PIDFILE="/home/pi/blitzortung/flashtd.pid" # File for storing the PID
LOCKDIR="/var/lock/" # Path to the lock-dir
LOCKFILE="flashtd.lck" # Name of the lock-file

# Set your GPS-Module
#GPSTYPE="SNAV"
#GPSTYPE="Garmin"
GPSTYPE="SiRF"

#SBAS="-s"

#BAUDRATE="4800"
#BAUDRATE="9600"
#BAUDRATE="19200"
#BAUDRATE="38400"

# Set your USB-Device
DEVICE="/dev/ttyUSB0"
#DEVICE="/dev/ttyS1"

# Blitzortung.org Username & Password
BO_USERNAME="USER"
BO_PASSWORD="PASS"

# Your Region (1=Europe, 2=Oceanien, 3=USA, 4=Japan)
REGION="1"

###############################################################

COMMAND="sudo $PROGDIR$PROGNAME $LOGFILE $SBAS $GPSTYPE $BAUDRATE $DEVICE $BO_USERNAME $BO_PASSWORD $REGION"

###############################################################

# Get PID
pid_tracker(){
if test ! -f $PIDFILE; then
#echo "No PIDFILE found."
return 1
fi
trackerPID=`head -n 1 $PIDFILE`
return 0
}


# Get Status
status_tracker (){
pid_tracker
if ps -p $trackerPID > /dev/null 2>&1; then
# The Tracker is already running...
return 0
else
# The Tracker is not running
return 1
fi
}

printstatus_tracker(){
if status_tracker $1 $2; then
echo "$PROGNAME (pid $trackerPID) is running..."
else
echo "$PROGNAME is not running."
fi
}

kill_tracker(){
sudo kill $2 $trackerPID
}

PATH=/bin:/usr/bin:/sbin:/usr/sbin

case "$1" in
start)
status_tracker
if [ $? -eq 0 ]; then
echo "$PROGNAME already started..."
exit 1
fi
echo -n "Starting $PROGNAME..."
#echo "$COMMAND"
$COMMAND &
if [ -d $LOCKDIR ]; then
touch $LOCKDIR/$LOCKFILE
touch $PIDFILE
echo $! > $PIDFILE
else
mkdir $LOCKDIR
touch $LOCKDIR/$LOCKFILE
touch $PIDFILE
echo $! > $PIDFILE
fi
echo "done."
exit 0
;;
stop)
status_tracker
if [ $? -eq 1 ]; then
echo "$PROGNAME is not running... could not stop"
exit 1
fi
echo -n "Stopping $PROGNAME..."
pid_tracker
kill_tracker $PROGNAME
rm -f $LOCKDIR/$LOCKFILE
rm -f $PIDFILE
echo "done."
;;
restart)
$0 stop
$0 start
;;
status)
printstatus_tracker
;;
*)
echo "Usage: ... {start|stop|restart|status}"
exit 1
;;
esac

exit 0

kelsowx
Posts: 3
Joined: Sun Apr 21, 2013 12:49 pm

Re: Run Levels and Daemon

Mon Apr 22, 2013 4:44 am

Any advice as to how I ensure this script is running, would be appreciated.

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Run Levels and Daemon

Mon Apr 22, 2013 5:04 am

running "pidof blitzortung_tracker" will give you a PID if it's running, or no output at all if it's not running.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

kelsowx
Posts: 3
Joined: Sun Apr 21, 2013 12:49 pm

Re: Run Levels and Daemon

Mon Apr 22, 2013 5:09 am

Hi. thanks for your reply, but I have no idea what your reply means

bugloss
Posts: 22
Joined: Fri Jan 04, 2013 2:44 pm
Contact: Website

Re: Run Levels and Daemon

Mon Apr 22, 2013 9:05 am

http://www.youtube.com/watch?v=omK2Rht3Mwo

Watch this video and you'll [email protected] 11.00 or there abouts what you need to do if you want to see if a programme is running.

Type: ps aux | less

R+ by your programme says it's running

less shows one page at a time press space bar to view the next screen and b to go back a screen.

Or type: top

which shows whats happening in real time. You need to be root to view all this stuff.

ctrl c to exit

Adam
http://www.adamwilson.co

bugloss
Posts: 22
Joined: Fri Jan 04, 2013 2:44 pm
Contact: Website

Re: Run Levels and Daemon

Mon Apr 22, 2013 5:16 pm

Edit 1
You don't need to be root to see all this stuff.
A
http://www.adamwilson.co

Return to “Beginners”