From 2db59611696eab62affee6b75807c5a04cc69ff0 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Wed, 22 Feb 2023 22:52:44 +0100 Subject: [PATCH] Example: fixed mismatch between install dirs and DIRs in example.xml.in Docker: Removed example from test container, fixed example container --- docker/example/Dockerfile | 2 ++ docker/example/Makefile.in | 6 ++++- docker/example/startsystem.sh | 47 +---------------------------------- docker/test/Dockerfile | 3 --- docker/test/start.sh | 5 ++-- docker/test/startsystem.sh | 4 +-- example/main/Makefile.in | 3 ++- example/main/example.xml.in | 2 +- 8 files changed, 14 insertions(+), 58 deletions(-) diff --git a/docker/example/Dockerfile b/docker/example/Dockerfile index bc0a1e37..82d68c63 100644 --- a/docker/example/Dockerfile +++ b/docker/example/Dockerfile @@ -111,6 +111,8 @@ RUN adduser -D -H clicon COPY --from=0 /clixon/build/ /usr/local/ +# Overwrite config file since install dirs are wrong +COPY example.xml /usr/local/etc/example.xml # Create symlink so you can run clixon without -f arg RUN ln -s /usr/local/etc/example.xml /usr/local/etc/clixon.xml diff --git a/docker/example/Makefile.in b/docker/example/Makefile.in index ffbbbca8..e5330182 100644 --- a/docker/example/Makefile.in +++ b/docker/example/Makefile.in @@ -49,6 +49,10 @@ SHELL = /bin/sh all: echo "Run make docker to build docker image" +# Cannot use generated Makefile in docker since it uses tmp install dirs +example.xml: + cp $(top_srcdir)/example/main/$@ $@ + # (recursively) clone the repo from top-level - NOTE changes must be committed clixon: git clone file://$(realpath ${top_srcdir}) @@ -59,7 +63,7 @@ clean: distclean: clean rm -f Makefile *~ .depend -docker: clixon Dockerfile +docker: clixon Dockerfile example.xml sudo docker build -t $(IMG) $(DOCKERFLAGS) . start: docker diff --git a/docker/example/startsystem.sh b/docker/example/startsystem.sh index d574db3e..37faf79b 100755 --- a/docker/example/startsystem.sh +++ b/docker/example/startsystem.sh @@ -54,52 +54,7 @@ touch /run/openrc/softlevel #/usr/local/bin/clixon_restconf -l f/var/log/restconf.log -D $DBG & #>&2 echo "clixon_restconf started" -cat < /usr/local/etc/example.xml - - /usr/local/etc/example.xml - ietf-netconf:startup - ietf-netconf:confirmed-commit - clixon-restconf:allow-auth-none - clixon-restconf:fcgi - /usr/local/share/clixon - @YANG_STANDARD_DIR@ - clixon-example - example - /usr/local/lib/example/backend - /usr/local/lib/example/netconf - /usr/local/lib/example/restconf - /usr/local/lib/example/cli - /usr/local/lib/example/clispec - /usr/local/var/example/example.sock - /usr/local/var/example/example.pidfile - 0 - 0 - /usr/local/var/example - init - disabled - true - false - - true - none - default
0.0.0.0
80false
-
- - false - kw-nokey - false - list container - true - - include clixon-example - clixon-example - enable - - -
-EOF - -ln -s /usr/local/etc/example.xml clixon.xml +#ln -s /usr/local/etc/example.xml clixon.xml # Start clixon backend /usr/local/sbin/clixon_backend -D $DBG -s running -l e -f /usr/local/etc/example.xml diff --git a/docker/test/Dockerfile b/docker/test/Dockerfile index 41098693..b5017bcb 100644 --- a/docker/test/Dockerfile +++ b/docker/test/Dockerfile @@ -88,11 +88,8 @@ WORKDIR /clixon/clixon/util RUN make RUN make install -# Build and install the clixon example -WORKDIR /clixon/clixon/example/main RUN make RUN make install -RUN install example.xml /clixon/build/etc/clixon.xml # Copy tests WORKDIR /clixon/clixon/test diff --git a/docker/test/start.sh b/docker/test/start.sh index 97813cd9..3240a6c8 100755 --- a/docker/test/start.sh +++ b/docker/test/start.sh @@ -57,7 +57,6 @@ SPORT=${SPORT:-8443} # Initial running datastore content (other than empty) STORE=${STORE:-} - CONFIG0=$(cat < /usr/local/etc/example.xml @@ -84,8 +83,8 @@ EOF CONFIG=${CONFIG:-$CONFIG0} -# Start clixon-example backend ->&2 echo -n "Starting Backend..." +# Create clixon-test container +>&2 echo -n "Starting Container..." sudo docker run -p $PORT:80 -p $SPORT:443 --name clixon-test --rm -e DBG=$DBG -e CONFIG="$CONFIG" -e STORE="$STORE" -td clixon/clixon-test || err "Error starting clixon-test" # Wait for snmpd to start diff --git a/docker/test/startsystem.sh b/docker/test/startsystem.sh index 7d15dff2..f02c6715 100755 --- a/docker/test/startsystem.sh +++ b/docker/test/startsystem.sh @@ -78,9 +78,7 @@ echo "Set disable_coredump false" > /etc/sudo.conf chmod 775 /usr/local/bin/test/site.sh -# Start clixon backend (tests will kill this) -/usr/local/sbin/clixon_backend -D $DBG -s running -l e # logs on docker logs ->&2 echo "clixon_backend started" +# No backend is started since tests dont require it # Start snmpd, we need this for the SNMP tests and the app clixon_snmp. Log to stdout, then we can # use Docker logs to see what's happening. diff --git a/example/main/Makefile.in b/example/main/Makefile.in index aa94895d..8613c9fd 100644 --- a/example/main/Makefile.in +++ b/example/main/Makefile.in @@ -188,7 +188,8 @@ ifdef with_restconf endif install -d -m 0755 $(DESTDIR)$(libdir)/$(APPNAME)/clispec install -m 0644 $(CLISPECS) $(DESTDIR)$(libdir)/$(APPNAME)/clispec - install -d -m 0755 $(DESTDIR)$(localstatedir)/$(APPNAME) + install -d -m 0755 $(DESTDIR)$(localstatedir)/$(APPNAME) # This is for XMLDB_DIR + install -d -m 0755 $(DESTDIR)$(localstatedir)/run # This is for PID and SOCK uninstall: rm -rf $(DESTDIR)$(sysconfdir)/$(APPNAME).xml diff --git a/example/main/example.xml.in b/example/main/example.xml.in index c50a8975..bf07ab87 100644 --- a/example/main/example.xml.in +++ b/example/main/example.xml.in @@ -17,7 +17,7 @@ @LOCALSTATEDIR@/run/example.pid 0 0 - @LOCALSTATEDIR@/lib/misc + @LOCALSTATEDIR@/example init disabled true