added default image for all clients (known and unkown)
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

This commit is contained in:
Paolo Asperti 2020-04-28 22:39:45 +02:00
parent df17c93e76
commit 91811347d8
Signed by: paspo
GPG Key ID: 06D46905D19D5182
4 changed files with 55 additions and 19 deletions

View File

@ -29,6 +29,17 @@ db hosts setprop lab01 \
By running the above command, the **memtest** image will be used for one boot only.
## default image ##
When there's no specific setting for the host, the host is not in the hosts db, or the image specified for the host is not available, the *default image* is used.
To set the default image, you can use this command:
```bash
db configuration setprop pxeserver-httpd \
defaultimage memtest
```
## TODO / ideas ##
* Create a menu, for interactive selection

View File

@ -1,6 +1,6 @@
Summary: LibreSchool PXE server
Name: libreschool-pxeserver
Version: 1.1.3
Version: 1.1.4
Release: 1.ns7
License: GPL
BuildArch: noarch
@ -112,6 +112,9 @@ if [ "$1" = 0 ]; then
fi
%changelog
* Tue Apr 28 2020 Paolo Asperti <paolo@asperti.com> - 1.1.4-1.ns7
- Added default image setting
* Sat Apr 25 2020 Paolo Asperti <paolo@asperti.com> - 1.1.3-1.ns7
- Added KUbuntu 20.04 (live only)
- Added LUbuntu 20.04 (live only)

View File

@ -0,0 +1 @@
localhd

View File

@ -21,6 +21,7 @@
require_once "EsmithDatabase.php";
$hosts_db = new EsmithDatabase('hosts');
$config_db = new EsmithDatabase('configuration');
/**
* Check if specified mac address is valid
@ -100,6 +101,26 @@ function imageExists($i) {
return is_dir($dir) && is_readable($bootfile) && $iso_ok;
}
/**
* Try to boot the default PXE Image
*
* @return void
*/
function try_defaultimage() {
global $config_db;
$defaultimage = $config_db->getProp('pxeserver-httpd','defaultimage');
if (imageExists($defaultimage)) {
print("#!ipxe
# Loading PXEImage
chain " . $defaultimage . "/boot
");
exit();
}
}
if (!isset($_REQUEST['mac'])) {
defaultExit();
}
@ -112,7 +133,7 @@ if (!isValidMAC($_REQUEST['mac'])) {
$mac = $_REQUEST['mac'];
$client = getClientFromMAC($mac);
if (!$client) {
// TODO: make up a default for unknown clients
try_defaultimage();
defaultExit();
}