-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·60 lines (48 loc) · 1.46 KB
/
setup.sh
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
#!/bin/sh
. /opt/farm/scripts/init
. /opt/farm/scripts/functions.install
base=/opt/farm/ext/monitoring-snmpd/templates/$OSVER
if [ ! -f $base/snmpd.tpl ]; then
echo "skipping snmpd configuration (no template available for $OSVER)"
exit 1
fi
file="/etc/local/.config/snmp"
if [ ! -f $file.community ]; then
if [ "$SNMP_COMMUNITY" = "" ]; then
echo -n "enter snmp v2 community or hit enter to disable snmpd monitoring: "
stty -echo
read SNMP_COMMUNITY
stty echo
echo "" # force a carriage return to be output
fi
echo -n "$SNMP_COMMUNITY" >$file.community
chmod 0600 $file.community
fi
if [ ! -s $file.community ]; then
echo "skipping snmpd configuration (no community configured)"
exit 0
fi
/opt/farm/ext/farm-roles/install.sh snmpd
echo "setting up snmpd configuration"
config="/etc/snmp/snmpd.conf"
oldmd5=`md5sum $config`
save_original_config $config
if [ -s $file.range ]; then
range=`cat $file.range`
else
range=`/opt/farm/config/get-management-public-ip-range.sh`
fi
community="`cat $file.community`"
domain=`/opt/farm/config/get-external-domain.sh`
cat $base/snmpd.tpl |sed -e "s#%%community%%#$community#g" -e "s#%%domain%%#$domain#g" -e "s#%%management%%#$range#g" >$config
newmd5=`md5sum $config`
if [ -f $base/snmpd.default ]; then
remove_link /etc/default/snmpd
install_copy $base/snmpd.default /etc/default/snmpd
fi
if [ "$oldmd5" != "$newmd5" ]; then
service snmpd restart
echo
else
echo "skipping snmpd restart, configuration has not changed"
fi