Просмотр исходного кода

1、针对打包工具升级,修改恢复出厂逻辑
2、snmp配置修改时,增加agent的重启

guohui лет назад: 2
Родитель
Сommit
d85c72030e
6 измененных файлов с 32 добавлено и 12 удалено
  1. 9 6
      output/push2/tools/script.sh
  2. 1 0
      pro/src/app.c
  3. 1 0
      pro/src/common.h
  4. 4 0
      pro/src/paras.c
  5. 15 6
      pro/src/sys.c
  6. 2 0
      pro/src/thread.c

+ 9 - 6
output/push2/tools/script.sh

@@ -13,7 +13,6 @@ function is_ipv6()
         return 0
     fi
 }
-
 function kill_all()
 {
     killall  RestartApp.sh smartMornitor.sh smartMonitor.sh main  snmpd  Qt_Test  smartPDU  smartUPG
@@ -54,17 +53,17 @@ function set_net()
    ifconfig eth0 $ip4
 }
 
-
 kill_all
 rm_old
 
 echo release $obj ... 
 tar -xpf  $tmpdir/pdutar  -C  /  >/dev/null  2>&1
 if [ -e $tmpdir/logo.png ]; then
-    cp -rf $tmpdir/logo.png /root/run/app/image/
+    cp -f $tmpdir/logo.png /root/run/app/image/
 fi
 if [ -e $tmpdir/smartPDU.ini ]; then
-    cp -rf $tmpdir/smartPDU.ini /root/run/app/
+    cp -f $tmpdir/smartPDU.ini /root/run/app/
+    cp -f $tmpdir/smartPDU.ini /root/run/app/smartPDU_bak.ini
     rm -rf /root/bak/*
 fi
 rm -rf $tmpdir
@@ -72,8 +71,12 @@ rm -rf $tmpdir
 set_net
 
 echo +++++++ upgrade ok! +++++++
-echo reboot device now ... 
-reboot -f
+echo  reboot device now ...
+
+reboot -d 1
+exit 0
+
+
 
 
 

+ 1 - 0
pro/src/app.c

@@ -1854,6 +1854,7 @@ int snmp_config(SNMPManager *m)
         system(cmd);
     }
     system("/etc/init.d/S90PDUApp restart snmpd");
+    thread_restart(THREAD_ID_SNMP);
 
     return 0;
 }

+ 1 - 0
pro/src/common.h

@@ -39,6 +39,7 @@
 #define DATABASE_BAK_NAME   "pdu_dat_bak.db"
 #define SNMP_MIB_NAME       "pduMIB"
 #define INI_FILE_NAME       "smartPDU.ini"
+#define INI_FILE_BAK_NAME   "smartPDU_bak.ini"
 
 //高配表头串口定义-----------------------------------------------
 //控制板通信串口

+ 4 - 0
pro/src/paras.c

@@ -380,6 +380,7 @@ static int ini_reset(paras_handle_t *h)
 {
     int r;
     FILE *fp=NULL;
+    char tmp[200];
     GlobalDeviceInfo *info=&DFLT_PARAS;
 
     fp = fopen(h->path, "w");
@@ -410,6 +411,9 @@ static int ini_reset(paras_handle_t *h)
 
     fclose(fp);
 
+    sys_get_path(tmp, INI_FILE_BAK_NAME);
+    file_copy(tmp, h->path);
+
     if(h->dic) {
         iniparser_freedict(h->dic);
     }

+ 15 - 6
pro/src/sys.c

@@ -138,19 +138,28 @@ int sys_set_factory(void)
 
     snprintf(src, sizeof(src), "%s/%s", dir, DATABASE_BAK_NAME);
     snprintf(dst, sizeof(dst), "%s/%s", dir, DATABASE_NAME);
-
-    paras_reset();
-
     LOGD("___ file_copy from %s to %s\n", src, dst);
     r = file_copy(dst, src);
+
+    if(0) {
+        r = paras_reset();
+    }
+    else {
+        snprintf(src, sizeof(src), "%s/%s", dir, INI_FILE_BAK_NAME);
+        snprintf(dst, sizeof(dst), "%s/%s", dir, INI_FILE_NAME);
+
+        LOGD("___ file_copy from %s to %s\n", src, dst);
+        r = file_copy(dst, src);
+    }
+
     if(r==0) {
-    #if 0
+#if 0
         r = set_net(&DFLT_PARAS.dev._network_info, IP_V4);
         if(r) {
             LOGE("____ set_net failed\n");
             return -1;
         }
-    #endif
+#endif
 
         LOGD("____ exit smartPDU now ...\n");
         exit(0);
@@ -1214,7 +1223,7 @@ int sys_init(void)
     lock_s_init();
     paras_init();
     
-    nic_restart(DFLT_NIC);
+    //nic_restart(DFLT_NIC);
     thread_start(THREAD_ID_POLLING, NULL);
 
     return 0;

+ 2 - 0
pro/src/thread.c

@@ -41,6 +41,7 @@ int thread_restart(int id)
     }
     thread_attr_t *attr=&thdAttrs[id];
 
+    thread_stop(id);
     return thread_startEx(id, attr->name, attr->fn, attr->arg, attr->stksz, attr->prio);
 }
 
@@ -110,6 +111,7 @@ int thread_stop(int id)
     thread_handle_t *h=&thdHandles[id];
 
     h->quit = 1;
+    //pthread_detach();
     pthread_join(h->tid, NULL);
     h->tid = 0;
     h->running = 0;