OnConnect 900 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/sh
  2. LOGIN=$1
  3. IP=$2
  4. CASH=$3
  5. ID=$4
  6. SPEED=`/etc/stargazer/GetSpeed $LOGIN`
  7. UPSPEED=`/etc/stargazer/GetUpSpeed $LOGIN`
  8. MAC=`/etc/stargazer/GetMac $LOGIN`
  9. SCOUNT="Kbit/s"
  10. fwcmd="/sbin/ipfw -q"
  11. arpcmd="/usr/sbin/arp"
  12. cur_date=`date \+\%Y.\%m.\%d`
  13. cur_time=`date \+\%H:\%M:\%S`
  14. # fix user mac to ip
  15. ${arpcmd} -S $IP $MAC
  16. #SPEED CONTROL
  17. ${fwcmd} pipe `expr $ID + 101` config bw $UPSPEED$SCOUNT queue 128Kbytes
  18. ${fwcmd} pipe `expr $ID + 32101` config bw $SPEED$SCOUNT queue 128Kbytes
  19. # SHAPER
  20. ${fwcmd} table 3 add $IP `expr $ID + 101`
  21. ${fwcmd} table 4 add $IP `expr $ID + 32101`
  22. ${fwcmd} table 47 delete $IP
  23. # DAY/NIGHT switcher
  24. /bin/echo $SPEED:`expr $ID + 32101` > /etc/stargazer/dn/$LOGIN
  25. /bin/chmod 777 /etc/stargazer/dn/$LOGIN
  26. # ADD TO LOG
  27. echo "$cur_date $cur_time CONNECT: ID-$ID;LOGIN-$LOGIN;IP-$IP;CASH-$CASH;SPEED-$SPEED;UPSPEED-$UPSPEED,MAC-$MAC" >> /var/stargazer/allconnect.log