rc.modules 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. else
  27. ifconfig eth0 up
  28. sleep 2
  29. /sbin/udhcpc -n
  30. if [ $? -eq 1 ]; then
  31. sleep 1
  32. interface="eth0"
  33. ip_address=""
  34. netmask=""
  35. gateway=""
  36. while IFS= read -r line; do
  37. # 检查行是否以 iface 开始,并包含指定的接口名
  38. if [[ "$line" == "iface $interface inet static" ]]; then
  39. # 读取下一行,它应该是 address
  40. while read -r next_line; do
  41. # 检查下一行是否以 address 开始
  42. if echo "$next_line" | grep -q "address" ; then
  43. # 提取IP地址(从"address "之后开始)
  44. ip_address=`echo ${next_line} | awk -F ' ' '{print $2}'`
  45. #echo $ip_address
  46. #break # 找到IP后退出循环
  47. elif echo "$next_line" | grep -q "netmask" ;then
  48. netmask=`echo ${next_line} | awk -F ' ' '{print $2}'`
  49. elif echo "$next_line" | grep -q "gateway" ;then
  50. gateway=`echo ${next_line} | awk -F ' ' '{print $2}'`
  51. else
  52. break
  53. #echo "asdas"
  54. fi
  55. done
  56. fi
  57. done < $INTERFACES_FILE
  58. echo "$interface" "$ip_address" "$gateway" "$netmask"
  59. if [[ "$ip_address" == "" ]]; then
  60. `ifconfig eth0 192.168.1.132 up`
  61. else
  62. `ifconfig "$interface" "$ip_address" netmask "$netmask" up`
  63. `route del default`
  64. `route add default gw "$gateway"`
  65. fi
  66. else
  67. echo "hello udhcp!!!"
  68. fi
  69. fi
  70. ./opt/led_flash &
  71. ssh-keygen -A
  72. /etc/init.d/sshd start
  73. export QT_BOOT=/usr/lib/arm-qt
  74. export QTDIR=/usr/lib/arm-qt
  75. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/arm-qt/lib
  76. export LD_LIBRARY_PATH=$QTDIR/lib:$QTDIR/plugins/platforms:$LD_LIBRARY_PATH
  77. export QT_PLUGIN_PATH=$QTDIR/plugins
  78. export QT_QPA_GENERIC_PLUGINS=tslib:$TSLIB_TSDEVICE
  79. export QT_QPA_FONTDIR=$QTDIR/lib/fonts
  80. export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins
  81. export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb1
  82. RUNDIR=/mnt/UDISK
  83. APPDIR=$RUNDIR/app
  84. WEBDIR=$RUNDIR/web
  85. SNMPDIR=$APPDIR/snmp
  86. # source /etc/qtenv.sh
  87. export MIBDIRS=$SNMPDIR/mibs
  88. export LD_LIBRARY_PATH=$APPDIR/lib:${LD_LIBRARY_PATH}
  89. start_snmpd()
  90. {
  91. $SNMPDIR/bin/snmpd -Cc $SNMPDIR/conf/snmpd.conf -Lo &
  92. chmod 777 /var/agentx/master
  93. }
  94. start_pdu()
  95. {
  96. #run smartPDU
  97. $APPDIR/smartPDU &
  98. }
  99. led_on()
  100. {
  101. #light led
  102. echo 160 > /sys/class/gpio/export
  103. echo in > /sys/class/gpio/gpio160/direction
  104. echo 161 > /sys/class/gpio/export
  105. echo in > /sys/class/gpio/gpio161/direction
  106. echo 162 > /sys/class/gpio/export
  107. echo in > /sys/class/gpio/gpio162/direction
  108. echo 131 > /sys/class/gpio/export
  109. echo in > /sys/class/gpio/gpio131/direction
  110. echo 136 > /sys/class/gpio/export
  111. echo out > /sys/class/gpio/gpio136/direction
  112. echo 1 > /sys/class/gpio/gpio136/value
  113. }
  114. start_lcd()
  115. {
  116. # light lcd
  117. led_on
  118. # fbinit
  119. $APPDIR/Qt_Test -platform linuxfb:fb=/dev/fb1 &
  120. }
  121. app_start()
  122. {
  123. case "$1" in
  124. smartPDU)
  125. start_pdu
  126. ;;
  127. snmpd)
  128. start_snmpd
  129. ;;
  130. Qt_Test)
  131. start_lcd
  132. ;;
  133. all)
  134. start_snmpd
  135. start_pdu
  136. start_lcd
  137. ;;
  138. *)
  139. exit 1
  140. esac
  141. }
  142. app_stop()
  143. {
  144. case "$1" in
  145. smartPDU)
  146. killall $1
  147. ;;
  148. snmpd)
  149. killall $1
  150. ;;
  151. Qt_Test)
  152. killall $1
  153. ;;
  154. all)
  155. killall snmpd smartPDU Qt_Test
  156. ;;
  157. *)
  158. exit 1
  159. esac
  160. }
  161. #app_start all
  162. start_snmpd
  163. sleep 4
  164. start_pdu
  165. sleep 5
  166. start_lcd
  167. sh /mnt/UDISK/app/smartMonitor.sh &
  168. # sleep 20
  169. # led_on
  170. # fi