From 3b6a2f6edba241306f409ce3f7f534f8f56e8fe8 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Wed, 17 May 2023 09:17:03 -0400 Subject: [PATCH] Update qm /etc/agent/agent.conf that when the qm.service is started This pull request will cause the /usr/lib/qm/rootfs/etc/hirte/agent.conf to be created on every qm.service start. This way if the admin changes the /etc/hirte/agent.conf on the host, the equivalent inside of the qm will match with the exception that the nodename is prefixed with qm. If the nodename in the hosts /etc/hirte/agent.conf is changed to foobar, then the qm's /etc/hirte/agent.conf will have the same settings except the node name will be qm.foobar. Signed-off-by: Daniel J Walsh --- qm.container | 1 + setup | 38 +++++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/qm.container b/qm.container index fe57a1e5..8655c81b 100644 --- a/qm.container +++ b/qm.container @@ -9,6 +9,7 @@ MemorySwapMax=0 OOMScoreAdjust=500 Restart=always Slice=QM.slice +ExecPreStart=/usr/share/qm/setup hirte-agent [Container] AddCapability=all diff --git a/setup b/setup index fccc6e70..493e010d 100755 --- a/setup +++ b/setup @@ -16,6 +16,7 @@ replaceIDs() { grep -q "^$2:" $1 || echo $2:$3 >> $1 } +AGENTCONF=/etc/hirte/agent.conf INSTALLDIR="$1" [ ! -z "${INSTALLDIR}" ] || INSTALLDIR=/usr/share/qm @@ -26,23 +27,22 @@ systemctl stop qm.service 2>/dev/null || true hirteSetup() { rootfs=$1 - if test ! -f ${rootfs}/etc/hirte/agent.conf; then - if test -f /etc/hirte/agent.conf; then - sed -e 's,^NodeName=,NodeName=qm.,g' /etc/hirte/agent.conf > ${rootfs}/etc/hirte/agent.conf + if test ! -f ${rootfs}${AGENTCONF}; then + if test -f ${AGENTCONF}; then + sed -e 's,^NodeName=,NodeName=qm.,g' ${AGENTCONF} > ${rootfs}${AGENTCONF} fi fi hostname=$(hostname) - if test -f ${rootfs}/etc/hirte/agent.conf; then + if test -f ${rootfs}${AGENTCONF}; then sed -e "s,^NodeName=qm.$,NodeName=qm.${hostname},g" \ -e "s,^NodeName=$,NodeName=qm.${hostname},g" \ - -i ${rootfs}/etc/hirte/agent.conf + -i ${rootfs}${AGENTCONF} else - cat > ${rootfs}/etc/hirte/agent.conf < ${rootfs}${AGENTCONF} <