added default image for all clients (known and unkown)
This commit is contained in:
parent
df17c93e76
commit
91811347d8
11
README.md
11
README.md
@ -29,6 +29,17 @@ db hosts setprop lab01 \
|
|||||||
|
|
||||||
By running the above command, the **memtest** image will be used for one boot only.
|
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 ##
|
## TODO / ideas ##
|
||||||
|
|
||||||
* Create a menu, for interactive selection
|
* Create a menu, for interactive selection
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Summary: LibreSchool PXE server
|
Summary: LibreSchool PXE server
|
||||||
Name: libreschool-pxeserver
|
Name: libreschool-pxeserver
|
||||||
Version: 1.1.3
|
Version: 1.1.4
|
||||||
Release: 1.ns7
|
Release: 1.ns7
|
||||||
License: GPL
|
License: GPL
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
@ -112,6 +112,9 @@ if [ "$1" = 0 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
%changelog
|
%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
|
* Sat Apr 25 2020 Paolo Asperti <paolo@asperti.com> - 1.1.3-1.ns7
|
||||||
- Added KUbuntu 20.04 (live only)
|
- Added KUbuntu 20.04 (live only)
|
||||||
- Added LUbuntu 20.04 (live only)
|
- Added LUbuntu 20.04 (live only)
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
localhd
|
@ -21,6 +21,7 @@
|
|||||||
require_once "EsmithDatabase.php";
|
require_once "EsmithDatabase.php";
|
||||||
|
|
||||||
$hosts_db = new EsmithDatabase('hosts');
|
$hosts_db = new EsmithDatabase('hosts');
|
||||||
|
$config_db = new EsmithDatabase('configuration');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if specified mac address is valid
|
* Check if specified mac address is valid
|
||||||
@ -100,6 +101,26 @@ function imageExists($i) {
|
|||||||
return is_dir($dir) && is_readable($bootfile) && $iso_ok;
|
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'])) {
|
if (!isset($_REQUEST['mac'])) {
|
||||||
defaultExit();
|
defaultExit();
|
||||||
}
|
}
|
||||||
@ -112,7 +133,7 @@ if (!isValidMAC($_REQUEST['mac'])) {
|
|||||||
$mac = $_REQUEST['mac'];
|
$mac = $_REQUEST['mac'];
|
||||||
$client = getClientFromMAC($mac);
|
$client = getClientFromMAC($mac);
|
||||||
if (!$client) {
|
if (!$client) {
|
||||||
// TODO: make up a default for unknown clients
|
try_defaultimage();
|
||||||
defaultExit();
|
defaultExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user