diff options
author | Jose M. Guisado <jguisado@soleta.eu> | 2020-12-18 11:55:26 +0000 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2021-01-13 09:58:22 +0100 |
commit | 85d092864cddb8390c13915ead3b24b48d2b2306 (patch) | |
tree | 542dc24df029c5503a7859215dcaa33519632af2 /src/rest.c | |
parent | 1472ff276f73311e7122391b2623f11ab2828395 (diff) |
#802 add uefi folder for post_modes pxe template lookup
When executing og_cmd_post_modes ogServer is looking up for the template
related to the mode coming as a parameter. This lookup is only done for
the bios boot mode. (ie. /opt/opengnsys/tftpboot/menu.lst/templates/)
Templates can be created for a given boot mode, for example you can
create a UEFI-only template (it.
/opt/opengnsys/tftpboot/grub/templates).
When a UEFI only template was coming as a parameter to og_cmd_post_modes
the file can't be located because the UEFI template folder is never
tested.
Add UEFI folder to the lookup of pxe templates, try this folder if bios
mode fails.
PS: Later on a bash script "setclientmode" is to be executed, which will
take its own way of updating these pxe files (ie. templates/../), this
script updates every boot mode if an available template is found.
Diffstat (limited to 'src/rest.c')
-rw-r--r-- | src/rest.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -865,6 +865,7 @@ static int og_cmd_reboot(json_t *element, struct og_msg_params *params) return og_send_request(OG_METHOD_POST, OG_CMD_REBOOT, params, NULL); } +#define OG_TFTP_TMPL_PATH_UEFI "/opt/opengnsys/tftpboot/grub/templates" #define OG_TFTP_TMPL_PATH "/opt/opengnsys/tftpboot/menu.lst/templates" static int og_cmd_get_modes(json_t *element, struct og_msg_params *params, @@ -1016,6 +1017,7 @@ static int og_set_client_mode(struct og_dbi *dbi, const char *mac, static int og_cmd_post_modes(json_t *element, struct og_msg_params *params) { char ips_str[(OG_DB_IP_MAXLEN + 1) * OG_CLIENTS_MAX + 1] = {}; + char template_file_uefi[PATH_MAX + 1] = {}; char template_file[PATH_MAX + 1] = {}; char template_name[PATH_MAX + 1] = {}; char first_line[PATH_MAX + 1] = {}; @@ -1052,9 +1054,17 @@ static int og_cmd_post_modes(json_t *element, struct og_msg_params *params) OG_TFTP_TMPL_PATH, mode_str); f = fopen(template_file, "r"); if (!f) { - syslog(LOG_ERR, "cannot open file (%s:%d)\n", - __func__, __LINE__); - return -1; + syslog(LOG_WARNING, "cannot open file %s (%s:%d). Trying UEFI template instead.\n", + template_file, __func__, __LINE__); + + snprintf(template_file_uefi, sizeof(template_file_uefi), "%s/%s", + OG_TFTP_TMPL_PATH_UEFI, mode_str); + f = fopen(template_file_uefi, "r"); + if (!f) { + syslog(LOG_ERR, "cannot open file %s (%s:%d). No template found.\n", + template_file_uefi, __func__, __LINE__); + return -1; + } } if (!fgets(first_line, sizeof(first_line), f)) { |