blob: 3a3ede6adae8c40a61f37c2dbf8211ded095915e (
plain)
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
|
#!/bin/sh
#
# pingcntl: echolot control + wrapper
# Written by admin@arancio.net, peter@palfrader.org
set -e
################################################################
# You perhaps want to change those items
USER=pinger
VERBOSE=0
PINGD="/home/pinger/echolot/pingd"
# You probably don't want to mess with stuff below this line
################################################################
CHECKULIMIT=1
CHECKUID=1
# Check for evil ulimits
if [ "$CHECKULIMIT" -gt "0" ]; then
FDs=`ulimit -n`
HFDs=`ulimit -H -n`
if [ "$FDs" -lt "512" ]; then
if [ "$HFDs" -lt "512" ]; then
echo "Hardlimit for open File Descriptors is less than 512." >&2
echo "Please consider raising it." >&2
if [ "$FDs" -lt "$HFDs" ]; then
echo "Raising it to $HFDs" >&2
ulimit -n $HFDs
fi
else
if [ "$HFDs" -lt "1024" ]; then
FDs=$HFDs
else
FDs=1024
fi
echo "Softlimit for open File Descriptors is less than 512." >&2
echo "Raising it to $FDs" >&2
ulimit -n $FDs
fi
fi
fi
# Check for right User
SU=""
if [ "$CHECKUID" -gt "0" ]; then
CUID=`id -u`
CUIDNAME=`id -nu`
if [ "$CUIDNAME" = "$USER" ]; then
SU=""
elif [ "$CUID" = "0" ]; then
SU="su $USER -c"
else
echo "You are neither $USER nor root. Aborting." >&2
exit 1;
fi
fi
# set VERBOSE
if [ $VERBOSE -gt 0 ]; then
VERBOSE="--verbose"
else
VERBOSE=""
fi
case $1 in
start)
echo -n "Starting Echolot: pingd"
if [ ! -z "$SU" ]; then
$SU "$PINGD --detach $VERBOSE start"
else
$PINGD --detach $VERBOSE start
fi
echo "."
;;
stop)
echo -n "Stopping Echolot: pingd"
if [ ! -z "$SU" ]; then
$SU "$PINGD stop"
else
$PINGD stop
fi
echo "."
;;
reload|force-reload|restart)
$0 stop
sleep 10
$0 start
;;
process|add|delete|set|setremailercaps|deleteremailercaps|getkeyconf|sendpings|buildstats|buildkeys|buildthesaurus|buildfromlines|dumpconf|summary)
echo "Running pingd $1..."
if [ ! -z "$SU" ]; then
$SU "$PINGD \"$@\""
else
$PINGD "$@"
fi
echo "done."
;;
*)
echo "Usage: $0 (start|stop|reload|force-reload|restart)" >&2
echo " $0 <COMMAND> [parameters]" >&2
echo "See the pingd(1) manual page for valid commands" >&2
exit 1
;;
esac
exit 0
# vim:set ts=2:
# vim:set shiftwidth=2:
|