dustin
/
jenkinsagent
Archived
1
0
Fork 0

rootfs: Get syslog servers from DHCP options

Instead of parsing the kernel command line to find the destination(s)
where syslog messages should be forwarded, we can use a *dhcpcd* hook to
get them from the DHCP lease.
master
Dustin 2022-03-12 16:23:18 -06:00
parent c972de572c
commit b29e32df30
7 changed files with 33 additions and 21 deletions

View File

@ -1 +1 @@
audit=0 panic=5 console=ttyAMA0 root=nbd:rosalina.pyrocufflink.blue:jenkinsagent rsyslog.dest=rosalina.pyrocufflink.blue sshkeys.root=http://rosalina.pyrocufflink.blue/~dustin/id_ed25519.pub
audit=0 panic=5 console=ttyAMA0 root=nbd:rosalina.pyrocufflink.blue:jenkinsagent sshkeys.root=http://rosalina.pyrocufflink.blue/~dustin/id_ed25519.pub

View File

@ -39,6 +39,8 @@ option ntp_servers
# on the server to actually work.
option rapid_commit
option log_servers
# A ServerID is required by RFC2131.
require dhcp_server_identifier

View File

@ -0,0 +1,28 @@
#!/bin/sh
gen_action() {
echo 'action('
echo ' type="omfwd"'
printf ' Target="%s"\n' "${1}"
echo ' Port="514"'
echo ' template="RSYSLOG_SyslogProtocol23Format"'
echo ')'
}
changed=false
if [ -n "${interface}" ] && [ -d /run/rsyslog.d ]; then
if [ -n "${new_log_servers}" ]; then
echo '# Generated by dhcpcd' > /run/rsyslog.d/dhcpcd."${interface}".conf
for s in ${new_log_servers}; do
gen_action "${s}" >> /run/rsyslog.d/dhcpcd."${interface}".conf
done
changed=true
elif [ -n "${old_log_servers}" ]; then
rm -f /run/rsyslog.d/dhcpcd."${interface}".conf
changed=true
fi
fi
if ${changed}; then
systemctl try-restart rsyslog
fi

View File

@ -1,7 +0,0 @@
[Unit]
Description=Generate rsyslog.conf
Before=rsyslog.service
[Service]
Type=oneshot
ExecStart=/usr/libexec/gen-rsyslog-conf.sh

View File

@ -0,0 +1,2 @@
[Unit]
After=network-online.target

View File

@ -1 +0,0 @@
../gen-rsyslog-conf.service

View File

@ -1,12 +0,0 @@
#!/bin/sh -e
# shellcheck disable=SC2046
set -- $(cat /proc/cmdline)
while [ $# -ge 1 ]; do
case "$1" in
rsyslog.dest=*)
printf '*.* @%s\n' "${1#*=}" >> /run/rsyslog.d/remote.conf
;;
esac
shift
done