From 264e9e2668457c8ec71aee1d1994ef27da3ca1f1 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 17 Jun 2020 16:41:35 +0200 Subject: [PATCH] Adding and using snippets/tpl.300.create-motd.sh --- kickstart/template-centos8.ks | 5 +++++ snippets/tpl.210.bashrc-centos8.sh | 3 +++ snippets/tpl.300.create-motd.sh | 30 ++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 snippets/tpl.300.create-motd.sh diff --git a/kickstart/template-centos8.ks b/kickstart/template-centos8.ks index f6b8294..5bf9bf2 100644 --- a/kickstart/template-centos8.ks +++ b/kickstart/template-centos8.ks @@ -205,6 +205,11 @@ echo echo "Using snippet $pkgs_snippet" $SNIPPET($pkgs_snippet) +#set $create_motd_snippet = "per_status/" + $SYSTEM_STATUS + "/tpl.300.create-motd.sh" +echo +echo "Using snippet $create_motd_snippet" +$SNIPPET($create_motd_snippet) + diff --git a/snippets/tpl.210.bashrc-centos8.sh b/snippets/tpl.210.bashrc-centos8.sh index 2124f04..dd4441d 100644 --- a/snippets/tpl.210.bashrc-centos8.sh +++ b/snippets/tpl.210.bashrc-centos8.sh @@ -10,6 +10,9 @@ set_bashrc_centos8() { echo local url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/bashrc-centos8" + echo + log "Rewriting /etc/bashrc ..." + local tmp_file=$( mktemp ) wget -O "${tmp_file}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" || true if [[ -s "${tmp_file}" ]] ; then diff --git a/snippets/tpl.300.create-motd.sh b/snippets/tpl.300.create-motd.sh new file mode 100644 index 0000000..77d60b9 --- /dev/null +++ b/snippets/tpl.300.create-motd.sh @@ -0,0 +1,30 @@ +## !/bin/bash +#raw + +#----------------------------------------------------------- +create_motd() { + + echo + echo "${HASH_LINE}" + echo "Calling create_motd() ..." + echo + local url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/create-motd.sh" + + echo + log "Creating initial /etc/motd ..." + + local mk_script=$( mktemp -p /tmp "mk_create_motd.XXXXXXXXXX.ksh" ) + if wget -O "${mk_script}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" ; then + chmod 0755 "${mk_script}" + "${mk_script}" > /etc/motd + else + echo "[$(date)]: Could not get 'mk_create_motd.ksh' from '${url}'." | tee -a "${ERROR_POINTER}" + fi + rm -fv "${mk_script}" + +} + +create_motd + +#end raw +## vim: ts=4 et list -- 2.39.5