Przeglądaj źródła

转脚本文件格式

guohui 2 lat temu
rodzic
commit
d0e975548b
5 zmienionych plików z 39 dodań i 28 usunięć
  1. 15 10
      output/push/tools/script.sh
  2. 10 10
      pro/config/cfg.h
  3. 1 1
      pro/src/app.c
  4. 8 4
      pro/src/netswitch.c
  5. 5 3
      pub

+ 15 - 10
output/push/tools/script.sh

@@ -30,21 +30,26 @@ function rm_old()
 }
 }
 function set_net()
 function set_net()
 {
 {
-   ip4=`ip addr show dev eth0 | sed -e's/^.*inet \([^ ]*\)\/.*$/\1/;t;d'`
-   ip6=`ip addr show dev eth0 | sed -e's/^.*inet6 \([^ ]*\)\/.*$/\1/;t;d'`
-   str_lo="auto lo\niface lo inet loopback\n\n"
-   str_e0="auto eth0\niface eth0 inet static\naddress $ip4\nnetmask 255.255.255.0\ngateway 192.168.1.1\n\n"
+   netfile=/etc/network/interfaces
+   content=$(cat $netfile)
    
    
-   if [ "$ip6" = "" ]; then
-      echo ___$ip6
+   if [[ $content == *"address"* ]]; then
+      return
    fi
    fi
-   
-   str_e1="auto eth1\niface eth1 inet dhcp\npre-up /etc/network/nfs_check\nwait-delay 5\nhostname $(hostname)\n"
 
 
-   netfile=/etc/network/interfaces
+   ip4=192.168.1.132
+   mask4=255.255.255.0
+   gw4=192.168.1.1
+
+   str_lo="auto lo\niface lo inet loopback\n\n"
+   str_e0="auto eth0\niface eth0 inet static\naddress $ip4\nnetmask $mask4\ngateway $gw4\n\n"
+   str_e1="auto eth1\niface eth1 inet dhcp\npre-up /etc/network/nfs_check\nwait-delay 5\nhostname $(hostname)\n"
+   
    echo -e $str_lo > $netfile
    echo -e $str_lo > $netfile
    echo -e $str_e0 >> $netfile
    echo -e $str_e0 >> $netfile
    echo -e $str_e1 >> $netfile
    echo -e $str_e1 >> $netfile
+
+   ifconfig eth0 $ip4
 }
 }
 
 
 
 
@@ -60,7 +65,7 @@ echo release $obj ...
 tar -xpf  $obj  -C  /  >/dev/null  2>&1
 tar -xpf  $obj  -C  /  >/dev/null  2>&1
 rm $obj
 rm $obj
 
 
-#set_net
+set_net
 
 
 echo +++++++ upgrade ok! +++++++
 echo +++++++ upgrade ok! +++++++
 echo reboot device now ... 
 echo reboot device now ... 

+ 10 - 10
pro/config/cfg.h

@@ -21,14 +21,15 @@
 
 
 
 
 /////////////customer demannd//////////////////////
 /////////////customer demannd//////////////////////
-//#define CUST_GOM037
+#define CUST_GOM037     //xian
 //#define CUST_USASL
 //#define CUST_USASL
-#define CUST_ANDERSON
+//#define CUST_ANDERSON
 
 
 
 
-#ifdef CUST_GOM037
+#ifdef CUST_GOM037      //xian
     //#define GOM037_PDU_GC10_08K_80H        //ac_in1_out1_40a_p8_5ch_nologo_cn
     //#define GOM037_PDU_GC10_08K_80H        //ac_in1_out1_40a_p8_5ch_nologo_cn
-    //#define GOM037PDU_GC20_04K_125H       //ac_in1_out1_40a_p4_5ch_nologo_cn
+    //#define GOM037PDU_GC20_04K_125H        //ac_in1_out1_40a_p4_5ch_nologo_cn
+  
 
 
     #ifdef GOM037PDU_GC20_04K_125H
     #ifdef GOM037PDU_GC20_04K_125H
         #undef CHANNEL_DELAY_SEC
         #undef CHANNEL_DELAY_SEC
@@ -40,26 +41,25 @@
     #define PDU_GC40_03K_125H           //ac_in3_out3_40a_p8_12ch_nologo_en
     #define PDU_GC40_03K_125H           //ac_in3_out3_40a_p8_12ch_nologo_en
 
 
     //#define PDU_GC60_04K_125H         //ac_in3_out1_40a_p4_24ch_nologo_en
     //#define PDU_GC60_04K_125H         //ac_in3_out1_40a_p4_24ch_nologo_en
-
 #endif
 #endif
 
 
 
 
-
 #ifdef CUST_ANDERSON
 #ifdef CUST_ANDERSON
     #define USE_NETSWITCH
     #define USE_NETSWITCH
 
 
     #define SW_PORT_INDEX_START         0
     #define SW_PORT_INDEX_START         0
     #define SW_PORT_INDEX_END           21
     #define SW_PORT_INDEX_END           21
 
 
