#!/usr/bin/execlineb -P
# lircmd in foreground (--nodaemon). Pause if conf missing/empty.

envfile -I /etc/s6-rc/config/lircmd.conf
importas -sCuD "--nodaemon" Args Args

ifelse {
	ifelse { test -f /etc/lirc/lircmd.conf } {
		pipeline {
			redirfd -r 0 /etc/lirc/lircmd.conf
			grep -Ev "^[[:space:]]*(#|$)"
		} { grep -q . }
	} { exit 1 }
} {
	fdmove -c 2 1
	exec /usr/sbin/lircmd ${Args}
}
s6-pause
