Sfoglia il codice sorgente

开启dhcp,dns,web升级

guohui 2 anni fa
parent
commit
edcce0344a

BIN
output/merge


+ 6 - 6
output/pack.sh

@@ -1,16 +1,16 @@
 #!/bin/sh
 
-NUM=$1
-STRA=$2
-OBJ1=$3
-OBJ2=$4
+NUM=0
+STRA=0
+OBJ1=0
+OBJ2=0
 
 TMP=pdutar
 TARGET=pdupkg
 
 FULLDIR=$(realpath $0)
 CURDIR=$(dirname $FULLDIR)
-MERG=$CURDIR/merge/merge
+MERG=$CURDIR/merge
 
 SRCDIR=$CURDIR/t113i
 OUTDIR=$CURDIR/push
@@ -24,6 +24,6 @@ chmod 777 -R $OUTDIR
 tar -czpf $OUTDIR/$TMP -C $SRCDIR .
 
 #echo merge pdupkg
-#$MERG $NUM $STRA $OBJ1 $OBJ2 $OUTDIR/$TMP
+$MERG $NUM $STRA $OBJ1 $OBJ2 $OUTDIR/$TMP
 
 

+ 2 - 1
output/t113i/etc/init.d/rcS

@@ -30,8 +30,9 @@ mdev -s
 
 /etc/adb_conf.sh start &
 #/usr/sbin/dnsmasq
-#/sbin/udhcpc -i eth0 -s /usr/share/udhcpc/default.script
+/sbin/udhcpc -i eth0 -s /usr/share/udhcpc/default.script
 /usr/sbin/smartMonitor.sh &
+/usr/sbin/smartUPG &
 
 tinymix set "ADC2 Input MIC2 Boost Switch" 1 > /dev/null
 tinymix set "ADC3 Input MIC3 Boost Switch" 1 > /dev/null

+ 4 - 4
output/t113i/etc/profile

@@ -21,10 +21,10 @@ unset i
 
 export XDG_RUNTIME_DIR=/dev/shm
 
-RUNDIR=/root/run
-APPDIR=$RUNDIR/app
-WEBDIR=$RUNDIR/web
-SNMPDIR=$APPDIR/snmp
+export RUNDIR=/root/run
+export APPDIR=$RUNDIR/app
+export WEBDIR=$RUNDIR/web
+export SNMPDIR=$APPDIR/snmp
 
 source /etc/qtenv.sh
 export MIBDIRS=$SNMPDIR/mibs

+ 10 - 12
pro/CMakeLists.txt

@@ -102,22 +102,20 @@ set(SRC_DIR  ${PROJECT_BINARY_DIR})
 set(DST_DIR ${PROJECT_SOURCE_DIR}/../output)
 set(CHIP t113i)
 
+set(UPG_SRC_LIST ${PROJECT_SOURCE_DIR}/upgrade/md5.c
+                 ${PROJECT_SOURCE_DIR}/upgrade/upgrade.c)
+				
+add_executable(smartUPG ${UPG_SRC_LIST})
+target_link_libraries(smartUPG -lc -lpthread)
+
+add_custom_command(TARGET  smartUPG  POST_BUILD
+                   COMMAND mkdir -p ${DST_DIR}/${CHIP}/usr/sbin
+                   COMMAND cp -upf  ${SRC_DIR}/smartUPG ${DST_DIR}/${CHIP}/usr/sbin)
 
 add_custom_command(TARGET  smartPDU  POST_BUILD
                    COMMAND mkdir -p ${DST_DIR}/${CHIP}/root/run/app
                    COMMAND cp -upf  ${SRC_DIR}/smartPDU ${DST_DIR}/${CHIP}/root/run/app
-				   COMMAND ${DST_DIR}/pack.sh
-				   )
+                   COMMAND ${DST_DIR}/pack.sh)
 
-if(0)
-	set(UPG_SRC_LIST   ${PROJECT_SOURCE_DIR}/upgrade/md5.c
-				   	   ${PROJECT_SOURCE_DIR}/upgrade/upgrade.c)
-				   
-	add_executable(smartUPG ${UPG_SRC_LIST})
-	target_link_libraries(smartUPG -lc -lpthread)
 
-	add_custom_command(TARGET  smartUPG  POST_BUILD
-                   COMMAND mkdir -p ${DST_DIR}/${CHIP}/usr/sbin
-                   COMMAND cp -upf  ${SRC_DIR}/smartUPG ${DST_DIR}/${CHIP}/usr/sbin)
-endif()
 

+ 3 - 1
pro/src/appweb_handle.c

@@ -3984,7 +3984,9 @@ static void equipmentMintenanceUpload(void *conn)
         upload_handle(conn, path);
     }
 
-    http_reply(conn, 200, "操作成功");
+    ack_str = ctrl_sts_ack_to_json();
+    http_reply(conn, 200, ack_str);
+    cJSON_free(ack_str);
 }
 
 static void equipmentMintenanceExport(void *conn)

+ 3 - 0
pro/src/sys.c

@@ -743,6 +743,9 @@ static int set_net(NetworkInfo_t *para, int ipv)
 
     r = file_save(FILE_NET, fbuf, strlen(fbuf));
     if(r==0) {
+        //system("ip addr flush dev eth0");
+        //sprintf(eth0, "ip link set dev eth0 %s/%d && ip link set eth0 up && ip link set eth0 down", info->ip_address, info->netmask);
+        //system(eth0);
         system("ifdown eth0 && ifup eth0");
     }
     free(fbuf);

+ 33 - 5
pro/upgrade/upgrade.c

@@ -524,15 +524,43 @@ static int file_clear(void)
 }
 
 
-
 //////////////////////////////////////////////////
+static int is_running(char *prog)
+{
+    FILE *fp;
+    int pid=0;
+    char buf[20]={0};
+    char command[200];
+
+    snprintf(command, sizeof(command), "ps -ef | grep -v grep | grep -w -c %s", prog);
+
+    fp = popen(command, "r");
+    if (fp == NULL) {
+    LOGE("execute %s failed: %s", command, strerror(errno));
+    return 0;
+    }
+
+    if (fgets(buf, sizeof(buf), fp)) {
+    pid = atoi(buf);
+    }
+    pclose(fp);
+    
+    return (pid)?1:0;
+}
+
 static int app_start(void)
 {
-    return 0;//system("smartMonitor.sh &");
+    LOGD("____ app_start\n");
+
+    if(is_running("smartMonitor.sh")) {
+        return -1;
+    }
+    return system("/usr/sbin/smartMonitor.sh &");
 }
 static int app_stop(void)
 {
-    return 0;//system("killall smartMonitor.sh && /etc/init.d/S90PDUApp stop");
+    LOGD("____ app_stop\n");
+    return system("killall smartMonitor.sh; /etc/init.d/S90PDUApp stop");
 }
 
 //////////////////////////////////////////////////
@@ -686,7 +714,6 @@ static int upg_handle(upg_handle_t *h)
                 if(r==0) {
                     file_touch(UPGRADE_STEP_COVER);
                     h->step = UPGRADE_STEP_FINISH;
-                    app_start();
                 }
                 else {
                     LOGD("file_cover, delete %s!\n", tmp);
@@ -698,10 +725,11 @@ static int upg_handle(upg_handle_t *h)
                     file_untouch(UPGRADE_STEP_COVER);
                     
                     file_restore();
-                    app_start();
+                    
                 }
                 file_untouch(UPGRADE_STEP_DOWN);
                 file_untouch(UPGRADE_STEP_SPLIT);
+                app_start();
             }
             break;