This repository has been archived on 2025-02-12. You can view files and clone it, but cannot push or open issues or pull requests.
NeoStats/neostats.in

132 lines
3.2 KiB
Text
Raw Normal View History

2000-06-10 09:14:03 +00:00
#!/bin/sh
#
2005-02-06 10:35:19 +00:00
# NeoStats Startup Script
2003-09-22 13:13:25 +00:00
# $Id: cronchk 583 2003-09-20 10:35:54Z Fish $
2000-06-10 09:14:03 +00:00
#
2005-02-06 10:35:19 +00:00
# This is a script suitable for use in a crontab or starting NeoStats
# It checks to make sure NeoStats is configured correctly
# and also starts/stops NeoStats, and checks that neostats is running from
# when executed frm cron.
2000-06-10 09:14:03 +00:00
#
2005-02-06 10:35:19 +00:00
# To Start NeoStats, just execute this script
#
# To check that neostats is running, put the following line in your
2000-06-10 09:14:03 +00:00
# crontab:
2005-02-06 10:35:19 +00:00
# 0,10,20,30,40,50 * * * * @prefix@/neostats -c
2000-06-10 09:14:03 +00:00
# change this to the mail address to mail output to:
#MAIL=me
2005-02-06 10:35:19 +00:00
###############################################################################
# End of User Configuration
# Do Not edit anything below this line
###############################################################################
2000-06-10 09:14:03 +00:00
# change this to the directory you run your ircd from:
2005-02-06 10:35:19 +00:00
dir="@prefix@"
2000-06-10 09:14:03 +00:00
2002-10-24 14:28:26 +00:00
# change this to the name of your Neostats file in that directory:
2005-02-06 10:35:19 +00:00
ircdexe="/bin/neostats"
# Neostats config file
cfgfile="neostats.conf"
2000-06-10 09:14:03 +00:00
# I wouldn't touch this if I were you.
2005-02-06 10:35:19 +00:00
pidfile="neostats.pid"
2000-06-10 09:14:03 +00:00
########## you probably don't need to change anything below here ##########
2005-02-06 10:35:19 +00:00
if [ "$1" = "-c" ] ; then
# Check From Cron
shift;
2005-02-06 10:35:19 +00:00
if test -r $dir/$pidfile; then
# there is a pid file -- is it current?
2006-05-16 16:47:58 +00:00
ircdpid=`cat $dir/$pidfile`
2005-02-06 10:35:19 +00:00
if `kill -CHLD $ircdpid >/dev/null 2>&1`; then
# it's still going
# back out quietly
exit 0
fi
echo "NeoStats Crontab notice:"
echo ""
echo "Stale $ircdname file (erasing it)"
rm -f $dir/$pidfile
fi
if test -r $dir/$cfgfile; then
echo ""
echo "Couldn't find NeoStats running. Reloading it..."
echo ""
cd $dir
$dir/$ircdexe $@
2005-02-06 10:35:19 +00:00
else
echo ""
echo "NeoStats is not configured. Not Loading it..."
echo ""
fi
exit 0
elif [ "$1" = "start" ] ; then
#start NeoStats from command line
#first check if its running or not
shift;
2005-02-06 10:35:19 +00:00
if test -r $dir/$pidfile; then
# there is a pid file -- is it current?
2006-05-16 16:47:58 +00:00
ircdpid=`cat $dir/$pidfile`
2005-02-06 10:35:19 +00:00
if `kill -CHLD $ircdpid >/dev/null 2>&1`; then
# NeoStats is already running
echo ""
echo "NeoStats is already Running, Not starting another copy"
exit 0
fi
# remove the old pid file
rm -f $dir/$pidfile
fi
if test -r $dir/$cfgfile; then
echo ""
echo "Starting NeoStats..."
echo ""
cd $dir
$dir/$ircdexe $@
2005-02-06 10:35:19 +00:00
else
echo ""
echo "NeoStats is not configured. Running Config Script..."
echo ""
sleep 2
$dir/bin/makeconf $dir/$cfgfile
if test -r $dir/$cfgfile; then
echo ""
echo "Ok, Starting NeoStats ..."
echo ""
cd $dir
$dir/$ircdexe $@
2005-02-06 10:35:19 +00:00
fi
fi
exit 0
elif [ "$1" = "stop" ] ; then
#stop Neostats
if test -r $dir/$pidfile; then
# there is a pid file -- is it current?
2006-05-16 16:47:58 +00:00
ircdpid=`cat $dir/$pidfile`
2005-02-06 10:35:19 +00:00
if `kill -CHLD $ircdpid >/dev/null 2>&1`; then
# NeoStats is already running
kill -TERM $ircdpid
echo ""
echo "NeoStats sent Term Signal"
tail -n 5 $dir/logs/neostats.log
rm -f $dir/$pidfile
exit 0
fi
# remove the old pid file
echo "Couldn't find a copy of NeoStats running"
rm -f $dir/$pidfile
exit 0;
fi
elif [ "$1" = "version" ] ; then
$dir/$ircdexe -v
exit 0
elif [ "$1" = "help" ] ; then
$dir/$ircdexe -h
exit 0
2005-02-06 10:35:19 +00:00
else
echo "Usage: $0 -c|start|stop|version|help <options>"
2000-06-10 09:14:03 +00:00
fi
2005-02-06 10:35:19 +00:00