-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathneostats.in
More file actions
131 lines (123 loc) · 3.23 KB
/
neostats.in
File metadata and controls
131 lines (123 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/sh
#
# NeoStats Startup Script
# $Id: cronchk 583 2003-09-20 10:35:54Z Fish $
#
# 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.
#
# To Start NeoStats, just execute this script
#
# To check that neostats is running, put the following line in your
# crontab:
# 0,10,20,30,40,50 * * * * @prefix@/neostats -c
# change this to the mail address to mail output to:
#MAIL=me
###############################################################################
# End of User Configuration
# Do Not edit anything below this line
###############################################################################
# change this to the directory you run your ircd from:
dir="@prefix@"
# change this to the name of your Neostats file in that directory:
ircdexe="/bin/neostats"
# Neostats config file
cfgfile="neostats.conf"
# I wouldn't touch this if I were you.
pidfile="neostats.pid"
########## you probably don't need to change anything below here ##########
if [ "$1" = "-c" ] ; then
# Check From Cron
shift;
if test -r $dir/$pidfile; then
# there is a pid file -- is it current?
ircdpid=`cat $dir/$pidfile`
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 $@
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;
if test -r $dir/$pidfile; then
# there is a pid file -- is it current?
ircdpid=`cat $dir/$pidfile`
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 $@
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 $@
fi
fi
exit 0
elif [ "$1" = "stop" ] ; then
#stop Neostats
if test -r $dir/$pidfile; then
# there is a pid file -- is it current?
ircdpid=`cat $dir/$pidfile`
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
else
echo "Usage: $0 -c|start|stop|version|help <options>"
fi