added source file for podman

This commit is contained in:
mslacken
2022-11-24 15:06:48 +01:00
parent f64c91093b
commit 4a5b5a8317
4 changed files with 203 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
#!/bin/sh -eu
# This is the install script for warewulf when run in a privileged
# container.
cd /
PATH="/usr/bin:/usr/sbin"
CONTAINER=warewulf
BINSCRIPT=${CONTAINER}-container-manage.sh
WWCTL=wwctl
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
echo "LABEL INSTALL"
# ensure all scripts will be present on the host
copy_to_usr_local_bin() {
SCRIPT=$1
BASEDIR=`dirname $SCRIPT`
mkdir -p $BASEDIR
if [ ! -e /host/usr/local/bin/${SCRIPT} ]; then
echo "copy /container/${SCRIPT} in /host/usr/local/bin/"
rsync -u /container/${SCRIPT} /host/usr/local/bin/${SCRIPT}
else
echo "/host/usr/local/bin/${SCRIPT} already exist, will not update it"
fi
}
copy_to_etc() {
CONF=$1
BASEDIR=`dirname $CONF`
mkdir -p $BASEDIR
if [ ! -e /host/etc/${CONF} ]; then
echo "copy /container/${CONF} in /host/etc/"
rsync -u /container/${CONF} /host/etc/${CONF}
else
echo "/host/etc/${CONF} already exist, will not update it"
fi
}
sync_dir() {
DIR=$1
test -e /host/${DIR} || mkdir -pv /host/${DIR}
test -e /host/${DIR} && (rsync -au ${DIR} `dirname /host/${DIR}`; echo "updating $DIR")
}
# For podman, cp a systemd unit for starting on boot
if [ ! -e /host/etc/systemd/system/${CONTAINER}.service ]; then
mkdir -p /host/etc/systemd/system/
rsync -u /container/${CONTAINER}.service /host/etc/systemd/system/${CONTAINER}.service
else
echo "/host/etc/systemd/system/${CONTAINER}.service already exist"
fi
# create the dirs
mkdir -p /host/etc/warewulf
mkdir -p /host/var/lib/warewulf
copy_to_usr_local_bin ${WWCTL}
copy_to_usr_local_bin ${BINSCRIPT}
# now sync hosts and overlays
sync_dir $OVERLAYDIR
sync_dir $CHROOTDIR
sync_dir $WAREWULFCONF
# bash completion
if [ ! -e /host/etc/bash_completion.d/wwctl ] ; then
mkdir -p /host/etc/bash_completion.d
cp $BASHCOMPLETION /host/etc/bash_completion.d/
fi
# containerdir
mkdir -p /host/$CONTAINERDIR

View File

@@ -0,0 +1,33 @@
#!/bin/bash
OVERLAYDIR=/var/lib/warewulf/overlays
CHROOTDIR=/var/lib/warewulf/chroots
CONTAINERDIR=/var/lib/warewulf/container
WAREWULFCONF=/etc/warewulf
BASEDIR=/var/lib/warewulf
cat >&2 << EOF
WARNING:
Purging all warewulf configurations, containers aka node images and overlays
Wating for 10s, press any key to abort
EOF
count=0
while true ; do
if read -t 0; then # Input ready
read -n 1 char
echo "Aborting purge"
exit 0
else # No input
echo -n '.'
sleep 1
count=$(( $count + 1))
if [ $count -eq 10 ] ; then
echo
break
fi
fi
done
echo "PURGING"
/container/label-uninstall
rm -rv /host/$WAREWULFCONF /host/$OVERLAYDIR /host/$CHROOTDIR /host/$CONTAINERDIR
rmdir /host/$BASEDIR

View File

@@ -0,0 +1,20 @@
#!/bin/sh -eu
# This is the uninstall script for grafana when run in a privileged
# container.
CONTAINER=warewulf
cd /
PATH="/usr/bin:/usr/sbin"
if [ ! -d /host/etc ] || [ ! -d /host/usr/local/bin ]; then
echo "${CONTAINER}-uninstall: host file system is not mounted at /host"
exit 1
fi
# removing installed files
echo "LABEL UNINSTALL: Removing all files"
rm -vf /host/usr/local/bin/wwctl
rm -vf /host/usr/local/bin/warewulf-container-manage.sh
rm -vf /host/etc/systemd/system/${CONTAINER}.service
rm -vf /host/usr/share/bash-completion/completions/wwctl