75 lines
1.7 KiB
Lua
75 lines
1.7 KiB
Lua
add_packages({ "socklog" })
|
|
-- Thanks to https://github.com/void-linux/socklog-void
|
|
|
|
modules.runit.add_service("socklog-unix",
|
|
[[#!/bin/sh
|
|
exec chpst -U nobody:nogroup socklog unix /dev/log 2>&1]],
|
|
[[#!/bin/sh
|
|
exec svlogd -ttt /var/log/socklog/*]])
|
|
modules.data.add_data_dir("/data/socklog/", "/var/log/socklog", "root", "root")
|
|
add_file("/etc/socklog/everything", [[!syslog-stripdate
|
|
-auth.*
|
|
-authpriv.*]])
|
|
modules.data.add_data_link("/etc/socklog/everything", "/var/log/socklog/everything/config")
|
|
|
|
-- TODO: package
|
|
add_file("/usr/local/bin/svlogtail", [[#!/bin/sh
|
|
|
|
usage () {
|
|
cat <<-'EOF'
|
|
svlogtail [-f] [LOG...] - show svlogd logs conveniently
|
|
Without arguments, show current logs of all services, uniquely.
|
|
With arguments, show all logs of mentioned services
|
|
|
|
With -f, follow log output.
|
|
EOF
|
|
}
|
|
|
|
globexist() {
|
|
[ -f "$1" ]
|
|
}
|
|
|
|
IFS='
|
|
'
|
|
|
|
fflag=false
|
|
if [ "$1" = -f ]; then
|
|
shift
|
|
fflag=true
|
|
fi
|
|
|
|
if [ $# = 0 ]; then
|
|
cat /var/log/socklog/*/current | sort -u
|
|
if $fflag; then
|
|
tail -Fq -n0 /var/log/socklog/*/current | uniq
|
|
fi
|
|
else
|
|
old=
|
|
cur=
|
|
for log; do
|
|
case "$log" in
|
|
-*) usage; exit 1;;
|
|
esac
|
|
if [ -d /var/log/socklog/$log ]; then
|
|
if globexist /var/log/socklog/$log/*.[us]; then
|
|
old="$old$IFS/var/log/socklog/$log/*.[us]"
|
|
fi
|
|
cur="$cur$IFS/var/log/socklog/$log/current"
|
|
else
|
|
echo "no logs for $log" 1>&2
|
|
exit 1
|
|
fi
|
|
done
|
|
cat $old $cur | sort
|
|
if $fflag; then
|
|
tail -Fq -n0 $cur
|
|
fi
|
|
fi]])
|
|
chmod("/usr/local/bin/svlogtail", "700")
|
|
|
|
-- TODO: reemplazar con nanoklogd https://github.com/void-linux/socklog-void/blob/master/nanoklogd.c
|
|
modules.runit.add_service("log-kernel",
|
|
[[#!/bin/sh
|
|
exec cat /proc/kmsg]],
|
|
[[#!/bin/sh
|
|
exec logger -p kern.info -t '']])
|