rc.modules 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. #!/bin/sh
  2. echo "------run rc.modules file-----"
  3. #export boot_partition=$(fw_printenv -n boot_partition 2>/dev/null)
  4. # if [ x${boot_partition} == xboot ];then
  5. # /sbin/insmod /lib/modules/5.4.61/usb-storage.ko
  6. # /sbin/insmod /lib/modules/5.4.61/sunxi_gpadc.ko
  7. /sbin/insmod /lib/modules/5.4.61/gt9xxnew_ts.ko
  8. echo 0x07090160 0x083F10F7 > /sys/class/sunxi_dump/write
  9. # /sbin/insmod /lib/modules/5.4.61/8723ds.ko
  10. # /sbin/insmod /lib/modules/5.4.61/8189fs.ko
  11. # /sbin/insmod /lib/modules/5.4.61/r8188eu.ko
  12. # /sbin/insmod /lib/modules/5.4.61/8821cu.ko
  13. # sleep 1
  14. # wpa_supplicant -D wext -c /etc/wpa_supplicant.conf -i wlan0 &
  15. # udhcpc -i wlan0
  16. # wpa_supplicant -Dnl80211 -iwlan0 -c /etc/wifi/wpa_supplicant.conf -B
  17. amixer -D hw:audiocodec cset name='Headphone Switch' 1 && \
  18. amixer -D hw:audiocodec cset name='Headphone volume' 25
  19. #ifconfig eth0 192.168.1.132 up
  20. # 读取interfaces文件
  21. INTERFACES_FILE="/etc/network/interfaces"
  22. # 检查文件是否存在
  23. if [ ! -f "$INTERFACES_FILE" ]; then
  24. echo "Error: $INTERFACES_FILE not found."
  25. `ifconfig eth0 192.168.1.132 up`
  26. fi
  27. # else
  28. # ifconfig eth0 up
  29. # sleep 2
  30. # /sbin/udhcpc -n
  31. # if [ $? -eq 1 ]; then
  32. # sleep 1
  33. # interface="eth0"
  34. # ip_address=""
  35. # netmask=""
  36. # gateway=""
  37. # while IFS= read -r line; do
  38. # # 检查行是否以 iface 开始,并包含指定的接口名
  39. # if [[ "$line" == "iface $interface inet static" ]]; then
  40. # # 读取下一行,它应该是 address
  41. # while read -r next_line; do
  42. # # 检查下一行是否以 address 开始
  43. # if echo "$next_line" | grep -q "address" ; then
  44. # # 提取IP地址(从"address "之后开始)
  45. # ip_address=`echo ${next_line} | awk -F ' ' '{print $2}'`
  46. # #echo $ip_address
  47. # #break # 找到IP后退出循环
  48. # elif echo "$next_line" | grep -q "netmask" ;then
  49. # netmask=`echo ${next_line} | awk -F ' ' '{print $2}'`
  50. # elif echo "$next_line" | grep -q "gateway" ;then
  51. # gateway=`echo ${next_line} | awk -F ' ' '{print $2}'`
  52. # else
  53. # break
  54. # #echo "asdas"
  55. # fi
  56. # done
  57. # fi
  58. # done < $INTERFACES_FILE
  59. # echo "$interface" "$ip_address" "$gateway" "$netmask"
  60. # if [[ "$ip_address" == "" ]]; then
  61. # `ifconfig eth0 192.168.1.132 up`
  62. # else
  63. # `ifconfig "$interface" "$ip_address" netmask "$netmask" up`
  64. # `route del default`
  65. # `route add default gw "$gateway"`
  66. # fi
  67. # else
  68. # echo "hello udhcp!!!"
  69. # fi
  70. # fi
  71. interface="eth0"
  72. ip_address=""
  73. netmask=""
  74. gateway=""
  75. auto_flag=""
  76. ip_flag=""
  77. while IFS= read -r line; do
  78. if [[ "$line" == "iface $interface inet static" ]]; then
  79. ip_flag="1"
  80. auto_flag="1"
  81. elif [[ "$line" == "iface $interface inet dhcp" ]];then
  82. ip_flag="2"
  83. auto_flag="2"
  84. fi
  85. if [[ "$ip_flag" == "1" ]]; then
  86. if echo "$line" | grep -q "address" ; then
  87. # 提取IP地址(从"address "之后开始)
  88. ip_address=`echo ${line} | awk -F ' ' '{print $2}'`
  89. #echo $ip_address
  90. #break # 找到IP后退出循环
  91. elif echo "$line" | grep -q "netmask" ;then
  92. netmask=`echo ${line} | awk -F ' ' '{print $2}'`
  93. elif echo "$line" | grep -q "gateway" ;then
  94. gateway=`echo ${line} | awk -F ' ' '{print $2}'`
  95. fi
  96. if [[ "$ip_address" != "" && "$netmask" != "" && "$gateway" != "" ]]; then
  97. ip_flag=""
  98. fi
  99. fi
  100. done < $INTERFACES_FILE
  101. echo $ip_address $netmask $gateway $auto_flag $ip_flag
  102. if [[ "$auto_flag" == "1" && "$ip_address" != "" && "$netmask" != "" && "$gateway" != "" ]];then
  103. `ifconfig "$interface" "$ip_address" netmask "$netmask" up`
  104. `route del default`
  105. `route add default gw "$gateway"`
  106. echo "Static"
  107. elif [[ "$auto_flag" == "2" ]];then
  108. echo "get is DHCPC"
  109. /sbin/udhcpc -n
  110. else
  111. echo "Other FAILED"
  112. `ifconfig eth0 192.168.1.132 up`
  113. fi
  114. ./opt/led_flash &
  115. ssh-keygen -A
  116. /etc/init.d/sshd start
  117. export QT_BOOT=/usr/lib/arm-qt
  118. export QTDIR=/usr/lib/arm-qt
  119. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/arm-qt/lib
  120. export LD_LIBRARY_PATH=$QTDIR/lib:$QTDIR/plugins/platforms:$LD_LIBRARY_PATH
  121. export QT_PLUGIN_PATH=$QTDIR/plugins
  122. export QT_QPA_GENERIC_PLUGINS=tslib:$TSLIB_TSDEVICE
  123. export QT_QPA_FONTDIR=$QTDIR/lib/fonts
  124. export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins
  125. export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb1
  126. RUNDIR=/mnt/UDISK
  127. APPDIR=$RUNDIR/app
  128. WEBDIR=$RUNDIR/web
  129. SNMPDIR=$APPDIR/snmp
  130. # source /etc/qtenv.sh
  131. export MIBDIRS=$SNMPDIR/mibs
  132. export LD_LIBRARY_PATH=$APPDIR/lib:${LD_LIBRARY_PATH}
  133. start_snmpd()
  134. {
  135. $SNMPDIR/bin/snmpd -Cc $SNMPDIR/conf/snmpd.conf -Lo &
  136. chmod 777 /var/agentx/master
  137. }
  138. start_pdu()
  139. {
  140. #run smartPDU
  141. $APPDIR/smartPDU &
  142. }
  143. led_on()
  144. {
  145. #light led
  146. echo 160 > /sys/class/gpio/export
  147. echo in > /sys/class/gpio/gpio160/direction
  148. echo 161 > /sys/class/gpio/export
  149. echo in > /sys/class/gpio/gpio161/direction
  150. echo 162 > /sys/class/gpio/export
  151. echo in > /sys/class/gpio/gpio162/direction
  152. echo 131 > /sys/class/gpio/export
  153. echo in > /sys/class/gpio/gpio131/direction
  154. echo 136 > /sys/class/gpio/export
  155. echo out > /sys/class/gpio/gpio136/direction
  156. echo 1 > /sys/class/gpio/gpio136/value
  157. }
  158. start_lcd()
  159. {
  160. # light lcd
  161. led_on
  162. # fbinit
  163. $APPDIR/Qt_Test -platform linuxfb:fb=/dev/fb1 &
  164. }
  165. app_start()
  166. {
  167. case "$1" in
  168. smartPDU)
  169. start_pdu
  170. ;;
  171. snmpd)
  172. start_snmpd
  173. ;;
  174. Qt_Test)
  175. start_lcd
  176. ;;
  177. all)
  178. start_snmpd
  179. start_pdu
  180. start_lcd
  181. ;;
  182. *)
  183. exit 1
  184. esac
  185. }
  186. app_stop()
  187. {
  188. case "$1" in
  189. smartPDU)
  190. killall $1
  191. ;;
  192. snmpd)
  193. killall $1
  194. ;;
  195. Qt_Test)
  196. killall $1
  197. ;;
  198. all)
  199. killall snmpd smartPDU Qt_Test
  200. ;;
  201. *)
  202. exit 1
  203. esac
  204. }
  205. #app_start all
  206. start_snmpd
  207. sleep 4
  208. start_pdu
  209. sleep 5
  210. start_lcd
  211. sh /mnt/UDISK/app/smartMonitor.sh &
  212. # sleep 20
  213. # led_on
  214. # fi