diff options
Diffstat (limited to 'modules-available/rebootcontrol/install.inc.php')
-rw-r--r-- | modules-available/rebootcontrol/install.inc.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/modules-available/rebootcontrol/install.inc.php b/modules-available/rebootcontrol/install.inc.php index 0aedfa20..d45a2443 100644 --- a/modules-available/rebootcontrol/install.inc.php +++ b/modules-available/rebootcontrol/install.inc.php @@ -37,6 +37,13 @@ $output[] = tableCreate('reboot_subnet_x_subnet', " PRIMARY KEY (`srcid`, `dstid`), KEY `nextcheck` (`nextcheck`)"); +$output[] = tableCreate('reboot_scheduler', " + `locationid` INT(11) NOT NULL, + `action` ENUM('WOL', 'SHUTDOWN', 'REBOOT'), + `nextexecution` INT(10) UNSIGNED NOT NULL DEFAULT 0, + `options` BLOB, + PRIMARY KEY (`locationid`)"); + $output[] = tableAddConstraint('reboot_jumphost_x_subnet', 'hostid', 'reboot_jumphost', 'hostid', 'ON UPDATE CASCADE ON DELETE CASCADE'); $output[] = tableAddConstraint('reboot_jumphost_x_subnet', 'subnetid', 'reboot_subnet', 'subnetid', @@ -45,5 +52,26 @@ $output[] = tableAddConstraint('reboot_subnet_x_subnet', 'srcid', 'reboot_subnet 'ON UPDATE CASCADE ON DELETE CASCADE'); $output[] = tableAddConstraint('reboot_subnet_x_subnet', 'dstid', 'reboot_subnet', 'subnetid', 'ON UPDATE CASCADE ON DELETE CASCADE'); +$output[] = tableAddConstraint('reboot_scheduler', 'locationid', 'location', 'locationid', + 'ON UPDATE CASCADE ON DELETE CASCADE'); + +if (tableColumnKeyType('reboot_scheduler', 'action') === 'PRI') { + Database::exec("DELETE FROM reboot_scheduler WHERE action <> 'wol'"); + $res = Database::exec("ALTER TABLE `reboot_scheduler` DROP PRIMARY KEY, ADD PRIMARY KEY (`locationid`)"); + $output[] = $res !== false ? UPDATE_DONE : UPDATE_FAILED; +} +if (strpos(tableColumnType('reboot_scheduler', 'action'), 'REBOOT') === false) { + // Fiddle with column to rename ENUM values + $res = Database::exec("ALTER TABLE `reboot_scheduler` MODIFY COLUMN `action` ENUM('sd', 'rb', 'WOL', 'SHUTDOWN', 'REBOOT')"); + handleUpdateResult($res); + $res = Database::exec("UPDATE reboot_scheduler SET action = + CASE WHEN action = 'sd' THEN 'SHUTDOWN' WHEN action = 'rb' THEN 'REBOOT' ELSE 'WOL' END"); + handleUpdateResult($res); + $res = Database::exec("ALTER TABLE `reboot_scheduler` MODIFY COLUMN `action` ENUM('WOL', 'SHUTDOWN', 'REBOOT')"); + handleUpdateResult($res); + $output[] = UPDATE_DONE; +} + + responseFromArray($output);
\ No newline at end of file |