From 83f655a463c27a30ded921c209772d219cc1ca32 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 11 Apr 2018 14:21:36 +0200 Subject: [PATCH] Adding configuring logrotation --- bin/postinst | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/bin/postinst b/bin/postinst index f3fa810..6d1fbf9 100644 --- a/bin/postinst +++ b/bin/postinst @@ -66,7 +66,7 @@ create_authkeys() { if [[ -s "${tmp_file}" ]] ; then cat "${tmp_file}" >> /root/.ssh/authorized_keys fi - rm "${tmp_file}" + rm -v "${tmp_file}" } #----------------------------------------------------------- @@ -924,6 +924,45 @@ config_rsyslog_to_remote() { } +#----------------------------------------------------------- +config_logrotate() { + + echo + echo "${HASH_LINE}" + echo + log "Configuring logrotation ..." + echo + + mkdir -pv /etc/logrotate.d + + local base_url="${COBBLER_URL}/custom/create-vmware-tpl/files" + + local tmp_file=$( mktemp ) + local url="${base_url}/logrotate.conf" + local tgt="/etc/logrotate.conf" + + echo "Getting ${url} => ${tgt} ..." + wget -O "${tmp_file}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" || true + 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} ..." + wget -O "${tmp_file}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" || true + if [[ -s "${tmp_file}" ]] ; then + cp -v "${tmp_file}" "${tgt}" + fi + done + + rm -v "${tmp_file}" + +} + #----------------------------------------------------------- main() { @@ -952,6 +991,7 @@ main() { install_clamav install_puppet install_postfix + config_logrotate config_rsyslog_to_remote remove_ipv6_localhost -- 2.39.5