[Main]
Type = classic
Version = 0.1.0
Description = "isc-dhcp-relay daemon"
User = ( root )
Depends = ( mount-rw )
Options = ( log )

[Start]
Execute = (
	# dhcrelay in foreground (-d). SERVERS/OPTIONS/INTERFACES from
	# /etc/default/isc-dhcp-relay. For multiple -i flags, set IFACE_ARGS in
	# s6-rc config (e.g. IFACE_ARGS="-i eth0 -i eth1"); otherwise a single
	# INTERFACES value is passed as -i ${INTERFACES}.
	
	ifelse { test -f /etc/default/isc-dhcp-relay } {
		envfile /etc/default/isc-dhcp-relay
		importas -sCuD "" SERVERS SERVERS
		importas -sCuD "" OPTIONS OPTIONS
		importas -sCuD "" INTERFACES INTERFACES
		importas -sCuD "" IFACE_ARGS IFACE_ARGS
	
		ifelse { test -z "${SERVERS}" } {
			s6-pause
		} {
			ifelse { test -n "${IFACE_ARGS}" } {
				exec /usr/sbin/dhcrelay -d -q ${OPTIONS} ${IFACE_ARGS} ${SERVERS}
			} {
				ifelse { test -n "${INTERFACES}" } {
					exec /usr/sbin/dhcrelay -d -q ${OPTIONS} -i ${INTERFACES} ${SERVERS}
				} {
					exec /usr/sbin/dhcrelay -d -q ${OPTIONS} ${SERVERS}
				}
			}
		}
	}
	s6-pause
)

[Logger]
RunAs = s6log
Backup = 3
MaxSize = 2000000
Timestamp = tai
Destination = /var/log/isc-dhcp-relay
