Advertisement
test9999113443

Untitled

Sep 27th, 2022
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.92 KB | None | 0 0
  1. [Wive-NG-MT@/etc/root_home]# cat /usr/sbin/services_restart.sh
  2. #!/bin/sh
  3.  
  4. ##########################################################
  5. # This scipt restart needed services #
  6. # #
  7. # MODES: #
  8. # all - call from internel.sh - full reconfigure #
  9. # dhcp - call from dhcp script after full renew #
  10. # pppd - call from ip-up/down scripts #
  11. # misc - call from goahead by apply change in misc page #
  12. ##########################################################
  13.  
  14.  
  15. # prevent double start configure in one time
  16. while [ -e /tmp/servicerestart_runing ]; do
  17. # Sleep until file does exists/is created
  18. usleep 500000
  19. done
  20. touch /tmp/servicerestart_runing
  21.  
  22. # include global config
  23. . /etc/scripts/global.sh
  24.  
  25. LOG="logger -t services"
  26. MODE="$1"
  27.  
  28. $LOG "Restart needed services and scripts. Mode $MODE"
  29.  
  30. ##########################################################
  31. # Always reload shaper and netfilter rules #
  32. ##########################################################
  33. service shaper restart
  34. service iptables restart
  35.  
  36. ##########################################################
  37. # full reconfigure ipv6 if settings apply or first start
  38. # reconfigure ipv6 tunnels after wan/vpn adress renew
  39. # and reconfigure and start radvd/dhcp6s at apply in misc
  40. ##########################################################
  41. if [ "$MODE" = "all" ]; then
  42. service six restart
  43. elif [ "$IPv6OpMode" = "2" -o "$IPv6OpMode" = "3" ] && [ "$MODE" = "dhcp" -o "$MODE" = "pppd" ]; then
  44. service six restart
  45. elif [ "$MODE" = "misc" ]; then
  46. service six dhcpradvdreconf
  47. fi
  48.  
  49. ##########################################################
  50. # Regenerate resolv only if wan_static_dns on
  51. ##########################################################
  52. if [ "$wan_static_dns" = "on" ]; then
  53. service resolv restart
  54. fi
  55.  
  56. ##########################################################
  57. # Always reload some services #
  58. ##########################################################
  59. if [ -e /etc/init.d/parprouted ]; then
  60. service parprouted restart
  61. fi
  62. if [ -e /etc/init.d/dynroute ]; then
  63. service dynroute restart
  64. fi
  65. service dnsserver reload
  66. service ddns restart
  67. service ntp restart
  68. service miniupnpd restart
  69.  
  70. ##########################################################
  71. # restart nodogsplash/chillispot hotspot daemon #
  72. # need always restart - netfilter reconfigure by daemon #
  73. ##########################################################
  74. if [ -e /bin/nodogsplash ]; then
  75. service nodogsplash restart
  76. fi
  77. if [ -e /bin/chilli ]; then
  78. service chillispot restart
  79. fi
  80.  
  81. ##########################################################
  82. # Need restart this: #
  83. # 1) if physycal wan ip adress change #
  84. # 2) if apply changes from web #
  85. # 3) if full reconfigure #
  86. ##########################################################
  87. if [ "$MODE" = "dhcp" ] || [ "$MODE" = "misc" ] || [ "$MODE" = "all" ]; then
  88. if [ -e /etc/init.d/igmp_proxy ]; then
  89. service igmp_proxy restart
  90. fi
  91. if [ -e /etc/init.d/xupnpd ]; then
  92. service xupnpd restart
  93. fi
  94. if [ -e /etc/init.d/udpxy ]; then
  95. service udpxy restart
  96. fi
  97. fi
  98.  
  99. ##########################################################
  100. # Need restart this: #
  101. # 1) if misc chane apply #
  102. # 2) full reconfigure #
  103. ##########################################################
  104. if [ "$MODE" = "misc" ] || [ "$MODE" = "all" ]; then
  105. service kext restart
  106. if [ -e /etc/init.d/lld2d ]; then
  107. service lld2d restart
  108. fi
  109. if [ -e /etc/init.d/snmpd ]; then
  110. service snmpd restart
  111. fi
  112. if [ -e /etc/init.d/inetd ]; then
  113. service inetd restart
  114. fi
  115. if [ -e /etc/init.d/transmission ]; then
  116. service transmission restart
  117. fi
  118. fi
  119.  
  120. ##########################################################
  121. # Reconfigure and restart samba: #
  122. # 1) if recive wins server adress from dhcp #
  123. ##########################################################
  124. if [ "$MODE" = "dhcp" ] && [ -e /tmp/wins.dhcp ]; then
  125. service samba restart
  126. fi
  127.  
  128. # renew /etc/udhcpd.conf and restart dhcp server
  129. if [ "$dnsPEnabled" = "1" -o "$wan_static_dns" = "on" ] && [ "$MODE" = "misc" -o "$MODE" = "all" ]; then
  130. # if dnsmasq or static dns enabled and aplly at web or full reconfigure
  131. service dhcpd restart
  132. elif [ "$dnsPEnabled" != "1" -a "$wan_static_dns" != "on" ] && [ "$MODE" = "pppd" -o "$MODE" = "dhcp" ]; then
  133. # if dnsmasq or static dns disabled and mode=pppd/dhcp (renew/reconnect ISP)
  134. sleep 3
  135. service dhcpd restart
  136. fi
  137.  
  138. ##########################################################
  139. # Always send CDP/SONMP/FDP/EDP to ISP #
  140. ##########################################################
  141. if [ -e /bin/cdp-send ]; then
  142. service cdp restart
  143. fi
  144. if [ -e /bin/lldpd ]; then
  145. service lldpd restart
  146. fi
  147.  
  148. ##########################################################
  149. # restart 802.1x wireless daemon #
  150. ##########################################################
  151. if [ -e /bin/rt2860apd ]; then
  152. service apd restart
  153. fi
  154.  
  155. ##########################################################
  156. # restart bandsteering wireless daemon #
  157. ##########################################################
  158. if [ -e /bin/bndstrg ]; then
  159. service bndstr restart
  160. fi
  161.  
  162. ##########################################################
  163. # restart 802.1f wireless daemon #
  164. ##########################################################
  165. if [ -e /bin/ralinkiappd ]; then
  166. service iappd restart
  167. fi
  168.  
  169. ##########################################################
  170. # After physical reinit #
  171. ##########################################################
  172. if [ "$MODE" = "all" ]; then
  173. ##########################################################
  174. # This is hook for exec user script after connection #
  175. # configured. May be used for add scripts needed by some #
  176. # provides. #
  177. # Example: http://wive-ng.sf.net/downloads/wan_up.sh #
  178. # This script load external routes for www.kvidex.ru ISP #
  179. ##########################################################
  180. if [ -e /etc/scripts/wan_up.sh ]; then
  181. $LOG "Call user /etc/scripts/wan_up.sh script."
  182. sh /etc/scripts/wan_up.sh
  183. fi
  184. ##########################################################
  185. # in dhcp client mode restart from dhcp script #
  186. # in static/zeroconf/pure pppoe mode need restart anyway #
  187. ##########################################################
  188. if [ "$wanConnectionMode" != "DHCP" ] || [ "$purepppoemode" = "1" ]; then
  189. service vpnhelper restart
  190. fi
  191. fi
  192.  
  193. ##########################################################
  194. # need restart L2TP server every netfilter rules replaced
  195. # or ppp session to uplink restarted or new adress recived
  196. ##########################################################
  197. service vpnserver restart
  198.  
  199. ##########################################################
  200. # last stage after apply all changes restart cwmp client
  201. ##########################################################
  202. if [ -e /bin/cwmpd ]; then
  203. service cwmpd restart
  204. fi
  205.  
  206. ##########################################################
  207. # Always rebalance irq by cpus #
  208. ##########################################################
  209. if [ -e /bin/irqbalance ]; then
  210. service irqbalance restart
  211. fi
  212.  
  213. # remove running flag
  214. rm -f /tmp/servicerestart_runing
  215. [Wive-NG-MT@/etc/root_home]#
  216.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement