Просмотр исходного кода

support host_mib, provide rc file, provide minimal config, use bootstrap libraries for -ldb, -lbz2, -lpopt, -lz

Michael van Elst 23 лет назад
Родитель
Сommit
cdac6859ca
3 измененных файлов с 92 добавлено и 6 удалено
  1. 33 0
      snmp/rc.snmp
  2. 38 6
      snmp/snmp.spec
  3. 21 0
      snmp/snmpd.conf

+ 33 - 0
snmp/rc.snmp

@@ -0,0 +1,33 @@
+#!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
+##
+##  rc.snmp -- Run-Commands for OpenSSH Daemon
+##
+
+%config
+    snmp_enable="yes"
+
+%common
+    snmp_signal () {
+        if [ -f "@l_prefix@/var/snmp/snmpd.pid" ]; then
+            kill -$1 `cat @l_prefix@/var/snmp/snmpd.pid`
+        fi
+    }
+
+%start -p 200 -u @l_susr@
+    opServiceEnabled snmp || exit 0
+    if [ -f @l_prefix@/etc/snmp/snmpd.conf ]; then
+        @l_prefix@/sbin/snmpd -P @l_prefix@/var/snmp/snmpd.pid
+    fi
+
+%stop -p 200 -u @l_susr@
+    opServiceEnabled snmp || exit 0
+    snmp_signal TERM
+
+%restart -u @l_susr@
+    opServiceEnabled snmp || exit 0
+    snmp_signal TERM
+    sleep 2
+    if [ -f @l_prefix@/etc/snmp/snmpd.conf ]; then
+        @l_prefix@/sbin/snmpd -P @l_prefix@/var/snmp/snmpd.pid
+    fi
+

+ 38 - 6
snmp/snmp.spec

@@ -33,16 +33,21 @@ Distribution: OpenPKG [PLUS]
 Group:        Network
 Group:        Network
 License:      BSD
 License:      BSD
 Version:      5.0.8
 Version:      5.0.8
-Release:      20030318
+Release:      20030429
+
+#   package options
+%option       with_host_mib no
 
 
 #   list of sources
 #   list of sources
 Source0:      http://osdn.dl.sourceforge.net/net-snmp/net-snmp-%{version}.tar.gz
 Source0:      http://osdn.dl.sourceforge.net/net-snmp/net-snmp-%{version}.tar.gz
+Source1:      rc.snmp
+Source2:      snmpd.conf
 
 
 #   build information
 #   build information
 Prefix:       %{l_prefix}
 Prefix:       %{l_prefix}
 BuildRoot:    %{l_buildroot}
 BuildRoot:    %{l_buildroot}
-BuildPreReq:  OpenPKG, openpkg >= 20020206, openssl, zlib, db >= 4.1.24
-PreReq:       OpenPKG, openpkg >= 20020206
+BuildPreReq:  OpenPKG, openpkg >= 20030428, openssl
+PreReq:       OpenPKG, openpkg >= 20030428
 AutoReq:      no
 AutoReq:      no
 AutoReqProv:  no
 AutoReqProv:  no
 
 
@@ -55,18 +60,28 @@ AutoReqProv:  no
 
 
 %prep
 %prep
     %setup -q -n net-snmp-%{version}
     %setup -q -n net-snmp-%{version}
+    %{l_shtool} subst \
+        -e 's;/usr/include/rpm;%{l_prefix}/include/rpm;g' \
+        -e 's;-lpopt\([^a-z]\);-lrpmpopt\1;g' \
+        -e 's;-ldb\([^a-z]\);-lrpmdb\1;g' \
+        -e 's;-lz\([^a-z]\);-lrpz\1;g' \
+        -e 's;-lrpm\([^a-z]\);-lrpm -lrpmio\1;g' \
+        -e 's;-lrpmio\([^a-z]\);-lrpmio -lrpmpopt -lrpmbz2 -lrpmz\1;g' \
+        configure
 
 
 %build
 %build
     ./configure \
     ./configure \
         --with-cc="%{l_cc}" \
         --with-cc="%{l_cc}" \
         --with-cflags="%{l_cflags -O}" \
         --with-cflags="%{l_cflags -O}" \
+        --with-ldflags="%{l_ldflags}" \
         --prefix=%{l_prefix} \
         --prefix=%{l_prefix} \
         --with-persistent-directory=%{l_prefix}/var/snmp \
         --with-persistent-directory=%{l_prefix}/var/snmp \
         --with-openssl=%{l_prefix} \
         --with-openssl=%{l_prefix} \
-        --with-zlib=%{l_prefix} \
-        --with-db=%{l_prefix} \
         --enable-silent-libtool \
         --enable-silent-libtool \
         --disable-shared \
         --disable-shared \
+%if "%{with_host_mib}" == "yes"
+        --with-mib-modules="host" \
+%endif
         --with-defaults
         --with-defaults
     %{l_make} %{l_mflags} touchit
     %{l_make} %{l_mflags} touchit
     %{l_make} %{l_mflags}
     %{l_make} %{l_mflags}
@@ -79,12 +94,29 @@ AutoReqProv:  no
         -e "s;^\\(persistentdir.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix}/var/snmp;g" \
         -e "s;^\\(persistentdir.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix}/var/snmp;g" \
         `find . -type f -name Makefile -print`
         `find . -type f -name Makefile -print`
     %{l_make} %{l_mflags} install
     %{l_make} %{l_mflags} install
+
+    %{l_shtool} mkdir -f -p -m 755 \
+        $RPM_BUILD_ROOT%{l_prefix}/var/snmp \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/snmp
+
+    %{l_shtool} install -c -m 644 \
+        %{SOURCE snmpd.conf} \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/snmp/
+
+    %{l_shtool} install -c -m 755 \
+        -e 's;@l_prefix@;%{l_prefix};g' \
+        -e 's;@l_susr@;%{l_susr};g' \
+        %{SOURCE rc.snmp} \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
+
     rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform
     rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform
     ln $RPM_BUILD_ROOT%{l_prefix}/bin/snmptrap \
     ln $RPM_BUILD_ROOT%{l_prefix}/bin/snmptrap \
        $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform
        $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform
     strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
     strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
     strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
     strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
-    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
+    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} \
+        '%config %{l_prefix}/etc/snmp/*.conf'
 
 
 %files -f files
 %files -f files
 
 

+ 21 - 0
snmp/snmpd.conf

@@ -0,0 +1,21 @@
+###########################################################################
+#
+# snmpd.conf
+#
+#   - created by the snmpconf configuration program
+#
+###########################################################################
+# SECTION: Access Control Setup
+#
+#   This section defines who is allowed to talk to your running
+#   snmp agent.
+    
+# rouser: a SNMPv3 read-only user
+#   arguments:  user [noauth|auth|priv] [restriction_oid]
+    
+rouser  nms
+    
+# rocommunity: a SNMPv1/SNMPv2c read-only access community name
+#   arguments:  community [default|hostname|network/bits] [oid]
+    
+rocommunity  public 127.0.0.1