summaryrefslogtreecommitdiffstats
path: root/modules-available/rebootcontrol/hooks/config-tgz.inc.php
blob: 0b706960afedc522e546ba1acc2972ac7676b8b5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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;
}