Change dockerfiles and start scripts to install Net-SNMP, configure snmpd properly

and make sure it is started. This is needed for the SNMP tests (test_snm*) to run properly.
Since we can't rely on systemd in Alpine we start snmpd from the startsystem-scripts.
This commit is contained in:
Kristofer Hallin 2022-05-04 10:36:37 -07:00 committed by Olof hagsand
parent 7bdc5045b2
commit 5a09dcbf13
7 changed files with 53 additions and 3 deletions

View file

@ -39,6 +39,9 @@ MAINTAINER Olof Hagsand <olof@hagsand.se>
# For clixon and cligen
RUN apk add --update git make build-base gcc flex bison curl-dev
# For netsnmp
RUN apk add --update net-snmp net-snmp-dev
WORKDIR /usr/local/share
# Checkout standard YANG models for tests (note >1G for full repo)
@ -76,7 +79,7 @@ WORKDIR /clixon/clixon
COPY clixon .
# Configure, build and install clixon
RUN ./configure --prefix=/clixon/build --with-cligen=/clixon/build --without-restconf --with-yang-standard-dir=/usr/local/share/yang/standard
RUN ./configure --prefix=/clixon/build --with-cligen=/clixon/build --without-restconf --with-yang-standard-dir=/usr/local/share/yang/standard --enable-netsnmp --with-mib-generated-yang-dir=/usr/local/share/mib-yangs/
RUN make
RUN make install
@ -103,6 +106,9 @@ WORKDIR /clixon
COPY startsystem.sh startsystem.sh
RUN install startsystem.sh /clixon/build/bin/
# Add our generated YANG files
RUN git clone https://github.com/clicon/mib-yangs.git /usr/local/share/mib-yangs
#
# Stage 2
# The second step skips the development environment and builds a runtime system
@ -112,6 +118,14 @@ MAINTAINER Olof Hagsand <olof@hagsand.se>
# For clixon and cligen
RUN apk add --update flex bison fcgi-dev
# For SNMP
RUN apk add --update net-snmp net-snmp-tools
# Some custom configuration for SNMP
RUN sed -i 's/#rocommunity public localhost/rocommunity public localhost/' /etc/snmp/snmpd.conf
RUN echo "agentXSocket unix:/var/run/snmp.sock" >> /etc/snmpd.conf
RUN echo "agentxperms 777 777" >> /etc/snmpd.conf
# Test-specific (for test scripts)
RUN apk add --update sudo curl procps grep make bash expect
@ -120,6 +134,7 @@ RUN adduser -D -H clicon
COPY --from=0 /clixon/build/ /usr/local/
COPY --from=0 /usr/local/share/yang/* /usr/local/share/yang/standard/
COPY --from=0 /usr/local/share/mib-yangs/* /usr/local/share/mib-yangs/
# Log to stderr.
CMD /usr/local/bin/startsystem.sh