HEX
Server: Apache/2.2.34 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0910052141
System: Linux Kou-Etsu-Dou 4.4.59+ #25556 SMP PREEMPT Thu Mar 4 18:03:46 CST 2021 x86_64
User: hosam (1026)
PHP: 7.2.29
Disabled: NONE
Upload Files
File: //etc/init/dhcp-client6.conf
description "configure DHCP client for IPv6"

normal exit 0 SIGKILL
console log
respawn
respawn limit 3 30

# TODO: @IFACE might be changed at runtime, use network interface ID which will
#       be implemented in the future. Therefore, the arguments would be changed
#       to `$IFACE/$ID/$ACTION`
instance $IFACE/$ACTION

env LEASE_FILE_PREFIX=/tmp/dhcpv6.lease
env CONFIG_FILE_PREFIX=/etc/dhclient/ipv6/dhcpv6.conf

pre-start script
	LEASE_FILE=${LEASE_FILE_PREFIX}.${IFACE}
	CONFIG_FILE=${CONFIG_FILE_PREFIX}.${IFACE}

	/bin/echo default-duid \"`/usr/syno/sbin/synonetdtool --gen-DUID`\"\; > ${LEASE_FILE} || true

	if [ "xclient" == "x${ACTION}" ] && [ ! -f ${CONFIG_FILE} ]; then
		/bin/cp -f /etc/dhclient/ipv6/dhclient.conf ${CONFIG_FILE} || true
	fi
end script

script
	PID_FILE=/tmp/dhclient6-${IFACE}-${ACTION}.pid
	LEASE_FILE=${LEASE_FILE_PREFIX}.${IFACE}
	CONFIG_FILE=${CONFIG_FILE_PREFIX}.${IFACE}

	if [ ! -f /var/run/dhclient-script ]; then
		cp -f /etc/dhclient/dhclient-script /var/run/dhclient-script || true
	fi

	case "${ACTION}" in
		pd)
			exec /usr/sbin/dhclient -6 -d -q -pf ${PID_FILE} -sf /var/run/dhclient-script -lf ${LEASE_FILE} -P -nw ${IFACE}
			;;
		info)
			exec /usr/sbin/dhclient -6 -d -q -pf ${PID_FILE} -sf /var/run/dhclient-script -lf ${LEASE_FILE} -S -nw ${IFACE}
			;;
		client)
			exec /usr/sbin/dhclient -6 -d -q -pf ${PID_FILE} -sf /var/run/dhclient-script -lf ${LEASE_FILE} -cf ${CONFIG_FILE} -nw ${IFACE}
			;;
		*)
			;;
	esac
end script

post-start script
	/usr/bin/logger -t dhcp-client6 -p err "started on $IFACE with action=${ACTION}" || true
end script

post-stop script
	# flush ipv6 ip
	if [ "xclient" == "x${ACTION}" ]; then
		/sbin/ip -6 addr flush dev $IFACE scope global || true
	fi

	/usr/bin/logger -t dhcp-client6 -p err "stopped on $IFACE with action=${ACTION}" || true
end script
# vim:ft=upstart