Advertisement
Guest User

Untitled

a guest
Feb 8th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.62 KB | None | 0 0
  1. #!/bin/sh
  2. ##FreshJR_QOS FakeTC method BETA2 released 02/08/2018
  3. ##Script Tested on ASUS AC-68U, FW382.2, using Adaptive QOS with Manual Bandwidth Settings
  4. ##Script Changes Unidentified Packet QOS destination from Default Traffic Container (Category7) into user definable (in WebUI) Other Traffic Container
  5. ##Script Changes Minimum Guaranteed Bandwidth per QOS category from 128Kbit into user defined percentages upload and download.
  6. ##Script supports custom QOS rules, to create rules copy applicable rule templates below, change filter parameters as desried, and then paste into custom rule start area.
  7. ## Included custom rule moves any TCP/UDP traffic on ports 500 & 4500 into VOIP traffic Container. (Wifi Calling)
  8. ## Included custom rule moves any TCP/UDP traffic on ports 16384 - 16415 into VOIP traffic Container. (Facetime)
  9.  
  10. #---------------------------------------------------------------------------------------------------------------
  11. # VALID FLOW ID'S FOR CUSTOM RULES
  12. # ${VOIP}, ${Gaming}, ${Others}, ${Web}, ${Streaming}, ${Downloads}, ${Default}, ${Net}
  13. #
  14. # VALID MARKS FOR IPTABLES
  15. # ${VOIP_mark}, ${Gaming_mark}, ${Others_mark}, ${Web_mark}, ${Streaming_mark}, ${Downloads_mark}, ${Default_mark}, ${Net_mark}
  16. #
  17. # DOWNLOAD/INCOMMING TRAFFIC rule templates. See comments next to rule for details
  18. # ${tc} filter add dev br0 protocol all prio 2 u32 match ip dport 1234 0xffff flowid ${Downloads} #Template Rule 1 (All incomming traffic w/ LAN destination port 1234 goes to "Downloads" Traffic Container) (0xFFFF port mask defines only one port, if port range is desired see SNB forum post for guide)
  19. # ${tc} filter add dev br0 protocol all prio 2 u32 match ip dst 192.168.1.100/32 flowid ${VOIP} #Template Rule 2 (All incomming traffic w/ LAN destination ip 192.168.1.100 goes to "VOIP" Traffic Container)
  20. # ${tc} filter add dev br0 protocol all prio 2 u32 match u32 0xCCDDEEFF 0xffffffff at -16 flowid {VOIP} #Template Rule 3 (All incomming traffic w/ LAN destination MAC Address AA:BB:CC:DD:EE:FF goes to "VOIP" Traffic Container) **RULE USES LAST 8 MAC DIGITS
  21. # ${tc} filter add dev br0 protocol all prio 2 u32 match ip src 75.75.75.75/32 flowid ${Streaming} #Template Rule 4 (All incomming traffic w/ WAN server source ip 75.75.75.75 goes to "Streaming" Traffic Container) (/32 CIDR mask defines only one ip, if IP range is desired see SNB forum post for guide)
  22. #
  23. # UPLOAD/OUTOING TRAFFIC rule templates. See comments next to rule for details
  24. # ${tc} filter add dev eth0 protocol all prio 2 u32 match ip sport 1234 0xffff flowid ${Downloads} #Template Rule 1 (All outgoing traffic w/ LAN source port 1234 goes to "Downloads" Traffic Container) (0xFFFF port mask defines only one port, if port range is desired see SNB forum post for guide)
  25. # ${tc} filter add dev eth0 protocol all prio 2 u32 match ip src 192.168.1.100/32 flowid ${VOIP} #Template Rule 2 -->NOT WORKING/USE IPTABLES ALTERNATIVE<-- (All outgoing traffic w/ LAN source ip 192.168.1.123 goes to "VOIP" Traffic Container) **Reason this does not work is because you can only apply filters to egress traffic. The egress source IP of outgoing traffic is your Public WAN IP, not your Local LAN IP. So filter will not match on local IP.
  26. # ${tc} filter add dev eth0 protocol all prio 2 u32 match u16 0xEEFF 0xffff at -8 flowid {VOIP} #Template Rule 3 -->NOT WORKING/USE IPTABLES ALTERNATIVE<-- (All outgoing traffic w/ LAN source MAC Address AA:BB:CC:DD:EE:FF goes to "VOIP" Traffic Container) **RULE USES LAST 4 MAC DIGITS **Reason this does not work is because you can only apply filters to egress traffic. The egress source MAC ADDRESS of outgoing traffic is your Router MAC ADDRESS, not your client MAC ADDRESS. So filter will not match on local MAC ADDRESS.
  27. # ${tc} filter add dev eth0 protocol all prio 2 u32 match ip dst 75.75.75.75/32 flowid ${Streaming} #Template Rule 4 (All outgoing traffic w/ WAN server destination ip 75.75.75.75 goes to "Streaming" Traffic Container) (/32 CIDR mask defines only one ip, if IP range is desired see SNB forum post for guide)
  28. #
  29. # iptables -D POSTROUTING -t mangle -o eth0 -s 192.168.1.100/32 -j MARK --set-mark ${VOIP_mark} #Template Rule 2 WORKING ALTERNATIVE (Line1/2)
  30. # iptables -A POSTROUTING -t mangle -o eth0 -s 192.168.1.100/32 -j MARK --set-mark ${VOIP_mark} #Template Rule 2 WORKING ALTERNATIVE (Line2/2)
  31. # iptables -D POSTROUTING -t mangle -o eth0 -m mac --mac-source AA:BB:CC:DD:EE:FF -j MARK --set-mark ${VOIP_mark} #Template Rule 3 WORKING ALTERNATIVE (Line1/2)
  32. # iptables -A POSTROUTING -t mangle -o eth0 -m mac --mac-source AA:BB:CC:DD:EE:FF -j MARK --set-mark ${VOIP_mark} #Template Rule 3 WORKING ALTERNATIVE (Line2/2)
  33. #---------------------------------------------------------------------------------------------------------------
  34.  
  35.  
  36. #################### Bandwidth Setup #####################
  37.  
  38. user_variables() {
  39. #Percent of download speed guaranteed per QOS category, change below as desired (sum should equal 100)
  40. NetControl_DownBandPercent=5 #This value can be adjust as desired
  41. VoIP_DownBandPercent=20 #This value can be adjust as desired
  42. Gaming_DownBandPercent=15 #This value can be adjust as desired
  43. Others_DownBandPercent=10 #This value can be adjust as desired #Note: New destination for all unidentified traffic per script default
  44. WebSurfing_DownBandPercent=10 #This value can be adjust as desired
  45. Video_DownBandPercent=30 #This value can be adjust as desired
  46. FileTransfer_DownBandPercent=5 #This value can be adjust as desired
  47. Default_DownBandPercent=5 #This value can be adjust as desired #Note: Original destination all for unidentified traffic, no traffic should flow here
  48.  
  49. #Percent of upload speed guaranteed per QOS category, change below as desired (sum should equal 100)
  50. NetControl_UpBandPercent=5 #This value can be adjust as desired
  51. VoIP_UpBandPercent=20 #This value can be adjust as desired
  52. Gaming_UpBandPercent=15 #This value can be adjust as desired
  53. Others_UpBandPercent=30 #This value can be adjust as desired #Note: New destination for all unidentified traffic per script default
  54. WebSurfing_UpBandPercent=10 #This value can be adjust as desired
  55. Video_UpBandPercent=10 #This value can be adjust as desired
  56. FileTransfer_UpBandPercent=5 #This value can be adjust as desired
  57. Default_UpBandPercent=5 #This value can be adjust as desired #Note: Original destination all for unidentified traffic, no traffic should flow here
  58. }
  59.  
  60.  
  61. #################### Custom Rules Setup #####################
  62.  
  63. custom_down_rules() {
  64. read_variables
  65. logger "Adaptive QOS: Applying Custom Download Rules"
  66. ##DOWNLOAD (INCOMMING TRAFFIC) CUSTOM RULES START HERE
  67. realtc filter add dev br0 protocol all prio 2 u32 match ip dport 500 0xffff flowid ${VOIP} #Wifi Calling (All incomming traffic w/ LAN destination port 500 goes to "VOIP" Traffic Container)
  68. realtc filter add dev br0 protocol all prio 2 u32 match ip dport 4500 0xffff flowid ${VOIP} #Wifi Calling (All incomming traffic w/ LAN destination port 4500 goes to "VOIP" Traffic Container)
  69. realtc filter add dev br0 protocol all prio 2 u32 match ip dport 16384 0xffe0 flowid ${VOIP} #Facetime
  70. realtc filter add dev br0 protocol all prio 2 u32 match mark 0x80000000 0x8000ffff match ip dst 192.168.1.100/30 flowid ${Gaming} #Gaming - Routed Unidentified Traffic into Gaming for specified LAN devices
  71.  
  72. ##DOWNLOAD (INCOMMING TRAFFIC) CUSTOM RULES END HERE
  73. realtc filter add dev br0 protocol all prio 2 u32 match mark 0x80000000 0x8000ffff flowid ${Others} #Creates rule routing unidentified traffic into "Others" traffic container which user adjustable in webUI, instead of default reouting pf traffoc into non adjustable "Default" traffic container
  74. }
  75.  
  76. custom_up_rules() {
  77. read_variables
  78. logger "Adaptive QOS: Applying Custom Upload Rules"
  79. ##UPLOAD (OUTGOING TRAFFIC) CUSTOM RULES START HERE
  80. realtc filter add dev eth0 protocol all prio 2 u32 match ip sport 500 0xffff flowid ${VOIP} #Wifi Calling (All outgoing traffic w/ LAN source port 500 goes to "VOIP" Traffic Container)
  81. realtc filter add dev eth0 protocol all prio 2 u32 match ip sport 4500 0xffff flowid ${VOIP} #Wifi Calling (All outgoing traffic w/ LAN source port 4500 goes to "VOIP" Traffic Container)
  82. realtc filter add dev eth0 protocol all prio 2 u32 match ip sport 16384 0xffe0 flowid ${VOIP} #Facetime
  83. iptables -D POSTROUTING -t mangle -o eth0 -s 192.168.1.100/30 -m mark --mark 0x40000000/0x4000ffff -j MARK --set-mark ${Gaming_mark} #Gaming - Routed Unidentified Traffic into Gaming for specified LAN devices (line 1/2)
  84. iptables -A POSTROUTING -t mangle -o eth0 -s 192.168.1.100/30 -m mark --mark 0x40000000/0x4000ffff -j MARK --set-mark ${Gaming_mark} #Gaming - Routed Unidentified Traffic into Gaming for specified LAN devices (line 2/2)
  85. ##UPLOAD (OUTGOING TRAFFIC) CUSTOM RULES END HERE
  86. realtc filter add dev eth0 protocol all prio 2 u32 match mark 0x40000000 0x4000ffff flowid ${Others} #Creates rule routing unidentified traffic into "Others" traffic container which user adjustable in webUI, instead of default reouting pf traffoc into non adjustable "Default" traffic container
  87. }
  88.  
  89. rule22_down() {
  90. read_variables
  91. logger "Adaptive QOS: Modifying Download Rule 22 Container Destination"
  92. realtc filter add dev br0 protocol all prio 22 u32 match mark 0x80130000 0xc03f0000 flowid ${Web} #create https traffic that routes HTTPS traffic into "Web Surfing"
  93. }
  94.  
  95. rule22_up() {
  96. read_variables
  97. logger "Adaptive QOS: Modifying Upload Rule 22 Container Destination"
  98. realtc filter add dev eth0 protocol all prio 22 u32 match mark 0x40130000 0xc03f0000 flowid ${Web} #create https traffic that routes HTTPS traffic into "Web Surfing"
  99. }
  100.  
  101. #################### DO NOT MODIFY BELOW #####################
  102. #################### DO NOT MODIFY BELOW #####################
  103. #################### DO NOT MODIFY BELOW #####################
  104. #################### DO NOT MODIFY BELOW #####################
  105. #################### DO NOT MODIFY BELOW #####################
  106. #################### DO NOT MODIFY BELOW #####################
  107. #################### DO NOT MODIFY BELOW #####################
  108. #################### DO NOT MODIFY BELOW #####################
  109. #################### DO NOT MODIFY BELOW #####################
  110. #################### DO NOT MODIFY BELOW #####################
  111. #################### DO NOT MODIFY BELOW #####################
  112.  
  113. read_variables() {
  114. [ -f /jffs/scripts/FreshJR_QOS.vars ] && logger -s "Adaptive QOS: -- ERROR -- FreshJR_QOS.vars file is missing -- QOS non-functional"
  115. source /jffs/scripts/FreshJR_QOS.vars
  116.  
  117. VOIP_mark="0x40060001" #Marks to be used if using iptable rules
  118. Gaming_mark="0x40080001" #Note these marks are same as filter match/mask combo but have a 1 at the end. That trailing 1 prevents them from being caught by unidentified mask
  119. Others_mark="0x400a0001"
  120. Web_mark="0x400d0001"
  121. Streaming_mark="0x40040001"
  122. Downloads_mark="0x40030001"
  123. Default_mark="0x40000000"
  124. Net_mark="0x40090000"
  125. }
  126.  
  127. set_variables() {
  128. logger "Adaptive QOS: Started (Reading User Variables)"
  129. VARFILE="/jffs/scripts/FreshJR_QOS.vars"
  130. echo "" > $VARFILE
  131. echo Net="1:10" >> $VARFILE
  132. user_variables # load user variables at beggining of script
  133. flowid=0
  134. while read -r line; # reads order of QOS filter rules and class catagories
  135. do
  136.  
  137. case ${line%%,*} in # truncates rules present inside each catagory showing only first rule. Use these first rules to correlate each categories with their friendly name and their order
  138. '0')
  139. echo VOIP="1:1${flowid}" >> $VARFILE #VOIP
  140. eval "Cat${flowid}DownBandPercent=${VoIP_DownBandPercent}"
  141. eval "Cat${flowid}UpBandPercent=${VoIP_UpBandPercent}"
  142. ;;
  143. '1')
  144. echo Downloads="1:1${flowid}" >> $VARFILE #Downloads
  145. eval "Cat${flowid}DownBandPercent=${FileTransfer_DownBandPercent}"
  146. eval "Cat${flowid}UpBandPercent=${FileTransfer_UpBandPercent}"
  147. ;;
  148. '4')
  149. echo Streaming="1:1${flowid}" >> $VARFILE #Streaming
  150. eval "Cat${flowid}DownBandPercent=${Video_DownBandPercent}"
  151. eval "Cat${flowid}UpBandPercent=${Video_UpBandPercent}"
  152. ;;
  153. '7')
  154. echo Others="1:1${flowid}" >> $VARFILE #Others
  155. eval "Cat${flowid}DownBandPercent=${Others_DownBandPercent}"
  156. eval "Cat${flowid}UpBandPercent=${Others_UpBandPercent}"
  157. ;;
  158. '8')
  159. echo Gaming="1:1${flowid}" >> $VARFILE #Gaming
  160. eval "Cat${flowid}DownBandPercent=${Gaming_DownBandPercent}"
  161. eval "Cat${flowid}UpBandPercent=${Gaming_UpBandPercent}"
  162. ;;
  163. '9')
  164. Control="1:1${flowid}" #Net Control
  165. Cat0DownBandPercent=${NetControl_DownBandPercent}
  166. Cat0UpBandPercent=${NetControl_UpBandPercent}
  167. ;;
  168. '13')
  169. echo Web="1:1${flowid}" >> $VARFILE #Web Surfing
  170. eval "Cat${flowid}DownBandPercent=${WebSurfing_DownBandPercent}"
  171. eval "Cat${flowid}UpBandPercent=${WebSurfing_UpBandPercent}"
  172. ;;
  173. esac
  174. flowid=$((flowid + 1))
  175. done <<EOF
  176. $(nvram get bwdpi_app_rulelist | tr '<' '\n')
  177. EOF
  178. echo Default="1:17" >> $VARFILE #Default
  179. Cat7DownBandPercent=${Default_DownBandPercent}
  180. Cat7UpBandPercent=${Default_UpBandPercent}
  181.  
  182. DownCeil="$(printf "%.0f" $(nvram get qos_ibw))" #Download rate defined in WebUI
  183. UpCeil="$(printf "%.0f" $(nvram get qos_obw))" #Upload rate defined in WebUI
  184.  
  185. echo " " >> $VARFILE
  186. echo DownRate0="$(expr ${DownCeil} \* ${Cat0DownBandPercent} / 100)" >> $VARFILE #Minimum guarenteed Up/Down rates per QOS catagory corresponding to user defined percentages
  187. echo DownRate1="$(expr ${DownCeil} \* ${Cat1DownBandPercent} / 100)" >> $VARFILE
  188. echo DownRate2="$(expr ${DownCeil} \* ${Cat2DownBandPercent} / 100)" >> $VARFILE
  189. echo DownRate3="$(expr ${DownCeil} \* ${Cat3DownBandPercent} / 100)" >> $VARFILE
  190. echo DownRate4="$(expr ${DownCeil} \* ${Cat4DownBandPercent} / 100)" >> $VARFILE
  191. echo DownRate5="$(expr ${DownCeil} \* ${Cat5DownBandPercent} / 100)" >> $VARFILE
  192. echo DownRate6="$(expr ${DownCeil} \* ${Cat6DownBandPercent} / 100)" >> $VARFILE
  193. echo DownRate7="$(expr ${DownCeil} \* ${Cat7DownBandPercent} / 100)" >> $VARFILE
  194.  
  195. echo " " >> $VARFILE
  196. echo UpRate0="$(expr ${UpCeil} \* ${Cat0UpBandPercent} / 100)" >> $VARFILE
  197. echo UpRate1="$(expr ${UpCeil} \* ${Cat1UpBandPercent} / 100)" >> $VARFILE
  198. echo UpRate2="$(expr ${UpCeil} \* ${Cat2UpBandPercent} / 100)" >> $VARFILE
  199. echo UpRate3="$(expr ${UpCeil} \* ${Cat3UpBandPercent} / 100)" >> $VARFILE
  200. echo UpRate4="$(expr ${UpCeil} \* ${Cat4UpBandPercent} / 100)" >> $VARFILE
  201. echo UpRate5="$(expr ${UpCeil} \* ${Cat5UpBandPercent} / 100)" >> $VARFILE
  202. echo UpRate6="$(expr ${UpCeil} \* ${Cat6UpBandPercent} / 100)" >> $VARFILE
  203. echo UpRate7="$(expr ${UpCeil} \* ${Cat7UpBandPercent} / 100)" >> $VARFILE
  204.  
  205. #Minimum guarenteed Up/Down rates per QOS user within catagory (this allocation occurs after QOS catagory allotment)
  206. #Will be to 1/10 of the parent download catagories rate or a minimum of 25 kb/s
  207. #
  208. #echo " " >> $VARFILE #will be enabled for BETA2
  209. #echo subDownRate0="$(expr ${DownRate0} / 10)" >> $VARFILE #Might save in NVRAM instead of VAR file since subclasses are called and changed often
  210. #echo subDownRate1="$(expr ${DownRate1} / 10)" >> $VARFILE #Not enabled in BETA1 since want to check for existing bugs before experimental features
  211. #echo subDownRate2="$(expr ${DownRate2} / 10)" >> $VARFILE
  212. #echo subDownRate3="$(expr ${DownRate3} / 10)" >> $VARFILE
  213. #echo subDownRate4="$(expr ${DownRate4} / 10)" >> $VARFILE
  214. #echo subDownRate5="$(expr ${DownRate5} / 10)" >> $VARFILE
  215. #echo subDownRate6="$(expr ${DownRate6} / 10)" >> $VARFILE
  216. #echo subDownRate7="$(expr ${DownRate7} / 10)" >> $VARFILE
  217.  
  218. #Will be to 1/10 of the parent download catagories rate or a minimum of 2 kb/s
  219. #
  220. #echo " " >> $VARFILE
  221. #echo subUpRate0="$(expr ${UpRate0} / 10)" >> $VARFILE
  222. #echo subUpRate1="$(expr ${UpRate1} / 10)" >> $VARFILE
  223. #echo subUpRate2="$(expr ${UpRate2} / 10)" >> $VARFILE
  224. #echo subUpRate3="$(expr ${UpRate3} / 10)" >> $VARFILE
  225. #echo subUpRate4="$(expr ${UpRate4} / 10)" >> $VARFILE
  226. #echo subUpRate5="$(expr ${UpRate5} / 10)" >> $VARFILE
  227. #echo subUpRate6="$(expr ${UpRate6} / 10)" >> $VARFILE
  228. #echo subUpRate7="$(expr ${UpRate7} / 10)" >> $VARFILE
  229. }
  230.  
  231.  
  232. #Main program here, will execute different things depending on arguments
  233. case "$@" in
  234. '-init')
  235. set_variables
  236. ;;
  237. '-custom_down_rules')
  238. custom_down_rules
  239. ;;
  240. '-custom_up_rules')
  241. custom_up_rules
  242. ;;
  243. '-rule22_down')
  244. rule22_down
  245. ;;
  246. '-rule22_up')
  247. rule22_up
  248. ;;
  249. '-start') ##RAN ON SCRIPT STARTUP
  250. if [ "/jffs/scripts/FreshJR_QOS_fakeTC" -ef "/usr/sbin/tc" ] ; then
  251. logger -s "Adaptive QOS: FreshJR fakeTC Enabled (No Change Required)"
  252. else
  253. umount /usr/sbin/tc
  254. mount -o bind /jffs/scripts/FreshJR_QOS_fakeTC /usr/sbin/tc #replaces tc with FreshJR_QOS_fakeTC on startup
  255. if [ "/jffs/scripts/FreshJR_QOS_fakeTC" -ef "/usr/sbin/tc" ] ; then
  256. logger -s "Adaptive QOS: FreshJR FakeTC Enabled"
  257. else
  258. logger -s "Adaptive QOS: Start Error - FreshJR FakeTC NOT enabled"
  259. fi
  260. fi
  261. set_variables #creates var file
  262. ;;
  263. 'install'|'enable') ## INSTALLS AND TURNS ON SCRIPT
  264. if [ "$(nvram get qos_enable)" = "1" ] ; then
  265. echo "Disable QOS before attempting to install - script NOT installed"
  266. else
  267. if [ -f /jffs/scripts/firewall-start ] ; then #check if firewall-start exists
  268. if grep -q "#!/bin/sh" /jffs/scripts/firewall-start ; then #check if firewall-start header is correct
  269. : #if header is correct, do nothing
  270. else #if header is incorrect, fix header
  271. echo "Detected improper header in firewall-start, fixing header"
  272. sed -i "1i #!/bin/sh" /jffs/scripts/firewall-start
  273. chmod 0755 /jffs/scripts/firewall-start
  274. fi
  275.  
  276. if grep -q -x "/jffs/scripts/FreshJR_QOS -start" /jffs/scripts/firewall-start ; then #check if FreshJR_QOS is present as item in firewall start
  277. : #if FreshJR_QOS is present do nothing
  278. else #if not, appened it to the last line
  279. echo "Installing FreshJR QOS into firewall-start"
  280. echo "/jffs/scripts/FreshJR_QOS -start" >> /jffs/scripts/firewall-start
  281. fi
  282. else #if firewall-does not exist, set it up entirely
  283. echo "Firewall-start not detected, creating firewall-start"
  284. echo "Installing FreshJR QOS into firewall-start"
  285. echo "#!/bin/sh" > /jffs/scripts/firewall-start
  286. echo "/jffs/scripts/FreshJR_QOS -start" >> /jffs/scripts/firewall-start
  287. chmod 0755 /jffs/scripts/firewall-start
  288. fi
  289.  
  290. if [ "/jffs/scripts/FreshJR_QOS_fakeTC" -ef "/usr/sbin/tc" ] ; then #check if FreshJR_QOS_fakeTC is running after install
  291. echo ""
  292. echo -e "\033[1;32m FreshJR QOS was successfully installed \033[0m"
  293. echo -e "\033[1;32m (Adaptive QOS is turned OFF in router UI) \033[0m"
  294. echo ""
  295. else
  296. umount /usr/sbin/tc
  297. mount -o bind /jffs/scripts/FreshJR_QOS_fakeTC /usr/sbin/tc #if not running, replace faketc with FreshJR_QOS_fakeTC
  298. if [ "/jffs/scripts/FreshJR_QOS_fakeTC" -ef "/usr/sbin/tc" ] ; then
  299. logger "Adaptive QOS: FreshJR QOS FakeTC Installed"
  300. echo ""
  301. echo -e "\033[1;32m FreshJR QOS was successfully installed \033[0m"
  302. echo -e "\033[1;32m (Adaptive QOS is turned OFF in router UI) \033[0m"
  303. echo -e '(Ignore "Cant Unmount - Invalid Argument" Error Message if present)'
  304. echo ""
  305. else
  306. logger -s "Adaptive QOS: Error Installing FreshJR_QOS"
  307. fi
  308. fi
  309. cru d FreshJR_QOS #removes cron job from old version of script
  310. fi
  311. ;;
  312. 'uninstall') ## UNINSTALLS SCRIPT AND DELETES FILES
  313. if [ "$(nvram get qos_enable)" = "1" ] ; then
  314. echo "Disable QOS before attempting to uninstall - script NOT uninstalled"
  315. else
  316. if [ "/usr/sbin/faketc" -ef "/usr/sbin/tc" ] ; then
  317. :
  318. else
  319. umount /usr/sbin/tc
  320. mount -o bind /usr/sbin/faketc /usr/sbin/tc #if script is enabled, replaces FreshJR_QOS_fakeTC with faketc
  321. fi
  322.  
  323. sed -i '/FreshJR_QOS/d' /jffs/scripts/firewall-start #remove FreshJR_QOS from firewall start
  324. rm -f /jffs/scripts/FreshJR_QOS_fakeTC #deletes all related FreshJR_QOS files
  325. rm -f /jffs/scripts/FreshJR_QOS.vars
  326. rm -f /jffs/scripts/FreshJR_QOS
  327. if [ "/usr/sbin/faketc" -ef "/usr/sbin/tc" ] ; then
  328. logger -s "Adaptive QOS: FreshJR QOS Uninstalled"
  329. else
  330. logger -s "Adaptive QOS: Error Uninstalling FreshJR QOS"
  331. fi
  332. cru d FreshJR_QOS #removes cron job from old version of script
  333. fi
  334. ;;
  335. 'disable') ## TURNS OFF SCRIPT BUT KEEP FILES
  336. if [ "/usr/sbin/faketc" -ef "/usr/sbin/tc" ] ; then
  337. sed -i '/FreshJR_QOS/d' /jffs/scripts/firewall-start
  338. logger -s "Adaptive QOS: FreshJR_QOS_fakeTC Disabled"
  339. else
  340. if [ "$(nvram get qos_enable)" = "1" ] ; then
  341. echo "Disable QOS before attempting to disable the script - script not disabled"
  342. else
  343. umount /usr/sbin/tc
  344. mount -o bind /usr/sbin/faketc /usr/sbin/tc #replaces tc with faketc
  345. sed -i '/FreshJR_QOS/d' /jffs/scripts/firewall-start
  346. if [ "/usr/sbin/faketc" -ef "/usr/sbin/tc" ] ; then
  347. logger -s "Adaptive QOS: FreshJR_QOS_fakeTC Disabled"
  348. else
  349. logger -s "Adaptive QOS: Error Disabling FreshJR_QOS_fakeTC"
  350. fi
  351. fi
  352.  
  353. fi
  354. ;;
  355. *)
  356. echo "These are available commands:"
  357. echo ""
  358. echo "FreshJR_QOS check status of script, views help file"
  359. echo "FreshJR_QOS enable starts script, enables autostart on boot"
  360. echo "FreshJR_QOS install starts script, enables autostart on boot"
  361. echo "FreshJR_QOS disable stops script, turns off autostart on boot"
  362. echo "FreshJR_QOS uninstall stops script, turns off autostart on boot, deletes from on disk "
  363. echo ""
  364.  
  365. if [ "/jffs/scripts/FreshJR_QOS_fakeTC" -ef "/usr/sbin/tc" ] ; then
  366. echo -e "\033[1;32m FreshJR QOS fakeTC is enabled \033[0m"
  367. elif [ "/usr/sbin/faketc" -ef "/usr/sbin/tc" ] ; then
  368. echo -e "\033[1;32m FreshJR QOS fakeTC is NOT enabled \033[0m"
  369. else
  370. echo -e "\033[1;32m QOS System is left in a glitched state, please reboot router \033[0m"
  371. fi
  372. if [ "$(nvram get qos_enable)" = "1" ] ; then
  373. echo -e "\033[1;32m (Adaptive QOS is turned ON in router UI) \033[0m"
  374. else
  375. echo -e "\033[1;32m (Adaptive QOS is turned OFF in router UI) \033[0m"
  376. fi
  377. echo ""
  378. ;;
  379. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement