]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Adding snippets for configuring rsyslogd
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 17 Mar 2021 10:16:07 +0000 (11:16 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 17 Mar 2021 10:16:07 +0000 (11:16 +0100)
snippets/tpl.080.rsyslogd-el7.sh [new file with mode: 0644]
snippets/tpl.080.rsyslogd-el8.sh [new file with mode: 0644]

diff --git a/snippets/tpl.080.rsyslogd-el7.sh b/snippets/tpl.080.rsyslogd-el7.sh
new file mode 100644 (file)
index 0000000..d8c8df4
--- /dev/null
@@ -0,0 +1,58 @@
+## !/bin/bash
+#raw
+
+#-----------------------------------------------------------
+set_rsyslogd_el7() {
+
+    echo
+    echo "${HASH_LINE}"
+    echo "Calling set_rsyslogd_el7() ..."
+    echo
+    local url_top="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/rsyslog.conf"
+    local url_sub="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/50_rsyslog.conf.el7"
+
+    echo
+    log "Configuring Rsyslogd."
+
+    echo
+    log "Cleaning /etc/rsyslog.d ..."
+    if [[ -d /etc/rsyslog.d ]] ; then
+        local cfg_file=
+        for cfg_file in /etc/rsyslog.d/*.conf ; do
+            if [[ -f "${cfg_file}" ]] ; then
+                rm -fv "${cfg_file}"
+            fi
+        done
+    else
+        mkdir -pv /etc/rsyslog.d
+    fi
+
+    echo
+    log "Rewriting /etc/rsyslog.conf ..."
+
+    local tmp_file=$( mktemp )
+    wget -O "${tmp_file}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url_top}" || true
+    if [[ -s "${tmp_file}" ]] ; then
+        cp -p /etc/rsyslog.conf /etc/rsyslog.conf.orig
+        mv -v "${tmp_file}" /etc/rsyslog.conf
+        chmod -v 0644 /etc/rsyslog.conf
+    fi
+    rm -fv "${tmp_file}"
+
+    echo
+    log "Rewriting /etc/rsyslog.d/50_rsyslog.conf ..."
+
+    tmp_file=$( mktemp )
+    wget -O "${tmp_file}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url_sub}" || true
+    if [[ -s "${tmp_file}" ]] ; then
+        mv -v "${tmp_file}" /etc/rsyslog.d/50_rsyslog.conf
+        chmod -v 0644 /etc/rsyslog.d/50_rsyslog.conf
+    fi
+    rm -fv "${tmp_file}"
+
+}
+
+set_rsyslogd_el7
+
+#end raw
+## vim: ts=4 et list
diff --git a/snippets/tpl.080.rsyslogd-el8.sh b/snippets/tpl.080.rsyslogd-el8.sh
new file mode 100644 (file)
index 0000000..a46bb3c
--- /dev/null
@@ -0,0 +1,58 @@
+## !/bin/bash
+#raw
+
+#-----------------------------------------------------------
+set_rsyslogd_el8() {
+
+    echo
+    echo "${HASH_LINE}"
+    echo "Calling set_rsyslogd_el8() ..."
+    echo
+    local url_top="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/rsyslog.conf"
+    local url_sub="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/50_rsyslog.conf.el8"
+
+    echo
+    log "Configuring Rsyslogd."
+
+    echo
+    log "Cleaning /etc/rsyslog.d ..."
+    if [[ -d /etc/rsyslog.d ]] ; then
+        local cfg_file=
+        for cfg_file in /etc/rsyslog.d/*.conf ; do
+            if [[ -f "${cfg_file}" ]] ; then
+                rm -fv "${cfg_file}"
+            fi
+        done
+    else
+        mkdir -pv /etc/rsyslog.d
+    fi
+
+    echo
+    log "Rewriting /etc/rsyslog.conf ..."
+
+    local tmp_file=$( mktemp )
+    wget -O "${tmp_file}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url_top}" || true
+    if [[ -s "${tmp_file}" ]] ; then
+        cp -p /etc/rsyslog.conf /etc/rsyslog.conf.orig
+        mv -v "${tmp_file}" /etc/rsyslog.conf
+        chmod -v 0644 /etc/rsyslog.conf
+    fi
+    rm -fv "${tmp_file}"
+
+    echo
+    log "Rewriting /etc/rsyslog.d/50_rsyslog.conf ..."
+
+    tmp_file=$( mktemp )
+    wget -O "${tmp_file}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url_sub}" || true
+    if [[ -s "${tmp_file}" ]] ; then
+        mv -v "${tmp_file}" /etc/rsyslog.d/50_rsyslog.conf
+        chmod -v 0644 /etc/rsyslog.d/50_rsyslog.conf
+    fi
+    rm -fv "${tmp_file}"
+
+}
+
+set_rsyslogd_el8
+
+#end raw
+## vim: ts=4 et list