#!/bin/sh
# hotplug event for ipgroup update

# record the log
mkdir -p "/tmp/.qos_ctl"
local HOTP_LOG="/tmp/.qos_ctl/hotplug.log"
[ ! -f $HOTP_LOG ] && echo -e "time \ttrigger \taction" > $HOTP_LOG
[ "`ls -l $HOTP_LOG | awk '{print $5}'`" -gt 100000 ] && echo -e "time \ttrigger \taction" > $HOTP_LOG
echo -e "`date +%Y%m%d-%H:%M:%S` $group_name $ACTION" >> $HOTP_LOG

# CHECK IF qos module is ready
[ ! -f /tmp/.qos_ctl/ready ] && echo -e "`date +%Y%m%d-%H:%M:%S` \tqos not start, ignore hotplug msg!" >>$HOTP_LOG && exit

# response 
case "$ACTION" in 
		update)
			. /lib/qos_ctl/main.sh ipv6group $ACTION $group_name
			;; 
		*)
			echo -e "`date +%Y%m%d-%H:%M:%S` \tillegal $ACTION!" >> $HOTP_LOG
			;;
esac
