net-snmp: removed post-install, added pre-install. use ssd for init

This commit is contained in:
Fredrik Rinnestam 2015-08-04 20:17:25 +02:00
parent f294667853
commit 20ffd2c907
5 changed files with 45 additions and 22 deletions

View File

@ -622,9 +622,9 @@ drwxr-xr-x root/root usr/share/snmp/snmpconf-data/snmptrapd-data/
-rw-r--r-- root/root usr/share/snmp/snmpconf-data/snmptrapd-data/traphandle
drwxr-xr-x root/root var/
drwxr-xr-x root/root var/lib/
drwxr-xr-x daemon/daemon var/lib/snmp/
drwxr-xr-x snmp/snmp var/lib/snmp/
drwxr-xr-x root/root var/log/
drwxr-xr-x daemon/daemon var/log/snmp/
-rw-r--r-- daemon/daemon var/log/snmp/snmpd.log (EMPTY)
drwxr-xr-x snmp/snmp var/log/snmp/
-rw-r--r-- snmp/snmp var/log/snmp/snmpd.log (EMPTY)
drwxr-xr-x root/root var/run/
drwxr-xr-x daemon/daemon var/run/snmp/
drwxr-xr-x snmp/snmp var/run/snmp/

View File

@ -1,3 +1,3 @@
d4a3459e1577d0efa8d96ca70a885e53 net-snmp-5.7.3.tar.gz
497f4009387e3844137cb44f36520c9d snmpd
0ac35ebc69c521313cf0c24b9afb3b22 snmpd
e75939cb0b4648856d07b9c04610af5d snmpd.conf

View File

@ -5,7 +5,7 @@
name=net-snmp
version=5.7.3
release=1
release=2
source=(http://download.sourceforge.net/$name/$name-$version.tar.gz \
snmpd snmpd.conf)
@ -48,7 +48,7 @@ build() {
mkdir -p $PKG/var/{lib,run,log}/snmp
touch $PKG/var/log/snmp/snmpd.log
chown -R daemon:daemon $PKG/var/{lib,run,log}/snmp
chown -R snmp:snmp $PKG/var/{lib,run,log}/snmp
install -D -m 644 $SRC/snmpd.conf $PKG/etc/snmp/snmpd.conf
install -D -m 755 $SRC/snmpd $PKG/etc/rc.d/snmpd

14
net-snmp/pre-install Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
if [ -z "`getent group snmp`" ]
then
/usr/sbin/groupadd -g 72 snmp
fi
if [ -z "`getent passwd snmp`" ]
then
/usr/sbin/useradd -u 72 -g snmp -d /var/lib/snmp/ -s /bin/false snmp
/usr/bin/passwd -l snmp
fi
# End of file

View File

@ -1,28 +1,37 @@
#!/bin/sh
#!/bin/bash
#
# /etc/rc.d/snmpd: start/stop net-snmpd daemon
#
SNMP_LOG=/var/log/snmp/snmpd.log
SNMP_PID=/var/run/snmp/snmpd.pid
SNMPD_ARGS="-A -p $SNMP_PID -Lf $SNMP_LOG -u daemon -g daemon"
SSD=/sbin/start-stop-daemon
PROG=/usr/sbin/snmpd
PID=/var/run/snmp/snmpd.pid
LOG=/var/log/snmp/snmpd.log
OPTS="-A -p $PID -Lf $LOG -u snmp -g snmp"
case $1 in
start)
/usr/sbin/snmpd ${SNMPD_ARGS}
;;
$SSD --start --pidfile $PID --exec $PROG -- $OPTS
;;
stop)
kill -TERM `cat $SNMP_PID`
;;
$SSD --stop --remove-pidfile --retry 10 --pidfile $PID
;;
restart)
$0 stop
sleep 2
$0 start
;;
$0 stop
$0 start
;;
status)
$SSD --status --pidfile $PID
case $? in
0) echo "$PROG is running with pid $(cat $PID)" ;;
1) echo "$PROG is not running but the pid file $PID exists" ;;
3) echo "$PROG is not running" ;;
4) echo "Unable to determine the program status" ;;
esac
;;
*)
echo "Usage: $0 [start|stop|restart]";
;;
echo "usage: $0 [start|stop|restart|status]"
;;
esac
# End of file