#!/bin/bash

# Sets SNMPD correctly for Zenoss

SNMP="/etc/snmp/"
DEFAULT="/etc/default/snmpd"

# Let's install dependencies:

apt-get install -qq snmp snmpd 
echo "[1] Installing snmp and snmpd"

# Backup snmpd.conf 
mv $SNMP/snmpd.conf $SNMP/old.snmpd.conf
echo "[2] Backing up the snmpd.conf file"

# Create the new one
echo "rocommunity  public" > /etc/snmp/snmpd.conf
echo "[3] Creating new config file for snmpd.conf"

# Modify the line in /etc/default
sed -i 's/127.0.0.1//g' $DEFAULT
echo "[4] Removed a problematic line in /etc/default/snmpd"

#Restart the service...
/etc/init.d/snmpd restart

# Final step:
echo "[5] SNMP should be working correctly now."
echo "You can issue the following command to check everything:"
echo "snmpwalk localhost -v1 -c public system"
