]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Adding and using snippets/tpl.500.logrotate.sh
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 19 Jun 2020 14:23:57 +0000 (16:23 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 19 Jun 2020 14:23:57 +0000 (16:23 +0200)
kickstart/template-centos8.ks
snippets/tpl.500.logrotate.sh [new file with mode: 0644]

index 2ab3587952564168985475f4415c6429bf73dbf0..bc744f9831d099a8dfa90d34e5c0fb01979d3b8e 100644 (file)
@@ -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 (file)
index 0000000..f522c1f
--- /dev/null
@@ -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