diff options
Diffstat (limited to 'modules-available/rebootcontrol/hooks/config-tgz.inc.php')
-rw-r--r-- | modules-available/rebootcontrol/hooks/config-tgz.inc.php | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/modules-available/rebootcontrol/hooks/config-tgz.inc.php b/modules-available/rebootcontrol/hooks/config-tgz.inc.php new file mode 100644 index 00000000..0b706960 --- /dev/null +++ b/modules-available/rebootcontrol/hooks/config-tgz.inc.php @@ -0,0 +1,18 @@ +<?php + +$pubkey = SSHKey::getPublicKey(); +$tmpfile = '/tmp/bwlp-' . md5($pubkey) . '.tar'; +if (!is_file($tmpfile) || !is_readable($tmpfile) || filemtime($tmpfile) + 86400 < time()) { + if (file_exists($tmpfile)) { + unlink($tmpfile); + } + try { + $a = new PharData($tmpfile); + $a->addFromString("/root/.ssh/authorized_keys.d/rebootcontrol", $pubkey); + $file = $tmpfile; + } catch (Exception $e) { + EventLog::failure('Could not include ssh key for reboot-control in config.tgz', (string)$e); + } +} elseif (is_file($tmpfile) && is_readable($tmpfile)) { + $file = $tmpfile; +} |