From 275a89a78b49c0fc654aca44da21821a2eba21df Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Wed, 30 Nov 2022 15:29:50 +0100 Subject: [PATCH] disable nfs and copy ssh public keys to container --- Dockerfile | 14 ++++++++------ container-scripts/config-warewulf | 3 ++- container-scripts/label-install | 10 ++++++++-- container-scripts/label-purge | 3 ++- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index ceaa9bca..048a51fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,6 +51,7 @@ RUN zypper -n install \ dhcp-server \ iproute2 \ vim \ + yq \ tftp \ systemd \ && \ @@ -61,11 +62,12 @@ RUN zypper -n install \ sed -i 's/^DHCPD_INTERFACE=""/DHCPD_INTERFACE="ANY"/' $DHCPDCONF && \ sed -i 's/^DHCPD_RUN_CHROOTED="yes"/DHCPD_RUN_CHROOTED="no"/' $DHCPDCONF && \ WW4CONF=/etc/warewulf/warewulf.conf; test -e $WW4CONF && \ - sed -i 's/^ipaddr:.*/ipaddr: EMPTY/' $WW4CONF && \ - sed -i 's/^netmask:.*/netmask: EMPTY/' $WW4CONF && \ - sed -i 's/^network:.*/network: EMPTY/' $WW4CONF && \ - sed -i 's/^ range start:.*/ range start: EMPTY/' $WW4CONF && \ - sed -i 's/^ range end:.*/ range end: EMPTY/' $WW4CONF && \ + yq e '.ipaddr |= "EMPTY"' -i $WW4CONF && \ + yq e '.netmask |= "EMPTY"' -i $WW4CONF && \ + yq e '.network |= "EMPTY"' -i $WW4CONF && \ + yq e '.dhcp.["range start"] |= "EMPTY"' -i $WW4CONF && \ + yq e '.dhcp.["range end"] |= "EMPTY"' -i $WW4CONF && \ + yq e '.nfs.enabled |= false' -i $WW4CONF && \ mkdir -p /container && \ cp -vr container-scripts/label-* \ container-scripts/wwctl \ @@ -74,7 +76,7 @@ RUN zypper -n install \ container-scripts/config-warewulf \ /container &&\ mkdir -p /usr/share/bash_completion/completions/ &&\ - cp /etc/warewulf/bash_completion.d/warewulf /usr/share/bash_completion/completions/wwctl &&\ + cp /etc/warewulf/bash_completion.d/warewulf /usr/share/bash_completion/completions/warewulf &&\ mv -v container-scripts/ww4-config.service /etc/systemd/system/ &&\ mv -v container-scripts/warewulfd.service /etc/systemd/system/ &&\ systemctl enable ww4-config &&\ diff --git a/container-scripts/config-warewulf b/container-scripts/config-warewulf index cd4dfbd5..fd6254b2 100755 --- a/container-scripts/config-warewulf +++ b/container-scripts/config-warewulf @@ -69,6 +69,7 @@ fi # configure the services of the host by building the host overlay echo "-- Running wwctl --" -wwctl overlay build # enable tftp if systemd is running test -e /run/systemd/system && wwctl configure tftp +test -e /run/systemd/system && wwctl configure ssh +wwctl overlay build diff --git a/container-scripts/label-install b/container-scripts/label-install index e29365fb..470ff0e0 100755 --- a/container-scripts/label-install +++ b/container-scripts/label-install @@ -12,7 +12,8 @@ OVERLAYDIR=/var/lib/warewulf/overlays CHROOTDIR=/var/lib/warewulf/chroots CONTAINERDIR=/var/lib/warewulf/container WAREWULFCONF=/etc/warewulf -BASHCOMPLETION=/usr/share/bash_completion/completions/wwctl +BASHCOMPLETION=/usr/share/bash_completion/completions/w* +AUTHKEYDIR=/root/.ssh echo "LABEL INSTALL" # ensure all scripts will be present on the host @@ -67,10 +68,15 @@ sync_dir $CHROOTDIR sync_dir $WAREWULFCONF # bash completion -if [ ! -e /host/etc/bash_completion.d/wwctl ] ; then +if [ ! -e /host/etc/bash_completion.d/warewulf ] ; then mkdir -p /host/etc/bash_completion.d cp $BASHCOMPLETION /host/etc/bash_completion.d/ fi # containerdir mkdir -p /host/$CONTAINERDIR + +# authorized keys +mkdir -p /root/.ssh/ +echo "Copy authorized keys to container" +test -e /host/${AUTHKEYDIR}/*pub && cp -v /host/${AUTHKEYDIR}/*pub ${AUTHKEYDIR} || echo "no public keys found" diff --git a/container-scripts/label-purge b/container-scripts/label-purge index 95568309..f4dc9118 100755 --- a/container-scripts/label-purge +++ b/container-scripts/label-purge @@ -1,6 +1,7 @@ #!/bin/bash OVERLAYDIR=/var/lib/warewulf/overlays CHROOTDIR=/var/lib/warewulf/chroots +OCIDIR=/var/lib/warewulf/oci CONTAINERDIR=/var/lib/warewulf/container WAREWULFCONF=/etc/warewulf BASEDIR=/var/lib/warewulf @@ -28,6 +29,6 @@ while true ; do done echo "PURGING" /container/label-uninstall -rm -rv /host/$WAREWULFCONF /host/$OVERLAYDIR /host/$CHROOTDIR /host/$CONTAINERDIR +rm -rv /host/$WAREWULFCONF /host/$OVERLAYDIR /host/$CHROOTDIR /host/$CONTAINERDIR /host/$OCIDIR rmdir /host/$BASEDIR