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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169 | ryan@RLW-PC:~$ cat /etc/init.d/avgd
#!/bin/sh
#
# Initscript skeleton for various distributions(os).
# Mdk, RH (Fedora), SuSE, Debian, FreeBSD
#
# for RH, SuSE, Mdk
# chkconfig: 2345 60 40
# description: Starts and stops AVG Anti-Virus daemon
#
# LSB comments (should take precedence over chkconfg):
### BEGIN INIT INFO
# Provides: avgd
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts and stops AVG Anti-Virus daemon
### END INIT INFO
# Check if root is running this script
if [ $(id -u) -ne 0 ] ; then
echo "ERROR: Try to run this as root."
# LSB specification errorcode
exit 4
fi
AVG_SCRIPTS_DIR=/opt/avg/av/etc/init.d
# Source common/default variables settings
. ${AVG_SCRIPTS_DIR}/avgdinit.conf
# split deprecated variables in avgdinit.conf into new ones,
# used (and possibely reset in sourced functions.*) since v7.5
if [ -n "$AVG_LOCK_FILE" ] ; then
AVG_LOCK_FILE_NAME=${AVG_LOCK_FILE##*/}
AVG_LOCK_FILE_DIR=${AVG_LOCK_FILE%/*}
fi
# Source common/default functions for all distributions.
. ${AVG_SCRIPTS_DIR}/functions.common
# Check the command-line program
if [ ! -x "$AVG_CTL_PATH" ] ; then
echo "ERROR: Could not find ${AVG_CTL}"
# LSB specification errorcode
if [ "$1" = "status" ] ; then
exit 150
else
exit 5
fi
fi
# Detect os and distribution
os=`uname -s`
if [ "$os" = "Linux" -o "GNU/kFreeBSD" ] ; then
distro=`detect_distro`
if [ -z "$distro" ] ; then
distro="generic"
fi
elif [ "$os" = "FreeBSD" ] ; then
distro="freebsd"
else
# shouldn't occur (installation on unsupported system)
echo "Unsupported system $os detected."
exit 1
fi
# Source our distro-specific init functions and variables
# which can override common/default init functions.
# They can also source some init functions (mainly these
# used for echoing) provided by distro.
if [ -f ${AVG_SCRIPTS_DIR}/functions.${distro} ] ; then
. ${AVG_SCRIPTS_DIR}/functions.${distro}
fi
# After sourcing distro-specific variables
# we can set some composite path variables
if [ -n "$AVG_LOCK_FILE_NAME" ] ; then
AVG_LOCK_FILE="${AVG_LOCK_FILE_DIR}/${AVG_LOCK_FILE_NAME}"
fi
# Source configuration
if [ -f "/etc/sysconfig/${AVG_DAEMON}" ] ; then
. "/etc/sysconfig/${AVG_DAEMON}"
fi
status()
{
dist_echo_status_begin
dist_status
dist_echo_status_end
return $RETVAL
}
start()
{
dist_echo_start_begin
dist_start
dist_echo_start_end
if [ -n "$AVG_LOCK_FILE" ] ; then
[ "$RETVAL" -eq 0 ] && touch "${AVG_LOCK_FILE}" || RETVAL=150
fi
return $RETVAL
}
stop()
{
dist_echo_stop_begin
dist_stop
dist_echo_stop_end
if [ -n "$AVG_LOCK_FILE" ] ; then
[ "$RETVAL" -eq 0 ] && rm -f "${AVG_LOCK_FILE}" || RETVAL=150
fi
return $RETVAL
}
restart()
{
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
condrestart)
# Restarts the servce iff it is already running
# (which is detected by presence of lockfile or status function).
if [ -n "$AVG_LOCK_FILE" ] ; then
[ -f "${AVG_LOCK_FILE}" ] && restart || :
else
dist_status > /dev/null && restart || :
fi
;;
*)
echo "Usage: $0 {start|stop|status|restart|condrestart}"
exit 1
esac
exit $?
|