mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-03-13 20:40:05 +01:00
Ticket refs #1365: TR-157: Device.SoftwareModules. object
This commit is contained in:
parent
76b0afcd61
commit
33eb15471d
8 changed files with 553 additions and 692 deletions
118
backupSession.c
118
backupSession.c
|
|
@ -452,40 +452,36 @@ void bkp_session_delete_apply_schedule_download(struct apply_schedule_download *
|
|||
|
||||
void bkp_session_insert_change_du_state(struct change_du_state *pchange_du_state)
|
||||
{
|
||||
struct search_keywords keys[7];
|
||||
char schedule_time[128];
|
||||
char file_size[128];
|
||||
mxml_node_t *b, *n, *t;
|
||||
int i;
|
||||
pthread_mutex_lock (&mutex_backup_session);
|
||||
|
||||
sprintf(schedule_time,"%ld",pchange_du_state->timeout);
|
||||
b = bkp_session_insert(bkp_tree,"change_du_state",NULL);
|
||||
bkp_session_insert(b,"command_key",pchange_du_state->command_key);
|
||||
bkp_session_insert(b,"time",schedule_time);
|
||||
struct operations *p;
|
||||
char schedule_time[128];
|
||||
mxml_node_t *b, *n;
|
||||
|
||||
pthread_mutex_lock (&mutex_backup_session);
|
||||
sprintf(schedule_time, "%ld", pchange_du_state->timeout);
|
||||
b = bkp_session_insert(bkp_tree, "change_du_state", NULL);
|
||||
bkp_session_insert(b, "command_key", pchange_du_state->command_key);
|
||||
bkp_session_insert(b, "time", schedule_time);
|
||||
|
||||
list_for_each_entry(p, &(pchange_du_state->list_operation), list) {
|
||||
if (p->type == DU_INSTALL ) {
|
||||
n = bkp_session_insert(b,"install",NULL);
|
||||
bkp_session_insert(n,"url",p->url);
|
||||
bkp_session_insert(n,"uuid",p->uuid);
|
||||
bkp_session_insert(n,"username",p->username);
|
||||
bkp_session_insert(n,"password",p->password);
|
||||
bkp_session_insert(n,"executionenvref",p->executionenvref);
|
||||
}
|
||||
else if (p->type == DU_UNINSTALL) {
|
||||
n = bkp_session_insert(b,"uninstall",NULL);
|
||||
bkp_session_insert(n,"uuid",p->uuid);
|
||||
bkp_session_insert(n,"version",p->version);
|
||||
bkp_session_insert(n,"executionenvref",p->executionenvref);
|
||||
}
|
||||
else if (p->type == DU_UPDATE) {
|
||||
n = bkp_session_insert(b,"upgrade",NULL);
|
||||
bkp_session_insert(n,"url",p->url);
|
||||
bkp_session_insert(n,"uuid",p->uuid);
|
||||
bkp_session_insert(n,"username",p->username);
|
||||
bkp_session_insert(n,"password",p->password);
|
||||
bkp_session_insert(n,"version",p->version);
|
||||
n = bkp_session_insert(b, "install", NULL);
|
||||
bkp_session_insert(n, "url", p->url);
|
||||
bkp_session_insert(n, "uuid", p->uuid);
|
||||
bkp_session_insert(n, "username", p->username);
|
||||
bkp_session_insert(n, "password", p->password);
|
||||
bkp_session_insert(n, "executionenvref", p->executionenvref);
|
||||
} else if (p->type == DU_UPDATE) {
|
||||
n = bkp_session_insert(b, "upgrade", NULL);
|
||||
bkp_session_insert(n, "uuid", p->uuid);
|
||||
bkp_session_insert(n, "version", p->version);
|
||||
bkp_session_insert(n, "url", p->url);
|
||||
bkp_session_insert(n, "username", p->username);
|
||||
bkp_session_insert(n, "password", p->password);
|
||||
} else if (p->type == DU_UNINSTALL) {
|
||||
n = bkp_session_insert(b, "uninstall", NULL);
|
||||
bkp_session_insert(n, "uuid", p->uuid);
|
||||
bkp_session_insert(n, "version", p->version);
|
||||
bkp_session_insert(n, "executionenvref", p->executionenvref);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock (&mutex_backup_session);
|
||||
|
|
@ -494,7 +490,7 @@ void bkp_session_insert_change_du_state(struct change_du_state *pchange_du_state
|
|||
void bkp_session_delete_change_du_state(struct change_du_state *pchange_du_state)
|
||||
{
|
||||
struct search_keywords keys[2];
|
||||
char schedule_time[128];
|
||||
char schedule_time[128];
|
||||
mxml_node_t *b;
|
||||
|
||||
pthread_mutex_lock (&mutex_backup_session);
|
||||
|
|
@ -654,46 +650,44 @@ void bkp_session_delete_upload(struct upload *pupload)
|
|||
pthread_mutex_unlock (&mutex_backup_session);
|
||||
}
|
||||
|
||||
void bkp_session_insert_du_state_change_complete(struct du_state_change_complete *pdu_state_change_complete) {
|
||||
char schedule_time[128];
|
||||
char resolved[8];
|
||||
char fault_code[8];
|
||||
mxml_node_t *b, *n, *t;
|
||||
int i;
|
||||
pthread_mutex_lock (&mutex_backup_session);
|
||||
sprintf(schedule_time,"%ld",pdu_state_change_complete->timeout);
|
||||
|
||||
b = bkp_session_insert(bkp_tree,"du_state_change_complete",NULL);
|
||||
bkp_session_insert(b,"command_key",pdu_state_change_complete->command_key);
|
||||
bkp_session_insert(b,"time",schedule_time);
|
||||
void bkp_session_insert_du_state_change_complete(struct du_state_change_complete *pdu_state_change_complete)
|
||||
{
|
||||
char schedule_time[128], resolved[8], fault_code[8];
|
||||
struct opresult *p;
|
||||
list_for_each_entry(p, &(pdu_state_change_complete->list_opresult), list) {
|
||||
n = bkp_session_insert(b,"opresult",NULL);
|
||||
sprintf(resolved,"%d",p->resolved);
|
||||
sprintf(fault_code,"%d",p->fault);
|
||||
bkp_session_insert(n,"uuid",p->uuid);
|
||||
bkp_session_insert(n,"du_ref",p->du_ref);
|
||||
bkp_session_insert(n,"version",p->version);
|
||||
bkp_session_insert(n,"current_state",p->current_state);
|
||||
bkp_session_insert(n,"resolved",resolved);
|
||||
bkp_session_insert(n,"execution_unit_ref",p->execution_unit_ref);
|
||||
bkp_session_insert(n,"start_time",p->start_time);
|
||||
bkp_session_insert(n,"complete_time",p->complete_time);
|
||||
bkp_session_insert(n,"fault",fault_code);
|
||||
mxml_node_t *b, *n;
|
||||
|
||||
pthread_mutex_lock (&mutex_backup_session);
|
||||
sprintf(schedule_time, "%ld", pdu_state_change_complete->timeout);
|
||||
b = bkp_session_insert(bkp_tree, "du_state_change_complete", NULL);
|
||||
bkp_session_insert(b, "command_key", pdu_state_change_complete->command_key);
|
||||
bkp_session_insert(b, "time", schedule_time);
|
||||
list_for_each_entry(p, &(pdu_state_change_complete->list_opresult), list) {
|
||||
n = bkp_session_insert(b, "opresult", NULL);
|
||||
sprintf(resolved, "%d", p->resolved);
|
||||
sprintf(fault_code, "%d", p->fault);
|
||||
bkp_session_insert(n, "uuid", p->uuid);
|
||||
bkp_session_insert(n, "du_ref", p->du_ref);
|
||||
bkp_session_insert(n, "version", p->version);
|
||||
bkp_session_insert(n, "current_state", p->current_state);
|
||||
bkp_session_insert(n, "resolved", resolved);
|
||||
bkp_session_insert(n, "execution_unit_ref", p->execution_unit_ref);
|
||||
bkp_session_insert(n, "start_time", p->start_time);
|
||||
bkp_session_insert(n, "complete_time", p->complete_time);
|
||||
bkp_session_insert(n, "fault", fault_code);
|
||||
}
|
||||
pthread_mutex_unlock (&mutex_backup_session);
|
||||
}
|
||||
|
||||
void bkp_session_delete_du_state_change_complete(struct du_state_change_complete *pdu_state_change_complete) {
|
||||
struct search_keywords keys[2];
|
||||
mxml_node_t *b;
|
||||
char schedule_time[128];
|
||||
void bkp_session_delete_du_state_change_complete(struct du_state_change_complete *pdu_state_change_complete)
|
||||
{
|
||||
struct search_keywords keys[2];
|
||||
mxml_node_t *b;
|
||||
char schedule_time[128];
|
||||
|
||||
pthread_mutex_lock (&mutex_backup_session);
|
||||
keys[0].name = "command_key";
|
||||
keys[0].value = pdu_state_change_complete->command_key;
|
||||
sprintf(schedule_time,"%ld",pdu_state_change_complete->timeout);
|
||||
|
||||
keys[1].name = "time";
|
||||
keys[1].value = schedule_time;
|
||||
b = bkp_session_node_found(bkp_tree, "du_state_change_complete", keys, 2);
|
||||
|
|
|
|||
89
external.c
89
external.c
|
|
@ -22,9 +22,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <libubox/uloop.h>
|
||||
|
||||
#include <json-c/json.h>
|
||||
|
||||
#include "external.h"
|
||||
|
|
@ -37,6 +35,7 @@
|
|||
#include <libbbfdm/dmbbf.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
|
||||
static int pid;
|
||||
static json_object *json_obj_in;
|
||||
static int pfds_in[2], pfds_out[2];
|
||||
|
|
@ -44,6 +43,8 @@ static FILE *fpipe;
|
|||
char *external_MethodFault = NULL;
|
||||
char *external_MethodName = NULL;
|
||||
char *external_MethodVersion = NULL;
|
||||
char *external_MethodUUID = NULL;
|
||||
char *external_MethodENV = NULL;
|
||||
|
||||
void external_downloadFaultResp (char *fault_code)
|
||||
{
|
||||
|
|
@ -81,17 +82,21 @@ void external_fetch_uninstallFaultResp (char **fault)
|
|||
external_MethodFault = NULL;
|
||||
}
|
||||
|
||||
void external_du_change_stateFaultResp (char *fault_code, char *version, char *name)
|
||||
void external_du_change_stateFaultResp (char *fault_code, char *version, char *name, char *uuid, char *env)
|
||||
{
|
||||
FREE(external_MethodFault);
|
||||
external_MethodFault = fault_code ? strdup(fault_code) : NULL;
|
||||
FREE(external_MethodVersion);
|
||||
external_MethodVersion = version ? strdup(version) : NULL;
|
||||
FREE(external_MethodName);
|
||||
external_MethodName = name ? strdup(name) : NULL;
|
||||
external_MethodName = name ? strdup(name) : NULL;
|
||||
FREE(external_MethodUUID);
|
||||
external_MethodUUID = uuid ? strdup(uuid) : NULL;
|
||||
FREE(external_MethodENV);
|
||||
external_MethodENV = env ? strdup(env) : NULL;
|
||||
}
|
||||
|
||||
void external_fetch_du_change_stateFaultResp (char **fault, char **version, char **name)
|
||||
void external_fetch_du_change_stateFaultResp(char **fault, char **version, char **name, char **uuid, char **env)
|
||||
{
|
||||
*fault = external_MethodFault;
|
||||
external_MethodFault = NULL;
|
||||
|
|
@ -99,6 +104,10 @@ void external_fetch_du_change_stateFaultResp (char **fault, char **version, char
|
|||
external_MethodVersion = NULL;
|
||||
*name = external_MethodName;
|
||||
external_MethodName = NULL;
|
||||
*uuid = external_MethodUUID;
|
||||
external_MethodUUID = NULL;
|
||||
*env = external_MethodENV;
|
||||
external_MethodENV = NULL;
|
||||
}
|
||||
static void external_read_pipe_input(int (*external_handler)(char *msg))
|
||||
{
|
||||
|
|
@ -299,26 +308,6 @@ int external_download(char *url, char *size, char *type, char *user, char *pass,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int external_change_du_state_download(char *url, char *user, char *pass)
|
||||
{
|
||||
DD(INFO,"executing DU download url '%s'", url);
|
||||
json_object *json_obj_out;
|
||||
|
||||
/* send data to the script */
|
||||
json_obj_out = json_object_new_object();
|
||||
|
||||
json_obj_out_add(json_obj_out, "command", "du_download");
|
||||
json_obj_out_add(json_obj_out, "url", url);
|
||||
if(user) json_obj_out_add(json_obj_out, "user", user);
|
||||
if(pass) json_obj_out_add(json_obj_out, "pass", pass);
|
||||
|
||||
external_write_pipe_output(json_object_to_json_string(json_obj_out));
|
||||
|
||||
json_object_put(json_obj_out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int external_upload(char *url, char *type, char *user, char *pass, char *name)
|
||||
{
|
||||
DD(INFO,"executing download url '%s'", url);
|
||||
|
|
@ -342,15 +331,61 @@ int external_upload(char *url, char *type, char *user, char *pass, char *name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int external_change_du_state_uninstall(char *package_name)
|
||||
int external_change_du_state_install(char *url, char *uuid, char *user, char *pass, char *env)
|
||||
{
|
||||
DD(INFO,"executing DU install");
|
||||
json_object *json_obj_out;
|
||||
|
||||
/* send data to the script */
|
||||
json_obj_out = json_object_new_object();
|
||||
|
||||
json_obj_out_add(json_obj_out, "command", "du_install");
|
||||
json_obj_out_add(json_obj_out, "url", url);
|
||||
if (uuid) json_obj_out_add(json_obj_out, "uuid", uuid);
|
||||
if (user) json_obj_out_add(json_obj_out, "user", user);
|
||||
if (pass) json_obj_out_add(json_obj_out, "pass", pass);
|
||||
if (env) json_obj_out_add(json_obj_out, "env", env);
|
||||
|
||||
external_write_pipe_output(json_object_to_json_string(json_obj_out));
|
||||
|
||||
json_object_put(json_obj_out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int external_change_du_state_update(char *uuid, char *url, char *version, char *user, char *pass)
|
||||
{
|
||||
DD(INFO,"executing DU update");
|
||||
json_object *json_obj_out;
|
||||
|
||||
/* send data to the script */
|
||||
json_obj_out = json_object_new_object();
|
||||
|
||||
json_obj_out_add(json_obj_out, "command", "du_update");
|
||||
json_obj_out_add(json_obj_out, "uuid", uuid);
|
||||
json_obj_out_add(json_obj_out, "url", url);
|
||||
if (version) json_obj_out_add(json_obj_out, "version", version);
|
||||
if (user) json_obj_out_add(json_obj_out, "user", user);
|
||||
if (pass) json_obj_out_add(json_obj_out, "pass", pass);
|
||||
|
||||
external_write_pipe_output(json_object_to_json_string(json_obj_out));
|
||||
|
||||
json_object_put(json_obj_out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int external_change_du_state_uninstall(char *name, char *env)
|
||||
{
|
||||
DD(INFO,"executing DU uninstall");
|
||||
json_object *json_obj_out;
|
||||
|
||||
/* send data to the script */
|
||||
json_obj_out = json_object_new_object();
|
||||
|
||||
json_obj_out_add(json_obj_out, "command", "du_uninstall");
|
||||
json_obj_out_add(json_obj_out, "package_name", package_name);
|
||||
json_obj_out_add(json_obj_out, "name", name);
|
||||
if(env) json_obj_out_add(json_obj_out, "env", env);
|
||||
|
||||
external_write_pipe_output(json_object_to_json_string(json_obj_out));
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ static char *fc_script = "./ext/openwrt/scripts/icwmp.sh";
|
|||
static char *fc_script = "/usr/sbin/icwmp";
|
||||
#endif
|
||||
|
||||
void external_du_change_stateFaultResp (char *fault_code, char *version, char *name);
|
||||
void external_du_change_stateFaultResp (char *fault_code, char *version, char *name, char *uuid, char *env);
|
||||
void external_downloadFaultResp (char *fault_code);
|
||||
void external_fetch_downloadFaultResp (char **fault_code);
|
||||
void external_uploadFaultResp (char *fault_code);
|
||||
|
|
@ -32,9 +32,10 @@ int external_simple(char *command, char *arg, int c);
|
|||
int external_download(char *url, char *size, char *type, char *user, char *pass,time_t c);
|
||||
int external_upload(char *url, char *type, char *user, char *pass, char *name);
|
||||
int external_apply(char *action, char *arg,time_t c);
|
||||
int external_change_du_state_uninstall(char *package_name);
|
||||
void external_fetch_du_change_stateFaultResp (char **fault, char **version, char **name);
|
||||
int external_change_du_state_download(char *url, char *user, char *pass);
|
||||
void external_fetch_du_change_stateFaultResp(char **fault, char **version, char **name, char **uuid, char **env);
|
||||
int external_change_du_state_install(char *url, char *uuid, char *user, char *pass, char *env);
|
||||
int external_change_du_state_update(char *uuid, char *url, char *version, char *user, char *pass);
|
||||
int external_change_du_state_uninstall(char *name, char *env);
|
||||
int external_handle_action(int (*external_handler)(char *msg));
|
||||
void external_add_list_paramameter(char *param_name, char *param_data, char *param_type, char *fault_code);
|
||||
void external_free_list_parameter();
|
||||
|
|
|
|||
|
|
@ -311,8 +311,6 @@ void *thread_cwmp_rpc_cpe_schedule_download (void *v);
|
|||
void *thread_cwmp_rpc_cpe_apply_schedule_download (void *v);
|
||||
void *thread_cwmp_rpc_cpe_change_du_state (void *v);
|
||||
|
||||
int cwmp_launch_change_du_state_download(struct operations *poperation, struct opresult **pchange_du_state_complete);
|
||||
int cwmp_launch_update_du_state_download(char *user, char *pass, char *url, struct opresult **pchange_du_state_complete);
|
||||
const char *whitespace_cb(mxml_node_t *node, int where);
|
||||
|
||||
int cwmp_root_cause_TransferComplete (struct cwmp *cwmp, struct transfer_complete *p);
|
||||
|
|
|
|||
10
jshn.c
10
jshn.c
|
|
@ -117,13 +117,17 @@ enum dustatechange_fault {
|
|||
DUState_Change_FAULT,
|
||||
DUState_Change_VERSION,
|
||||
DUState_Change_NAME,
|
||||
DUState_Change_UUID,
|
||||
DUState_Change_ENV,
|
||||
__DUSTATE_MAX
|
||||
};
|
||||
|
||||
char *dustatechange_fault_policy[] = {
|
||||
[DUState_Change_FAULT] = "fault_code",
|
||||
[DUState_Change_VERSION] = "package_version",
|
||||
[DUState_Change_NAME] = "package_name"
|
||||
[DUState_Change_NAME] = "package_name",
|
||||
[DUState_Change_UUID] = "package_uuid",
|
||||
[DUState_Change_ENV] = "package_env"
|
||||
};
|
||||
|
||||
int
|
||||
|
|
@ -137,9 +141,9 @@ cwmp_handle_dustate_changeFault(char *msg)
|
|||
if (!tb[DUState_Change_FAULT])
|
||||
goto error;
|
||||
|
||||
DD(INFO,"triggered handle dustate_change fault %s", tb[DUState_Change_FAULT], tb[DUState_Change_VERSION], tb[DUState_Change_NAME]);
|
||||
DD(INFO,"triggered handle dustate_change fault:%s version:%s name:%s", tb[DUState_Change_FAULT], tb[DUState_Change_VERSION], tb[DUState_Change_NAME], tb[DUState_Change_UUID], tb[DUState_Change_ENV]);
|
||||
|
||||
external_du_change_stateFaultResp (tb[DUState_Change_FAULT], tb[DUState_Change_VERSION], tb[DUState_Change_NAME]);
|
||||
external_du_change_stateFaultResp (tb[DUState_Change_FAULT], tb[DUState_Change_VERSION], tb[DUState_Change_NAME], tb[DUState_Change_UUID], tb[DUState_Change_ENV]);
|
||||
|
||||
jshn_message_delete();
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -4,43 +4,39 @@
|
|||
# Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||
# Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||
|
||||
icwmp_fault_output() {
|
||||
|
||||
icwmp_fault_output()
|
||||
{
|
||||
local MSG=""
|
||||
local fault_code="$2"
|
||||
if [ "$action" = "apply_du_download" ]
|
||||
then
|
||||
local package_name="$3"
|
||||
local package_version="$4"
|
||||
if ([ "$action" = "du_install" ] || [ "$action" = "du_update" ]);then
|
||||
local package_name="$3"
|
||||
local package_version="$4"
|
||||
local package_uuid="$5"
|
||||
local package_env="$6"
|
||||
fi
|
||||
case "$action" in
|
||||
*download)
|
||||
json_init
|
||||
json_add_string "fault_code" "$fault_code"
|
||||
if [ "$#" = "4" ]
|
||||
then
|
||||
json_add_string "package_name" "$package_name"
|
||||
json_add_string "package_version" "$package_version"
|
||||
fi
|
||||
json_close_object
|
||||
MSG=`json_dump`
|
||||
;;
|
||||
*upload)
|
||||
json_init
|
||||
json_add_string "fault_code" "$fault_code"
|
||||
if [ "$#" = "4" ]
|
||||
then
|
||||
json_add_string "package_name" "$package_name"
|
||||
json_add_string "package_version" "$package_version"
|
||||
fi
|
||||
json_close_object
|
||||
MSG=`json_dump`
|
||||
;;
|
||||
du_install|du_update)
|
||||
json_init
|
||||
json_add_string "fault_code" "$fault_code"
|
||||
if [ "$#" = "6" ];then
|
||||
json_add_string "package_name" "$package_name"
|
||||
json_add_string "package_version" "$package_version"
|
||||
json_add_string "package_uuid" "$package_uuid"
|
||||
json_add_string "package_env" "$package_env"
|
||||
fi
|
||||
json_close_object
|
||||
MSG=`json_dump`
|
||||
;;
|
||||
*download|*upload)
|
||||
json_init
|
||||
json_add_string "fault_code" "$fault_code"
|
||||
json_close_object
|
||||
MSG=`json_dump`
|
||||
;;
|
||||
esac
|
||||
echo "$MSG"
|
||||
}
|
||||
|
||||
|
||||
icwmp_check_image()
|
||||
{
|
||||
. /lib/functions.sh; include /lib/upgrade
|
||||
|
|
@ -111,38 +107,7 @@ icwmp_apply_web_content()
|
|||
rm /tmp/web_content.ipk 2> /dev/null
|
||||
let fault_code=$fault_code+$FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED
|
||||
icwmp_fault_output "" "$fault_code"
|
||||
else
|
||||
icwmp_fault_output "" "$FAULT_CPE_NO_FAULT"
|
||||
fi
|
||||
}
|
||||
|
||||
icwmp_install_package()
|
||||
{
|
||||
local fault_code="9000"
|
||||
|
||||
var=`/bin/opkg install /tmp/du_change_state.ipk`
|
||||
|
||||
if [ "$?" != "0" ];then
|
||||
rm /tmp/du_change_state.ipk 2> /dev/null
|
||||
let fault_code=$fault_code+$FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED
|
||||
icwmp_fault_output "" "$fault_code"
|
||||
else
|
||||
name="`expr "$var" : 'Installing \([^(]*\)'`"
|
||||
version="`expr "$var" : 'Installing [^(]*(\(.*\))'`"
|
||||
icwmp_fault_output "" "$FAULT_CPE_NO_FAULT" "$name" "$version"
|
||||
fi
|
||||
}
|
||||
|
||||
icwmp_update_package()
|
||||
{
|
||||
local fault_code="9000"
|
||||
|
||||
/bin/opkg install /tmp/du_change_state.ipk
|
||||
if [ "$?" != "0" ];then
|
||||
rm /tmp/du_change_state.ipk 2> /dev/null
|
||||
let fault_code=$fault_code+$FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED
|
||||
icwmp_fault_output "" "$fault_code"
|
||||
else
|
||||
else
|
||||
icwmp_fault_output "" "$FAULT_CPE_NO_FAULT"
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
132
scripts/icwmp.sh
132
scripts/icwmp.sh
|
|
@ -72,11 +72,26 @@ case "$1" in
|
|||
__arg5="$6"
|
||||
action="download"
|
||||
;;
|
||||
du_download)
|
||||
du_install)
|
||||
__arg1="$2"
|
||||
__arg2="$3"
|
||||
__arg3="$4"
|
||||
action="du_download"
|
||||
__arg4="$5"
|
||||
__arg5="$6"
|
||||
action="du_install"
|
||||
;;
|
||||
du_update)
|
||||
__arg1="$2"
|
||||
__arg2="$3"
|
||||
__arg3="$4"
|
||||
__arg4="$5"
|
||||
__arg5="$6"
|
||||
action="du_update"
|
||||
;;
|
||||
du_uninstall)
|
||||
__arg1="$2"
|
||||
__arg2="$3"
|
||||
action="du_uninstall"
|
||||
;;
|
||||
upload)
|
||||
__arg1="$2"
|
||||
|
|
@ -206,36 +221,73 @@ handle_action() {
|
|||
/usr/sbin/icwmpd -m 1 "inform"
|
||||
fi
|
||||
|
||||
if [ "$action" = "du_download" ]; then
|
||||
if [ "$action" = "du_install" ]; then
|
||||
local fault_code="9000"
|
||||
if [ "$__arg2" = "" -o "$__arg3" = "" ];then
|
||||
wget -O /tmp/icwmp_du_download "$__arg1" 2> /dev/null
|
||||
if [ "$?" != "0" ];then
|
||||
let fault_code=$fault_code+$FAULT_CPE_DOWNLOAD_FAILURE
|
||||
icwmp_fault_output "" "$fault_code"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
local url="http://$__arg2:$__arg3@`echo $__arg1|sed 's/http:\/\///g'`"
|
||||
wget -O /tmp/icwmp_du_download "$url" 2> /dev/null
|
||||
if [ "$?" != "0" ];then
|
||||
let fault_code=$fault_code+$FAULT_CPE_DOWNLOAD_FAILURE
|
||||
ubus_args=`echo {\"url\":\"$__arg1\",\"uuid\":\"$__arg2\",\"username\":\"$__arg3\",\"password\":\"$__arg4\",\"environment\":\"$__arg5\"}`
|
||||
output=`ubus -t 3 call softwaremanagement du_install $ubus_args`
|
||||
if [ "$output" != "" ];then
|
||||
json_init
|
||||
json_load "$output"
|
||||
json_get_var status status
|
||||
if [ "$status" == "0" ];then
|
||||
json_get_var error error
|
||||
if [ "$error" == "Download" ];then
|
||||
let fault_code=$fault_code+$FAULT_CPE_DOWNLOAD_FAILURE
|
||||
else
|
||||
let fault_code=$fault_code+$FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED
|
||||
fi
|
||||
icwmp_fault_output "" "$fault_code"
|
||||
return 1
|
||||
else
|
||||
json_get_var name name
|
||||
json_get_var uuid uuid
|
||||
json_get_var version version
|
||||
json_get_var environment environment
|
||||
icwmp_fault_output "" "$FAULT_CPE_NO_FAULT" "$name" "$version" "$uuid" "$environment"
|
||||
fi
|
||||
fi
|
||||
mv /tmp/icwmp_du_download /tmp/du_change_state.ipk 2> /dev/null
|
||||
icwmp_fault_output "" "$FAULT_CPE_NO_FAULT"
|
||||
fi
|
||||
|
||||
if [ "$action" = "du_update" ]; then
|
||||
local fault_code="9000"
|
||||
ubus_args=`echo {\"uuid\":\"$__arg1\",\"url\":\"$__arg2\",\"version\":\"$__arg3\",\"username\":\"$__arg4\",\"password\":\"$__arg5\"}`
|
||||
output=`ubus -t 3 call softwaremanagement du_update $ubus_args`
|
||||
if [ "$output" != "" ];then
|
||||
json_init
|
||||
json_load "$output"
|
||||
json_get_var status status
|
||||
if [ "$status" == "0" ];then
|
||||
let fault_code=$fault_code+$FAULT_CPE_DOWNLOAD_FAILURE
|
||||
icwmp_fault_output "" "$fault_code"
|
||||
return 1
|
||||
else
|
||||
json_get_var name name
|
||||
json_get_var uuid uuid
|
||||
json_get_var version version
|
||||
json_get_var environment environment
|
||||
icwmp_fault_output "" "$FAULT_CPE_NO_FAULT" "$name" "$version" "$uuid" "$environment"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$action" = "du_uninstall" ]; then
|
||||
/bin/opkg remove "$__arg1" 2> /dev/null
|
||||
if [ "$?" != "0" ];then
|
||||
let fault_code=$fault_code+$FAULT_CPE_DOWNLOAD_FAILURE
|
||||
icwmp_fault_output "" "$fault_code"
|
||||
return 1
|
||||
local fault_code="9000"
|
||||
ubus_args=`echo {\"name\":\"$__arg1\",\"environment\":\"$__arg2\"}`
|
||||
output=`ubus -t 3 call softwaremanagement du_uninstall $ubus_args`
|
||||
if [ "$output" != "" ];then
|
||||
json_init
|
||||
json_load "$output"
|
||||
json_get_var status status
|
||||
if [ "$status" == "0" ];then
|
||||
let fault_code=$fault_code+$FAULT_CPE_DOWNLOAD_FAILURE
|
||||
icwmp_fault_output "" "$fault_code"
|
||||
return 1
|
||||
else
|
||||
icwmp_fault_output "" "$FAULT_CPE_NO_FAULT"
|
||||
fi
|
||||
fi
|
||||
icwmp_fault_output "" "$FAULT_CPE_NO_FAULT"
|
||||
fi
|
||||
|
||||
if [ "$action" = "download" ]; then
|
||||
local fault_code="9000"
|
||||
if [ "$__arg4" = "" -o "$__arg5" = "" ];then
|
||||
|
|
@ -331,6 +383,7 @@ handle_action() {
|
|||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$action" = "upload" ]; then
|
||||
local fault_code="9000"
|
||||
local flname=""
|
||||
|
|
@ -419,6 +472,7 @@ handle_action() {
|
|||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ "$action" = "apply_download" ]; then
|
||||
case "$__arg1" in
|
||||
1) icwmp_apply_firmware ;;
|
||||
|
|
@ -440,12 +494,6 @@ handle_action() {
|
|||
esac
|
||||
fi
|
||||
|
||||
if [ "$action" = "apply_du_download" ]; then
|
||||
case "$__arg1" in
|
||||
install) icwmp_install_package ;;
|
||||
update) icwmp_update_package ;;
|
||||
esac
|
||||
fi
|
||||
if [ "$action" = "factory_reset" ]; then
|
||||
/sbin/defaultreset
|
||||
fi
|
||||
|
|
@ -530,11 +578,26 @@ handle_action() {
|
|||
json_get_var __arg7 cert_path
|
||||
action="download"
|
||||
;;
|
||||
du_download)
|
||||
du_install)
|
||||
json_get_var __arg1 url
|
||||
json_get_var __arg2 user
|
||||
json_get_var __arg3 pass
|
||||
action="du_download"
|
||||
json_get_var __arg2 uuid
|
||||
json_get_var __arg3 user
|
||||
json_get_var __arg4 pass
|
||||
json_get_var __arg5 env
|
||||
action="du_install"
|
||||
;;
|
||||
du_update)
|
||||
json_get_var __arg1 uuid
|
||||
json_get_var __arg2 url
|
||||
json_get_var __arg3 version
|
||||
json_get_var __arg4 user
|
||||
json_get_var __arg5 pass
|
||||
action="du_update"
|
||||
;;
|
||||
du_uninstall)
|
||||
json_get_var __arg1 name
|
||||
json_get_var __arg2 env
|
||||
action="du_uninstall"
|
||||
;;
|
||||
upload)
|
||||
json_get_var __arg1 url
|
||||
|
|
@ -563,9 +626,6 @@ handle_action() {
|
|||
json_get_var __arg1 arg
|
||||
json_get_var __arg2 ids
|
||||
action="apply_download"
|
||||
elif [ "$action" = "du_download" ]; then
|
||||
json_get_var __arg1 arg
|
||||
action="apply_du_download"
|
||||
else
|
||||
json_get_var __arg1 arg
|
||||
action="apply_value"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue