7 .
/opt
/avg
/avg
8/etc
/init.d
/avgdinit.conf
10 # From functions.common
12 # wait until avgd pid-file exist or time's out
13 # if time's out, kill avgd and his childern
16 # print count-down limit
19 i
=$AVG_WAIT_FOR_PID_TIME
29 # wait until pid-file exist or time's out
30 i
=$AVG_WAIT_FOR_PID_TIME
33 if [ -f "$AVG_PID_FILE" ] ; then
42 # if avgd is still running, kill it and all his childern (ps ppid==pid avgd)
43 if [ -f "$AVG_PID_FILE" ] ; then
44 PID
=`cat "${AVG_PID_FILE}"`
45 PIDS
=`ps axopid,ppid,ruser | grep -w $PID | grep -w $SUSER | awk '{print $1}' | tr '\n' ' '`
46 if [ -n "$PIDS" ] ; then
47 printf "\r killing $AVG_DAEMON and his components with pids: ($PIDS)"
50 [ $RETVAL -eq 0 ] && rm -f $AVG_PID_FILE
60 # Return values are LSB-compliant.
61 # Should set the value of RETVAL to return value.
64 if [ -f "$AVG_PID_FILE" ] ; then
65 PID
=`cat "${AVG_PID_FILE}"`
66 ISRUN
=`ps axo pid,comm | grep -w $PID | grep -w ${AVG_DAEMON}`
67 if [ -n "$ISRUN" ] ; then
68 echo -n "(pid $PID) is running"
71 echo -n "$AVG_DAEMON dead but pidfile exists"
74 elif [ -n "$AVG_LOCK_FILE" -a -f "$AVG_LOCK_FILE" ] ; then
75 echo -n "${AVG_DAEMON} dead but subsys locked"
78 echo -n "$AVG_DAEMON is not running"
85 # Should set the value of RETVAL to return value.
88 #TODO: avgctl --reload
89 if [ -f "$AVG_PID_FILE" ] ; then
90 kill -HUP `cat "${AVG_PID_FILE}"`
93 RETVAL
=7 # program is not running (LSB specification)
94 echo -n "service not running"
100 # Stops the daemon (and waits until his pidfile is removed).
101 # Should set the value of RETVAL to return value.
105 if [ -f "$AVG_PID_FILE" ] ; then
106 $AVG_CTL --stop >/dev
/null
2>&1
108 if [ -f "$AVG_PID_FILE" ] ; then
109 PID
=`cat $AVG_PID_FILE`
110 ISRUN
=`ps axo pid,comm | grep -w $PID | grep -w ${AVG_DAEMON}`
111 [ -n "${ISRUN}" ] && wait_and_kill
115 echo -n " (not running)"
123 # Should set the value of RETVAL to return value.
124 # Note: Used for FreeBSD currently.
128 # if daemon is not running, nothing should be in RUN_DIR
129 if [ -n "`ls $AVG_RUN_DIR`" ] ; then
130 # See if it's already running.
131 if [ -f "$AVG_PID_FILE" ] ; then
132 PID
=`cat $AVG_PID_FILE`
133 ISRUN
=`ps axo pid,comm | grep -w $PID | grep -w ${AVG_DAEMON}`
134 if [ -n "${ISRUN}" ] ; then
135 #avgd is running = do nothing
136 echo -n " (already running with pid: $PID)"
141 #avgd is dead, clean mess (old pid and pipe files), before run
142 echo -n " (recovering)"
146 # make sure it doesn't core dump anywhere unless requested
147 ulimit -S -c ${DAEMON_COREFILE_LIMIT:-0} >/dev
/null
2>&1
149 # if they set NICELEVEL, honor it
150 [ -n "$NICELEVEL" ] && nice
="nice -n $NICELEVEL"
153 if [ "$SUSER" = "root" ] ; then
154 $nice "$AVG_CTL" --start >/dev
/null
2>&1
156 $nice su
-s /bin
/sh
-c "$AVG_CTL --start >/dev/null 2>&1" $SUSER
164 ############################################################
165 # Functions for echoing
168 dist_echo_status_begin
()
170 stat_busy
"Checking for service ${AVG_DAEMON}: "
174 dist_echo_status_end
()
180 dist_echo_start_begin
()
182 stat_busy
"Starting $AVG_DAEMON"
186 dist_echo_start_end
()
188 [ "$RETVAL" -eq 0 ] && stat_done || stat_fail
192 dist_echo_stop_begin
()
194 stat_busy
"Shutting down $AVG_DAEMON"
200 [ "$RETVAL" -eq 0 ] && stat_done || stat_fail
204 dist_echo_reload_begin
()
206 stat_busy
"Reloading virus database: "
210 dist_echo_reload_end
()
212 [ "$RETVAL" -eq 0 ] && stat_done || stat_fail
217 if [ $
(id
-u) -ne 0 ] ; then
218 echo "ERROR: Try to run this as root."
219 # LSB specification errorcode
223 # split deprecated variables in avgdinit.conf into new ones,
224 # used (and possibely reset in sourced functions.*) since v7.5
225 if [ -n "$AVG_LOCK_FILE" ] ; then
226 AVG_LOCK_FILE_NAME
=${AVG_LOCK_FILE##*/}
227 AVG_LOCK_FILE_DIR
=${AVG_LOCK_FILE%/*}
229 if [ -n "$AVG_CONF_FILE" ] ; then
230 AVG_CONF_FILE_NAME
=${AVG_CONF_FILE##*/}
231 AVG_CONF_FILE_DIR
=${AVG_CONF_FILE%/*}
234 # Source our distro-specific init functions and variables
235 # which can override common/default init functions.
236 # They can also source some init functions (mainly these
237 # used for echoing) provided by distro.
239 if [ -f ${AVG_SCRIPTS_DIR}/functions.
${distro} ] ; then
240 .
${AVG_SCRIPTS_DIR}/functions.
${distro}
243 # After sourcing distro-specific variables
244 # we can set some composite path variables
246 if [ -n "$AVG_LOCK_FILE_NAME" ] ; then
247 AVG_LOCK_FILE
="${AVG_LOCK_FILE_DIR}/${AVG_LOCK_FILE_NAME}"
250 if [ -n "$AVG_CONF_FILE_NAME" ] ; then
251 AVG_CONF_FILE
="${AVG_CONF_FILE_DIR}/${AVG_CONF_FILE_NAME}"
255 # Source configuration
257 if [ -f "/etc/sysconfig/${AVG_DAEMON}" ] ; then
258 .
"/etc/sysconfig/${AVG_DAEMON}"
262 # Check that required config file exists.
264 if [ -n "$AVG_CONF_FILE" -a ! -f "$AVG_CONF_FILE" ] ; then
265 echo "ERROR: Could not find ${AVG_CONF_FILE}"
266 # LSB specification errorcode
267 if [ "$1" = "status" ] ; then
276 dist_echo_status_begin
285 dist_echo_start_begin
288 if [ -n "$AVG_LOCK_FILE" ] ; then
289 [ "$RETVAL" -eq 0 ] && touch "${AVG_LOCK_FILE}" || RETVAL
=150
300 if [ -n "$AVG_LOCK_FILE" ] ; then
301 [ "$RETVAL" -eq 0 ] && rm -f "${AVG_LOCK_FILE}" || RETVAL
=150
309 dist_echo_reload_begin
340 # Restarts the servce iff it is already running
341 # (which is detected by presence of lockfile or status function).
342 if [ -n "$AVG_LOCK_FILE" ] ; then
343 [ -f "${AVG_LOCK_FILE}" ] && restart ||
:
345 dist_status
> /dev
/null
&& restart ||
:
349 echo "Usage: $0 {start|stop|status|reload|restart|condrestart}"