HEX
Server: Apache/2.4.63 (Unix)
System: Linux TOMS-220NAS 4.4.302+ #86009 SMP Wed Nov 26 18:19:17 CST 2025 x86_64
User: flavio87 (1026)
PHP: 8.3.27
Disabled: NONE
Upload Files
File: //usr/syno/lib/systemd/scripts/dhclient6.sh
#!/bin/bash
action=$1
shift;

IFACE=`echo $1 | awk -F '-' '{print $1}'`
ACTION=`echo $1 | awk -F '-' '{print $2}'`

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

case "$action" in
pre-start)
	LEASE_FILE=${LEASE_FILE_PREFIX}.${IFACE}
	CONFIG_FILE=${CONFIG_FILE_PREFIX}.${IFACE}

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

	if [ ! -f ${CONFIG_FILE} ]; then
		/bin/cp -f /etc/dhclient/ipv6/dhclient.conf ${CONFIG_FILE} || true
	fi

	retMsg="$(cp -f /etc/dhclient/dhclient-script /var/run/dhclient-script 2>&1)"
	if [ $? -ne 0 ]; then
		logger -p err "failed to copy dhclient-script: ${retMsg}"
	fi
	;;
start)
	PID_FILE=/tmp/dhclient6-${IFACE}-${ACTION}.pid
	LEASE_FILE=${LEASE_FILE_PREFIX}.${IFACE}
	CONFIG_FILE=${CONFIG_FILE_PREFIX}.${IFACE}

	case "${ACTION}" in
		pd)
			exec /usr/sbin/dhclient -6 -d -q -pf ${PID_FILE} -lf ${LEASE_FILE} -sf /var/run/dhclient-script -cf ${CONFIG_FILE} -P -nw ${IFACE}
			;;
		info)
			exec /usr/sbin/dhclient -6 -d -q -pf ${PID_FILE} -lf ${LEASE_FILE} -sf /var/run/dhclient-script -cf ${CONFIG_FILE} -S -nw ${IFACE}
			;;
		client)
			exec /usr/sbin/dhclient -6 -d -q -pf ${PID_FILE} -lf ${LEASE_FILE} -sf /var/run/dhclient-script -cf ${CONFIG_FILE} -nw ${IFACE}
			;;
		pd-client)
			exec /usr/sbin/dhclient -6 -d -q -pf ${PID_FILE} -lf ${LEASE_FILE} -sf /var/run/dhclient-script -cf ${CONFIG_FILE} -P -N -nw ${IFACE}
			;;
		*)
			;;
	esac
	;;
post-start)
	/usr/bin/logger -t dhcp-client6 -p err "started on $IFACE with action=${ACTION}" || true
	;;
post-stop)
	# 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
	;;
esac