-    #define SW_HOST_IP                  "192.168.0.1"
+    #define USE_STATIC_IP
+    #ifdef USE_STATIC_IP
+        #define SW_HOST_IP              "192.168.8.1"
+        #define SW_PDU_IP               "192.168.8.11"
+    #endif
     
     
     #undef MAX_CHN_COUNT
     #undef MAX_CHN_COUNT
     #define MAX_CHN_COUNT               24
     #define MAX_CHN_COUNT               24
 #endif
 #endif
 
 
-
-
-
 ////////////////////////////////////////////////////
 ////////////////////////////////////////////////////
 
 
 
 

+ 1 - 1
pro/src/app.c

@@ -2298,7 +2298,7 @@ int _global_device_manage_init(GlobalDeviceManager* _globalDeviceManager)
     appweb_init();
     appweb_init();
 
 
     cascade_init();
     cascade_init();
-    //netswitch_init();
+    netswitch_init();
 
 
     //通知smartUPG,app已经运行起来
     //通知smartUPG,app已经运行起来
     upg_init();
     upg_init();

+ 8 - 4
pro/src/netswitch.c

@@ -20,9 +20,6 @@
 #endif
 #endif
 
 
 
 
-#define USE_STATIC_IP
-
-
 #define SW_PORT_START       99329
 #define SW_PORT_START       99329
 #define NETSNMP_DS_APP_DONT_FIX_PDUS 0
 #define NETSNMP_DS_APP_DONT_FIX_PDUS 0
 
 
@@ -471,6 +468,13 @@ static int sw_get(netswitch_info_t *sw)
     if(h->ipflag==0) {
     if(h->ipflag==0) {
 #ifdef USE_STATIC_IP
 #ifdef USE_STATIC_IP
         strcpy(h->ipaddr, SW_HOST_IP);
         strcpy(h->ipaddr, SW_HOST_IP);
+        sprintf(temp, "%ip addr add %s", SW_PDU_IP);
+        r = system(temp);
+        if(r) {
+            LOGE("____set pdu ip failed\n");
+            return -1;
+        }
+        h->ipflag = 1;
 #else
 #else
         r = get_ipaddr(AF_INET, "eth0", h->ipaddr);
         r = get_ipaddr(AF_INET, "eth0", h->ipaddr);
         if(r) {
         if(r) {
@@ -482,8 +486,8 @@ static int sw_get(netswitch_info_t *sw)
                 return -1;
                 return -1;
             }
             }
         }
         }
-#endif
         h->ipflag = 1;
         h->ipflag = 1;
+#endif
     }
     }
     //LOGD("___local ip: %s\n", h->ipaddr);
     //LOGD("___local ip: %s\n", h->ipaddr);
 
 

+ 5 - 3
pub

@@ -8,7 +8,7 @@
 #  8:  ANDERSON_EN
 #  8:  ANDERSON_EN
 #  9:  USA_SL
 #  9:  USA_SL
 
 
-cust=8
+cust=1
 
 
 cmp_flag=1
 cmp_flag=1
 if [ $# -gt 0 ]; then
 if [ $# -gt 0 ]; then
@@ -24,13 +24,15 @@ custdir=$curdir/cust_data
 function do_copy()
 function do_copy()
 {
 {
     echo do_copy ...
     echo do_copy ...
-
+    
+    mkdir -p $curdir/output/t113i/root/run/app/image
     if [ $cust -eq 1 ]; then
     if [ $cust -eq 1 ]; then
         rm -rf  $curdir/output/t113i/root/run/web
         rm -rf  $curdir/output/t113i/root/run/web
         cp -rf $custdir/web/general  $curdir/output/t113i/root/run/web
         cp -rf $custdir/web/general  $curdir/output/t113i/root/run/web
 
 
-        cp -f $custdir/db/ac_i1_o1_chinese2.db $curdir/output/t113i/root/run/app/pdu_dat.db
+        cp -f $custdir/db/ac_i1_o1_chinese.db $curdir/output/t113i/root/run/app/pdu_dat.db
         #cp -f $custdir/db/ac_i3_o1_chinese.db $curdir/output/t113i/root/run/app/pdu_dat.db
         #cp -f $custdir/db/ac_i3_o1_chinese.db $curdir/output/t113i/root/run/app/pdu_dat.db
+	#cp -f $custdir/db/ac_i3_o3_chinese.db $curdir/output/t113i/root/run/app/pdu_dat.db
         cp -f $custdir/logo/logo_neuter.png $curdir/output/t113i/root/run/app/image/logo.png
         cp -f $custdir/logo/logo_neuter.png $curdir/output/t113i/root/run/app/image/logo.png
     elif [ $cust -eq 2 ]; then
     elif [ $cust -eq 2 ]; then
         rm -rf  $curdir/output/t113i/root/run/web
         rm -rf  $curdir/output/t113i/root/run/web