Création de script sur linux
Hors ligneMartou26 Le 26/11/2010 à 14:08 Profil de Martou26 Configuration de Martou26

Bonjour à tous,

J'ai une bonne configuration qui existe et qui se trouve sur /etc/init.d/snmpd/, il me faut la copier/adapter sur les autres machines ou la conf snmpd.conf sont en défauts, mais idéalement en créant un sript qui permettra de copier la conf directement sur les différentes machines hd et ldapzero.

Bonne configuration /etc/init.d/snmpd



#! /bin/sh -e
### BEGIN INIT INFO
# Provides: snmpd snmptrapd
# Required-Start: $network $local_fs
# Required-Stop: $network $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: SNMP agents
# Description: NET SNMP (Simple Network Management Protocol) Agents
### END INIT INFO
#
# Author: Jochen Friedrich <jochen@scram.de>
#
set -e

export PATH=/sbin:/usr/sbin:/bin:/usr/bin

test -x /usr/sbin/snmpd || exit 0
test -x /usr/sbin/snmptrapd || exit 0

# Defaults
export MIBDIRS=/usr/share/snmp/mibs
SNMPDRUN=yes
SNMPDOPTS='-Lsd -Lf /dev/null -p /var/run/snmpd.pid'
TRAPDRUN=no
TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid'

# Reads config file (will override defaults above)
[ -r /etc/default/snmpd ] && . /etc/default/snmpd

# Cd to / before starting any daemons.
cd /

# Create compatibility link to old AgentX socket location
if [ "$SNMPDCOMPAT" = "yes" ]; then
ln -sf /var/agentx/master /var/run/agentx
fi

case "$1" in
start)
echo -n "Starting network management services:"
if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
start-stop-daemon --quiet --start --oknodo --exec /usr/sbin/snmpd \
-- $SNMPDOPTS
echo -n " snmpd"
fi
if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
start-stop-daemon --quiet --start --oknodo --exec /usr/sbin/snmptrapd \
-- $TRAPDOPTS
echo -n " snmptrapd"
fi
echo "."
;;
stop)
echo -n "Stopping network management services:"
start-stop-daemon --quiet --stop --oknodo --exec /usr/sbin/snmpd
echo -n " snmpd"
start-stop-daemon --quiet --stop --oknodo --exec /usr/sbin/snmptrapd
echo -n " snmptrapd"
echo "."
;;
restart)
echo -n "Restarting network management services:"
start-stop-daemon --quiet --stop --oknodo --exec /usr/sbin/snmpd
start-stop-daemon --quiet --stop --oknodo --exec /usr/sbin/snmptrapd
# Allow the daemons time to exit completely.
sleep 2
if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
start-stop-daemon --quiet --start --exec /usr/sbin/snmpd -- $SNMPDOPTS
echo -n " snmpd"
fi
if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
# Allow snmpd time to start up.
sleep 1
start-stop-daemon --quiet --start --exec /usr/sbin/snmptrapd -- $TRAPDOPTS
echo -n " snmptrapd"
fi
echo "."
;;
reload|force-reload)
echo -n "Reloading network management services:"
if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
start-stop-daemon --quiet --stop --signal 1 \
--pidfile /var/run/snmpd.pid --exec /usr/sbin/snmpd
echo -n " snmpd"
fi
echo "."
;;
*)
echo "Usage: /etc/init.d/snmpd {start|stop|restart|reload|force-reload}"
exit 1
esac

exit 0

Vous avez résolu votre problème avec VIC ? Faites-le savoir sur les réseaux sociaux !
Vulgarisation-informatique.com
Cours en informatique & tutoriels