diff options
author | Simon Rettberg | 2019-09-24 15:25:32 +0200 |
---|---|---|
committer | Simon Rettberg | 2019-09-24 15:25:32 +0200 |
commit | d10a3a96e0538b8347472d6c2d350dc2bee86501 (patch) | |
tree | 397f62279eaea44be606421396d00ae1bb1b1c0f /modules-available/serversetup-bwlp-ipxe/install.inc.php | |
parent | [dnbd3] fix math (diff) | |
download | slx-admin-d10a3a96e0538b8347472d6c2d350dc2bee86501.tar.gz slx-admin-d10a3a96e0538b8347472d6c2d350dc2bee86501.tar.xz slx-admin-d10a3a96e0538b8347472d6c2d350dc2bee86501.zip |
[serversetup-bwlp-ipxe]
Diffstat (limited to 'modules-available/serversetup-bwlp-ipxe/install.inc.php')
-rw-r--r-- | modules-available/serversetup-bwlp-ipxe/install.inc.php | 78 |
1 files changed, 49 insertions, 29 deletions
diff --git a/modules-available/serversetup-bwlp-ipxe/install.inc.php b/modules-available/serversetup-bwlp-ipxe/install.inc.php index 35eeee37..37cfc085 100644 --- a/modules-available/serversetup-bwlp-ipxe/install.inc.php +++ b/modules-available/serversetup-bwlp-ipxe/install.inc.php @@ -1,17 +1,18 @@ <?php -$res = array(); +$result = array(); -$res[] = tableCreate('serversetup_bootentry', " +$result[] = tableCreate('serversetup_bootentry', " `entryid` varchar(16) CHARACTER SET ascii NOT NULL, `hotkey` varchar(8) CHARACTER SET ascii NOT NULL, `title` varchar(100) NOT NULL, `builtin` tinyint(1) NOT NULL, + `module` varchar(30) DEFAULT NULL, `data` blob NOT NULL, PRIMARY KEY (`entryid`) "); -$res[] = tableCreate('serversetup_menu', " +$result[] = tableCreate('serversetup_menu', " `menuid` int(11) NOT NULL AUTO_INCREMENT, `timeoutms` int(10) unsigned NOT NULL, `title` varchar(100) NOT NULL COMMENT 'Escaped/Sanitized for iPXE!', @@ -22,7 +23,7 @@ $res[] = tableCreate('serversetup_menu', " KEY `isdefault` (`isdefault`) "); -$res[] = tableCreate('serversetup_menuentry', " +$result[] = tableCreate('serversetup_menuentry', " `menuentryid` int(11) NOT NULL AUTO_INCREMENT, `menuid` int(11) NOT NULL, `entryid` varchar(16) CHARACTER SET ascii NULL COMMENT 'If NULL, entry is gap or another menu', @@ -38,7 +39,7 @@ $res[] = tableCreate('serversetup_menuentry', " KEY `entryid` (`entryid`) "); -$res[] = tableCreate('serversetup_menu_location', ' +$result[] = tableCreate('serversetup_menu_location', ' `menuid` int(11) NOT NULL, `locationid` int(11) NOT NULL, `defaultentryid` int(11) DEFAULT NULL, @@ -47,7 +48,7 @@ $res[] = tableCreate('serversetup_menu_location', ' KEY `defaultentryid` (`defaultentryid`) '); -$res[] = tableCreate('serversetup_localboot', " +$result[] = tableCreate('serversetup_localboot', " `systemmodel` varchar(120) NOT NULL, `pcbios` varchar(16) CHARACTER SET ascii DEFAULT NULL, `efi` varchar(16) CHARACTER SET ascii DEFAULT NULL, @@ -58,60 +59,79 @@ $res[] = tableCreate('serversetup_localboot', " if (!tableHasColumn('serversetup_menu_location', 'defaultentryid')) { if (Database::exec('ALTER TABLE serversetup_menu_location ADD COLUMN `defaultentryid` int(11) DEFAULT NULL, ADD KEY `defaultentryid` (`defaultentryid`)') !== false) { - $res[] = UPDATE_DONE; + $result[] = UPDATE_DONE; } else { - $res[] = UPDATE_FAILED; + $result[] = UPDATE_FAILED; } } -$res[] = tableAddConstraint('serversetup_menu', 'defaultentryid', 'serversetup_menuentry', 'menuentryid', +$result[] = tableAddConstraint('serversetup_menu', 'defaultentryid', 'serversetup_menuentry', 'menuentryid', 'ON DELETE SET NULL'); -$res[] = tableAddConstraint('serversetup_menuentry', 'entryid', 'serversetup_bootentry', 'entryid', +$result[] = tableAddConstraint('serversetup_menuentry', 'entryid', 'serversetup_bootentry', 'entryid', 'ON UPDATE CASCADE ON DELETE CASCADE'); -$res[] = tableAddConstraint('serversetup_menuentry', 'menuid', 'serversetup_menu', 'menuid', +$result[] = tableAddConstraint('serversetup_menuentry', 'menuid', 'serversetup_menu', 'menuid', 'ON UPDATE CASCADE ON DELETE CASCADE'); -$res[] = tableAddConstraint('serversetup_menu_location', 'menuid', 'serversetup_menu', 'menuid', +$result[] = tableAddConstraint('serversetup_menu_location', 'menuid', 'serversetup_menu', 'menuid', 'ON UPDATE CASCADE ON DELETE CASCADE'); -$res[] = tableAddConstraint('serversetup_menu_location', 'defaultentryid', 'serversetup_menuentry', 'menuentryid', +$result[] = tableAddConstraint('serversetup_menu_location', 'defaultentryid', 'serversetup_menuentry', 'menuentryid', 'ON UPDATE CASCADE ON DELETE SET NULL'); // 2019-03-19 Add refmenuid to have cascaded menus if (!tableHasColumn('serversetup_menuentry', 'refmenuid')) { - if (Database::exec("ALTER TABLE serversetup_menuentry ADD COLUMN `refmenuid` int(11) DEFAULT NULL COMMENT 'If entryid is NULL this can be a ref to another menu'") !== false) { - $res[] = UPDATE_DONE; - } else { - $res[] = UPDATE_FAILED; - } + if (Database::exec("ALTER TABLE serversetup_menuentry ADD COLUMN `refmenuid` int(11) DEFAULT NULL COMMENT 'If entryid is NULL this can be a ref to another menu'") !== false) { + $result[] = UPDATE_DONE; + } else { + $result[] = UPDATE_FAILED; + } } // 2019-03-26 Make localboot config distinct for efi and bios if (!tableHasColumn('serversetup_localboot', 'pcbios')) { - if (Database::exec("ALTER TABLE serversetup_localboot DROP COLUMN `bootmethod`, - ADD COLUMN `pcbios` varchar(16) CHARACTER SET ascii DEFAULT NULL, ADD COLUMN `efi` varchar(16) CHARACTER SET ascii DEFAULT NULL") !== false) { - $res[] = UPDATE_DONE; - } else { - $res[] = UPDATE_FAILED; - } + if (Database::exec("ALTER TABLE serversetup_localboot DROP COLUMN `bootmethod`, + ADD COLUMN `pcbios` varchar(16) CHARACTER SET ascii DEFAULT NULL, ADD COLUMN `efi` varchar(16) CHARACTER SET ascii DEFAULT NULL") !== false) { + $result[] = UPDATE_DONE; + } else { + $result[] = UPDATE_FAILED; + } } -$res[] = tableAddConstraint('serversetup_menuentry', 'refmenuid', 'serversetup_menu', 'menuid', - 'ON UPDATE CASCADE ON DELETE SET NULL'); +$result[] = tableAddConstraint('serversetup_menuentry', 'refmenuid', 'serversetup_menu', 'menuid', + 'ON UPDATE CASCADE ON DELETE SET NULL'); if (Module::get('location') !== false) { if (!tableExists('location')) { - $res[] = UPDATE_RETRY; + $result[] = UPDATE_RETRY; } else { - $res[] = tableAddConstraint('serversetup_menu_location', 'locationid', 'location', 'locationid', + $result[] = tableAddConstraint('serversetup_menu_location', 'locationid', 'location', 'locationid', 'ON UPDATE CASCADE ON DELETE CASCADE'); } } +// 2019-09-21 Add modue column to bootentry +if (!tableHasColumn('serversetup_bootentry', 'module')) { + if (Database::exec("ALTER TABLE serversetup_bootentry + ADD COLUMN `module` varchar(30) CHARACTER SET ascii DEFAULT NULL AFTER `builtin`") !== false) { + $result[] = UPDATE_DONE; + $res = Database::simpleQuery('SELECT entryid, data FROM serversetup_bootentry WHERE module IS NULL'); + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + $json = json_decode($row['data'], true); + if (isset($json['script'])) { + Database::exec("UPDATE serversetup_bootentry SET module = '.script' WHERE entryid = :id", ['id' => $row['entryid']]); + } else { + Database::exec("UPDATE serversetup_bootentry SET module = '.exec' WHERE entryid = :id", ['id' => $row['entryid']]); + } + } + } else { + $result[] = UPDATE_FAILED; + } +} + if (Module::isAvailable('serversetup')) { IPxe::createDefaultEntries(); } -responseFromArray($res); +responseFromArray($result); |