From a7727e40eaf30393b3fde4e2bd0a7224b0ba8f83 Mon Sep 17 00:00:00 2001 From: OpenGnSys Support Team Date: Wed, 20 Dec 2023 13:33:23 +0100 Subject: rest: allow to set boot mode in client/update Allow to specify .boot field and call set_client_mode() to update the boot mode. --- src/rest.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/rest.c b/src/rest.c index 658a398..8bde175 100644 --- a/src/rest.c +++ b/src/rest.c @@ -1777,6 +1777,10 @@ static int og_cmd_post_client_update(json_t *element, err = og_json_parse_string_copy(value, computer.name, sizeof(computer.name)); + } else if (!strcmp(key, "boot")) { + err = og_json_parse_string_copy(value, + computer.boot, + sizeof(computer.boot)); } else if (!strcmp(key, "mac")) { err = og_json_parse_string_copy(value, computer.mac, @@ -1824,14 +1828,16 @@ static int og_cmd_post_client_update(json_t *element, " inremotepc=%u," " idaula=%u," " nombreordenador='%s'," - " mac='%s'" + " mac='%s'," + " arranque='%s'" " WHERE ip='%s';", computer.serial_number, computer.netdriver, computer.maintenance, computer.netiface, computer.repo_id, computer.netmask, computer.remote, computer.room, computer.name, - computer.mac, computer.ip); + computer.mac, computer.boot, + computer.ip); if (!result) { dbi_conn_error(dbi->conn, &msglog); syslog(LOG_ERR, "failed to update client in database (%s:%d) %s\n", @@ -1841,6 +1847,14 @@ static int og_cmd_post_client_update(json_t *element, } dbi_result_free(result); + + if (og_set_client_mode(dbi, computer.mac, computer.boot)) { + syslog(LOG_ERR, "failed to set client boot mode (%s:%d)\n", + __func__, __LINE__); + og_dbi_close(dbi); + return -1; + } + og_dbi_close(dbi); return 0; } -- cgit v1.2.3-18-g5258