| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340 |
- #!/bin/sh
- echo "------run rc.modules file-----"
- #export boot_partition=$(fw_printenv -n boot_partition 2>/dev/null)
- # if [ x${boot_partition} == xboot ];then
- # /sbin/insmod /lib/modules/5.4.61/usb-storage.ko
- # /sbin/insmod /lib/modules/5.4.61/sunxi_gpadc.ko
- /sbin/insmod /lib/modules/5.4.61/gt9xxnew_ts.ko
- echo 0x07090160 0x083F10F7 > /sys/class/sunxi_dump/write
- # /sbin/insmod /lib/modules/5.4.61/8723ds.ko
- # /sbin/insmod /lib/modules/5.4.61/8189fs.ko
- # /sbin/insmod /lib/modules/5.4.61/r8188eu.ko
- # /sbin/insmod /lib/modules/5.4.61/8821cu.ko
- # sleep 1
- # wpa_supplicant -D wext -c /etc/wpa_supplicant.conf -i wlan0 &
- # udhcpc -i wlan0
- # wpa_supplicant -Dnl80211 -iwlan0 -c /etc/wifi/wpa_supplicant.conf -B
- amixer -D hw:audiocodec cset name='Headphone Switch' 1 && \
- amixer -D hw:audiocodec cset name='Headphone volume' 25
- #ifconfig eth0 192.168.1.132 up
- # 读取interfaces文件
- INTERFACES_FILE="/etc/network/interfaces"
-
- # 检查文件是否存在
- if [ ! -f "$INTERFACES_FILE" ]; then
- echo "Error: $INTERFACES_FILE not found."
- `ifconfig eth0 192.168.1.132 up`
- fi
- # else
- # ifconfig eth0 up
- # sleep 2
- # /sbin/udhcpc -n
- # if [ $? -eq 1 ]; then
- # sleep 1
- # interface="eth0"
- # ip_address=""
- # netmask=""
- # gateway=""
- # while IFS= read -r line; do
- # # 检查行是否以 iface 开始,并包含指定的接口名
- # if [[ "$line" == "iface $interface inet static" ]]; then
- # # 读取下一行,它应该是 address
- # while read -r next_line; do
- # # 检查下一行是否以 address 开始
- # if echo "$next_line" | grep -q "address" ; then
- # # 提取IP地址(从"address "之后开始)
- # ip_address=`echo ${next_line} | awk -F ' ' '{print $2}'`
- # #echo $ip_address
- # #break # 找到IP后退出循环
- # elif echo "$next_line" | grep -q "netmask" ;then
- # netmask=`echo ${next_line} | awk -F ' ' '{print $2}'`
- # elif echo "$next_line" | grep -q "gateway" ;then
- # gateway=`echo ${next_line} | awk -F ' ' '{print $2}'`
- # else
- # break
- # #echo "asdas"
- # fi
-
- # done
-
- # fi
- # done < $INTERFACES_FILE
- # echo "$interface" "$ip_address" "$gateway" "$netmask"
- # if [[ "$ip_address" == "" ]]; then
- # `ifconfig eth0 192.168.1.132 up`
- # else
- # `ifconfig "$interface" "$ip_address" netmask "$netmask" up`
- # `route del default`
- # `route add default gw "$gateway"`
- # fi
- # else
- # echo "hello udhcp!!!"
- # fi
- # fi
-
- interface="eth0"
- ip_address=""
- netmask=""
- gateway=""
- auto_flag=""
- ip_flag=""
- ipv6_addrss=""
- ipv6_netmask=""
- ipv6_gateway=""
- ipv6_autoflag=""
- hw_addr=""
- #if [[ -f /sys/class/addr_mgt/addr_eth ]];then
- # hw_addr=`cat /sys/class/addr_mgt/addr_eth`
- #fi
- #echo "hw $hw_addr"
- #ifconfig $interface hw ether $hw_addr
- #ifconfig $interface up
- while IFS= read -r line; do
- if [[ "$line" == "iface $interface inet static" ]]; then
- ip_flag="1"
- auto_flag="1"
- elif [[ "$line" == "iface $interface inet dhcp" ]];then
- ip_flag="2"
- auto_flag="2"
- elif [[ "$line" == "iface $interface inet6 static" ]];then
- ip_flag="3"
- ipv6_autoflag="3"
- elif [[ "$line" == "iface $interface inet6 dhcp" ]];then
- ip_flag="4"
- ipv6_autoflag="4"
- fi
- if [[ "$ip_flag" == "1" ]]; then
- if echo "$line" | grep -q "address" ; then
- # 提取IP地址(从"address "之后开始)
- ip_address=`echo ${line} | awk -F ' ' '{print $2}'`
- #echo $ip_address
- #break # 找到IP后退出循环
- elif echo "$line" | grep -q "netmask" ;then
- netmask=`echo ${line} | awk -F ' ' '{print $2}'`
- elif echo "$line" | grep -q "gateway" ;then
- gateway=`echo ${line} | awk -F ' ' '{print $2}'`
- fi
- if [[ "$ip_address" != "" && "$netmask" != "" && "$gateway" != "" ]]; then
- ip_flag=""
- fi
- elif [[ "$ip_flag" == "3" ]]; then
- if echo "$line" | grep -q "address" ; then
- # 提取IP地址(从"address "之后开始)
- ipv6_addrss=`echo ${line} | awk -F ' ' '{print $2}'`
- #echo $ip_address
- #break # 找到IP后退出循环
- elif echo "$line" | grep -q "netmask" ;then
- ipv6_netmask=`echo ${line} | awk -F ' ' '{print $2}'`
- elif echo "$line" | grep -q "gateway" ;then
- ipv6_gateway=`echo ${line} | awk -F ' ' '{print $2}'`
- fi
- if [[ "$ipv6_addrss" != "" && "$ipv6_netmask" != "" && "$ipv6_gateway" != "" ]]; then
- ip_flag=""
- fi
- fi
- done < $INTERFACES_FILE
- echo $ip_address $netmask $gateway $auto_flag $ip_flag
- echo $ipv6_addrss $ipv6_netmask $ipv6_gateway $ipv6_autoflag $ip_flag
- if [[ "$auto_flag" == "1" && "$ip_address" != "" && "$netmask" != "" && "$gateway" != "" ]];then
- # `ifconfig $interface hw ether $hw_addr`
- `ifconfig "$interface" "$ip_address" netmask "$netmask" up`
- `route del default`
- `route add default gw "$gateway"`
- echo "Static"
- elif [[ "$auto_flag" == "2" ]];then
- echo "get is DHCPC"
- /sbin/udhcpc &
- sleep 4
- # `ifconfig $interface hw ether $hw_addr`
- else
- echo "Other FAILED"
- `ifconfig eth0 192.168.1.132 up`
- #`ifconfig $interface hw ether $hw_addr`
- echo "" > $INTERFACES_FILE
- echo "# interface file auto-generated by buildroot" >> $INTERFACES_FILE
- echo "auto lo" >> $INTERFACES_FILE
- echo " iface lo inet loopback" >> $INTERFACES_FILE
- echo "auto eth0" >> $INTERFACES_FILE
- echo "iface eth0 inet static" >> $INTERFACES_FILE
- echo " address 192.168.1.132" >> $INTERFACES_FILE
- echo " netmask 255.255.255.0" >> $INTERFACES_FILE
- echo " gateway 192.168.1.0" >> $INTERFACES_FILE
- echo "" >> $INTERFACES_FILE
- echo "iface eth0 inet6 static" >> $INTERFACES_FILE
- echo " address fe80::132" >> $INTERFACES_FILE
- echo " netmask 64" >> $INTERFACES_FILE
- echo " gateway fe80::1" >> $INTERFACES_FILE
- echo "" >> $INTERFACES_FILE
- fi
- if [[ "$ipv6_autoflag" == "3" && "$ipv6_addrss" != "" && "$ipv6_netmask" != "" && "$ipv6_gateway" != "" ]];then
- `ifconfig "$interface" "$ipv6_addrss/$ipv6_netmask" up`
- #`route -A inet6 add default gw $ipv6_gateway dev $interface`
- echo "IPV6 static"
- elif [[ "$auto_flag" == "4" ]];then
- echo "get is DHCPCP"
- else
- echo "Other FAILED"
- #`ifconfig eth0 192.168.1.132 up`
- fi
- ./opt/led_flash &
- ssh-keygen -A
- /etc/init.d/sshd start
- export QT_BOOT=/usr/lib/arm-qt
- export QTDIR=/usr/lib/arm-qt
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/arm-qt/lib
- export LD_LIBRARY_PATH=$QTDIR/lib:$QTDIR/plugins/platforms:$LD_LIBRARY_PATH
- export QT_PLUGIN_PATH=$QTDIR/plugins
- export QT_QPA_GENERIC_PLUGINS=tslib:$TSLIB_TSDEVICE
- export QT_QPA_FONTDIR=$QTDIR/lib/fonts
- export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins
- export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb1
- RUNDIR=/mnt/UDISK
- APPDIR=$RUNDIR/app
- WEBDIR=$RUNDIR/web
- SNMPDIR=$APPDIR/snmp
- # source /etc/qtenv.sh
- export MIBDIRS=$SNMPDIR/mibs
- export LD_LIBRARY_PATH=$APPDIR/lib:${LD_LIBRARY_PATH}
- start_snmpd()
- {
- if [[ -f "$SNMPDIR/bin/snmpd" ]];then
- $SNMPDIR/bin/snmpd -Cc $SNMPDIR/conf/snmpd.conf -Lo &
- chmod 777 /var/agentx/master
- fi
- }
- start_pdu()
- {
- #run smartPDU
- if [[ -f "$APPDIR/smartPDU" ]];then
- $APPDIR/smartPDU &
- fi
- }
- led_on()
- {
- #light led
- echo 160 > /sys/class/gpio/export
- echo in > /sys/class/gpio/gpio160/direction
- echo 161 > /sys/class/gpio/export
- echo in > /sys/class/gpio/gpio161/direction
- echo 162 > /sys/class/gpio/export
- echo in > /sys/class/gpio/gpio162/direction
- echo 131 > /sys/class/gpio/export
- echo in > /sys/class/gpio/gpio131/direction
- echo 136 > /sys/class/gpio/export
- echo out > /sys/class/gpio/gpio136/direction
- echo 1 > /sys/class/gpio/gpio136/value
- }
- start_lcd()
- {
- # light lcd
- led_on
- # fbinit
- if [[ -f "$APPDIR/Qt_Test" ]];then
- $APPDIR/Qt_Test -platform linuxfb:fb=/dev/fb1 &
- fi
- }
- app_start()
- {
- case "$1" in
- smartPDU)
- start_pdu
- ;;
- snmpd)
- start_snmpd
- ;;
- Qt_Test)
- start_lcd
- ;;
- all)
- start_snmpd
- start_pdu
- start_lcd
- ;;
- *)
- exit 1
- esac
- }
- app_stop()
- {
- case "$1" in
- smartPDU)
- killall $1
- ;;
- snmpd)
- killall $1
- ;;
- Qt_Test)
- killall $1
- ;;
- all)
- killall snmpd smartPDU Qt_Test
- ;;
- *)
- exit 1
- esac
- }
- #app_start all
- start_snmpd
- sleep 4
- start_pdu
- sleep 1
- start_lcd
- if [[ -f "/mnt/UDISK/app/smartMonitor.sh" ]];then
- sh /mnt/UDISK/app/smartMonitor.sh &
- fi
- /usr/sbin/smartUPG &
- # sleep 20
- # led_on
- # fi
|