From 62cd83c208b20552887549b047714d4511000eca Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Fri, 19 Jun 2020 16:23:57 +0200 Subject: [PATCH] Adding and using snippets/tpl.500.logrotate.sh --- kickstart/template-centos8.ks | 7 ++++- snippets/tpl.500.logrotate.sh | 56 +++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 snippets/tpl.500.logrotate.sh diff --git a/kickstart/template-centos8.ks b/kickstart/template-centos8.ks index 2ab3587..bc744f9 100644 --- a/kickstart/template-centos8.ks +++ b/kickstart/template-centos8.ks @@ -242,8 +242,13 @@ echo echo "Using snippet $postfix_snippet" $SNIPPET($postfix_snippet) +#set $logrotate_snippet = "per_status/" + $SYSTEM_STATUS + "/tpl.500.logrotate.sh" +echo +echo "Using snippet $logrotate_snippet" +$SNIPPET($logrotate_snippet) - +## ########################### +## Sees to be finished #set $finish_snippet = "per_status/" + $SYSTEM_STATUS + "/tpl.999.finish.sh" echo diff --git a/snippets/tpl.500.logrotate.sh b/snippets/tpl.500.logrotate.sh new file mode 100644 index 0000000..f522c1f --- /dev/null +++ b/snippets/tpl.500.logrotate.sh @@ -0,0 +1,56 @@ +## !/bin/bash +#raw + +#----------------------------------------------------------- +config_logrotate() { + + echo + echo "${HASH_LINE}" + echo "Calling config_logrotate() ..." + echo + local base_url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}" + + log "Configuring logrotation ..." + echo + + mkdir -pv /etc/logrotate.d + + local tmp_file=$( mktemp ) + local url="${base_url}/logrotate.conf" + local tgt="/etc/logrotate.conf" + + echo "Getting ${url} => ${tgt} ..." + if wget -O "${tmp_file}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" ; then + : + else + echo "[$(date)]: Could not get 'logrotate.conf' from '${url}'." | tee -a "${ERROR_POINTER}" + fi + if [[ -s "${tmp_file}" ]] ; then + cp -v "${tmp_file}" "${tgt}" + fi + + local base= + for base in btmp syslog wtmp ; do + url="${base_url}/logrotate.d.${base}" + tgt="/etc/logrotate.d/${base}" + cp -v /dev/null "${tmp_file}" + echo "Getting ${url} => ${tgt} ..." + if wget -O "${tmp_file}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" ; then + : + else + echo "[$(date)]: Could not get '${base}' from '${url}'." | tee -a "${ERROR_POINTER}" + fi + if [[ -s "${tmp_file}" ]] ; then + cp -v "${tmp_file}" "${tgt}" + fi + done + + rm -v "${tmp_file}" + echo "Finished logrotate configuration." + +} + +config_logrotate + +#end raw +## vim: ts=4 et list -- 2.39.5