|
@@ -183,16 +183,22 @@ static int file_touch(int id)
|
|
|
{
|
|
{
|
|
|
int r;
|
|
int r;
|
|
|
char tmp[200];
|
|
char tmp[200];
|
|
|
-
|
|
|
|
|
- snprintf(tmp, sizeof(tmp), "touch %s/s%d", UPG_FOLDER, id);
|
|
|
|
|
|
|
+#if (CHIP_TYPE == CHIP_T113i)
|
|
|
|
|
+ snprintf(tmp, sizeof(tmp), "touch %s/s%d;sleep 1;sync;", UPG_FOLDER, id);
|
|
|
|
|
+#else
|
|
|
|
|
+ snprintf(tmp, sizeof(tmp), "touch %s/s%d;sleep 1;sync;sync;", UPG_FOLDER, id);
|
|
|
|
|
+#endif
|
|
|
return system(tmp); // 使用写入模式创建一个新文件
|
|
return system(tmp); // 使用写入模式创建一个新文件
|
|
|
}
|
|
}
|
|
|
static int file_untouch(int id)
|
|
static int file_untouch(int id)
|
|
|
{
|
|
{
|
|
|
int r;
|
|
int r;
|
|
|
char tmp[200];
|
|
char tmp[200];
|
|
|
-
|
|
|
|
|
- snprintf(tmp, sizeof(tmp), "rm %s/s%d", UPG_FOLDER, id);
|
|
|
|
|
|
|
+#if (CHIP_TYPE == CHIP_T113i)
|
|
|
|
|
+ snprintf(tmp, sizeof(tmp), "rm %s/s%d;sleep 1;sync;", UPG_FOLDER, id);
|
|
|
|
|
+#else
|
|
|
|
|
+ snprintf(tmp, sizeof(tmp), "rm %s/s%d;sleep 1;sync;sync;", UPG_FOLDER, id);
|
|
|
|
|
+#endif
|
|
|
return system(tmp); // 使用写入模式创建一个新文件
|
|
return system(tmp); // 使用写入模式创建一个新文件
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -271,8 +277,11 @@ static int file_cover(char *path)
|
|
|
{
|
|
{
|
|
|
int r;
|
|
int r;
|
|
|
char cmd[200];
|
|
char cmd[200];
|
|
|
-
|
|
|
|
|
|
|
+#if (CHIP_TYPE == CHIP_T113i)
|
|
|
snprintf(cmd, sizeof(cmd), "tar -xpf %s -C / > /dev/null 2>&1", path);
|
|
snprintf(cmd, sizeof(cmd), "tar -xpf %s -C / > /dev/null 2>&1", path);
|
|
|
|
|
+#else
|
|
|
|
|
+ snprintf(cmd, sizeof(cmd), "tar -zxvf %s -C / > /dev/null", path);
|
|
|
|
|
+#endif
|
|
|
r = system(cmd);
|
|
r = system(cmd);
|
|
|
if(r) {
|
|
if(r) {
|
|
|
LOGE("%s failed\n", cmd);
|
|
LOGE("%s failed\n", cmd);
|
|
@@ -533,7 +542,12 @@ static int is_running(char *prog)
|
|
|
char buf[20]={0};
|
|
char buf[20]={0};
|
|
|
char command[200];
|
|
char command[200];
|
|
|
|
|
|
|
|
|
|
+#if (CHIP_TYPE == CHIP_T113i)
|
|
|
snprintf(command, sizeof(command), "ps -ef | grep -v grep | grep -w -c %s", prog);
|
|
snprintf(command, sizeof(command), "ps -ef | grep -v grep | grep -w -c %s", prog);
|
|
|
|
|
+#else
|
|
|
|
|
+ snprintf(command, sizeof(command), "ps | grep -v grep | grep -w -c %s", prog);
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
|
|
|
fp = popen(command, "r");
|
|
fp = popen(command, "r");
|
|
|
if (fp == NULL) {
|
|
if (fp == NULL) {
|
|
@@ -556,12 +570,30 @@ static int app_start(void)
|
|
|
if(is_running("smartMonitor.sh")) {
|
|
if(is_running("smartMonitor.sh")) {
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
|
|
+#if (CHIP_TYPE == CHIP_T113i)
|
|
|
return system("/usr/sbin/smartMonitor.sh &");
|
|
return system("/usr/sbin/smartMonitor.sh &");
|
|
|
|
|
+#else
|
|
|
|
|
+ return system("sh /mnt/UDISK/app/smartMonitor.sh &");
|
|
|
|
|
+#endif
|
|
|
}
|
|
}
|
|
|
static int app_stop(void)
|
|
static int app_stop(void)
|
|
|
{
|
|
{
|
|
|
LOGD("____ app_stop\n");
|
|
LOGD("____ app_stop\n");
|
|
|
- return system("killall smartMonitor.sh; /etc/init.d/S90PDUApp stop");
|
|
|
|
|
|
|
+#if (CHIP_TYPE == CHIP_T113i)
|
|
|
|
|
+ system("killall smartMonitor.sh; /etc/init.d/S90PDUApp stop");
|
|
|
|
|
+ ret = system("echo \"V\" > /dev/watchdog");
|
|
|
|
|
+ sleep(1);
|
|
|
|
|
+ ret = system("echo \"V\" > /dev/watchdog");
|
|
|
|
|
+#else
|
|
|
|
|
+ LOGD("app_stop T113 S3\n");
|
|
|
|
|
+ int ret = system("killall sh snmpd Qt_Test smartPDU");
|
|
|
|
|
+ ret = system("echo \"V\" > /dev/watchdog");
|
|
|
|
|
+ sleep(1);
|
|
|
|
|
+ ret = system("echo \"V\" > /dev/watchdog");
|
|
|
|
|
+ sleep(1);
|
|
|
|
|
+ ret = system("echo \"V\" > /dev/watchdog");
|
|
|
|
|
+ return ret;
|
|
|
|
|
+#endif
|
|
|
}
|
|
}
|
|
|
static int sys_reboot(void)
|
|
static int sys_reboot(void)
|
|
|
{
|
|
{
|
|
@@ -661,6 +693,7 @@ static int upg_handle(upg_handle_t *h)
|
|
|
|
|
|
|
|
//先检查下载目录是否存在pdupkg文件
|
|
//先检查下载目录是否存在pdupkg文件
|
|
|
snprintf(tmp, sizeof(tmp), "%s/%s", DOWN_FOLDER, UPG_PKG_NAME);
|
|
snprintf(tmp, sizeof(tmp), "%s/%s", DOWN_FOLDER, UPG_PKG_NAME);
|
|
|
|
|
+ printf("%s\n",tmp);
|
|
|
if(file_exist(tmp)) {
|
|
if(file_exist(tmp)) {
|
|
|
file_touch(UPGRADE_STEP_DOWN);
|
|
file_touch(UPGRADE_STEP_DOWN);
|
|
|
h->step = UPGRADE_STEP_SPLIT;
|
|
h->step = UPGRADE_STEP_SPLIT;
|
|
@@ -719,7 +752,8 @@ static int upg_handle(upg_handle_t *h)
|
|
|
if(r==0) {
|
|
if(r==0) {
|
|
|
file_touch(UPGRADE_STEP_COVER);
|
|
file_touch(UPGRADE_STEP_COVER);
|
|
|
h->step = UPGRADE_STEP_FINISH;
|
|
h->step = UPGRADE_STEP_FINISH;
|
|
|
-
|
|
|
|
|
|
|
+ file_untouch(UPGRADE_STEP_DOWN);
|
|
|
|
|
+ file_untouch(UPGRADE_STEP_SPLIT);
|
|
|
sys_reboot();
|
|
sys_reboot();
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
@@ -730,12 +764,11 @@ static int upg_handle(upg_handle_t *h)
|
|
|
|
|
|
|
|
h->step = UPGRADE_STEP_NONE;
|
|
h->step = UPGRADE_STEP_NONE;
|
|
|
file_untouch(UPGRADE_STEP_COVER);
|
|
file_untouch(UPGRADE_STEP_COVER);
|
|
|
-
|
|
|
|
|
|
|
+ file_untouch(UPGRADE_STEP_SPLIT);
|
|
|
file_restore();
|
|
file_restore();
|
|
|
app_start();
|
|
app_start();
|
|
|
}
|
|
}
|
|
|
- file_untouch(UPGRADE_STEP_DOWN);
|
|
|
|
|
- file_untouch(UPGRADE_STEP_SPLIT);
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
@@ -751,8 +784,9 @@ static int upg_handle(upg_handle_t *h)
|
|
|
LOGD("___ UPGRADE_STEP_SUCCESS\n");
|
|
LOGD("___ UPGRADE_STEP_SUCCESS\n");
|
|
|
|
|
|
|
|
h->step = UPGRADE_STEP_NONE;
|
|
h->step = UPGRADE_STEP_NONE;
|
|
|
-
|
|
|
|
|
|
|
+#if (CHIP_TYPE == CHIP_T113i)
|
|
|
file_backup(); //启动成功才证明程序有效,可进行备份, 备份成功,删除下载目录中的文件以节省空间
|
|
file_backup(); //启动成功才证明程序有效,可进行备份, 备份成功,删除下载目录中的文件以节省空间
|
|
|
|
|
+#endif
|
|
|
file_clear();
|
|
file_clear();
|
|
|
|
|
|
|
|
//app_start();
|
|
//app_start();
|