@@ -160,28 +160,25 @@ int _sys_hwinfo(int com_id, const nlohmann::json &json_obj)
160160 std::vector<ifconfig_t > ifcs;
161161 ifconfig (ifcs);
162162 std::vector<nlohmann::json> jifcs;
163- for (auto & item : ifcs)
164- {
163+ for (auto &item : ifcs) {
165164 nlohmann::json eth_info;
166- eth_info[" name" ] = item.name ;
167- eth_info[" ip" ] = item.ip ;
165+ eth_info[" name" ] = item.name ;
166+ eth_info[" ip" ] = item.ip ;
168167 char eth_ip_buff[128 ] = {0 };
169168 sprintf (eth_ip_buff, " /sys/class/net/%s/speed" , item.name );
170169 FILE *file = fopen (eth_ip_buff, " r" );
171170 memset (eth_ip_buff, 0 , sizeof (eth_ip_buff));
172- if (file != NULL )
173- {
171+ if (file != NULL ) {
174172 int size = fread (eth_ip_buff, 1 , sizeof (eth_ip_buff), file);
175- if (size > 0 )
176- eth_ip_buff[size-1 ] = ' \0 ' ;
173+ if (size > 0 ) eth_ip_buff[size - 1 ] = ' \0 ' ;
177174 fclose (file);
178175 }
179176 eth_info[" speed" ] = eth_ip_buff;
180177 jifcs.push_back (eth_info);
181178 }
182179 data_body[" eth_info" ] = jifcs;
183- out_body[" data" ] = data_body;
184- std::string out = out_body.dump ();
180+ out_body[" data" ] = data_body;
181+ std::string out = out_body.dump ();
185182 zmq_com_send (com_id, out);
186183 return 0 ;
187184}
@@ -254,6 +251,15 @@ int sys_lsmode(int com_id, const nlohmann::json &json_obj)
254251 return out;
255252}
256253
254+ int sys_rmmode (int com_id, const nlohmann::json &json_obj)
255+ {
256+ std::string rmmode_name = json_obj[" data" ];
257+ const std::string command = " dpkg -P llm-" + rmmode_name;
258+ int out = system (command.c_str ());
259+ usr_print_error (json_obj[" request_id" ], json_obj[" work_id" ], " {\" code\" :0, \" message\" :\"\" }" , com_id);
260+ return out;
261+ }
262+
257263int sys_lstask (int com_id, const nlohmann::json &json_obj)
258264{
259265 int out;
@@ -349,6 +355,7 @@ int sys_update(int com_id, const nlohmann::json &json_obj)
349355 " {\" code\" :-10, \" message\" :\" Not available at the moment.\" }" , com_id);
350356 return out;
351357}
358+
352359int sys_upgrade (int com_id, const nlohmann::json &json_obj)
353360{
354361 int out;
@@ -521,6 +528,7 @@ void server_work()
521528 key_sql[" sys.reset" ] = sys_reset;
522529 key_sql[" sys.reboot" ] = sys_reboot;
523530 key_sql[" sys.version" ] = sys_version;
531+ key_sql[" sys.rmmode" ] = sys_rmmode;
524532}
525533
526534void server_stop_work ()
@@ -554,8 +562,7 @@ void unit_action_match(int com_id, const std::string &json_str)
554562 usr_print_error (" 0" , " sys" , " {\" code\" :-2, \" message\" :\" json format error\" }" , com_id);
555563 return ;
556564 }
557- if (work_id.empty ())
558- work_id = " sys" ;
565+ if (work_id.empty ()) work_id = " sys" ;
559566 std::string action;
560567 error = doc[" action" ].get_string (action);
561568 if (error) {
0 commit comments