WOL patch for FOG 0.29
Overview:
Patches for FOG 0.29 to allow broadcast of WOL packets across subnets.
The IP and netmask is now captured during manual or auto host registration via the PXE menu options.
The appropriate subnet is calculated from the IP and netmask of the host and used in the WOL packet.
Brief description of file changes:
fog.auto.reg
Current IP address and netmask are now captured, these are sent to the server. If the host already exists, these values are updated on the server.
fog.man.reg
Now asks for the IP address and netmask. Current values used if return pressed. These are sent to the FOG server. If the host already exists, these values are updated on the server.
auto.register.php
Converts the captured IP address and netmask into CIDR format and saves them in the IP field. Updates fields if host already exists.
functions.include.php
Functions added to convert netmask to CIDR format, and to calculate the broadcast address from the IP and netmask.
Createhost function altered to save netmask value
WakeonLan function altered to include appropriate broadcast address as a parameter
WakeOnLan.class.php
Updated to read the broadcast address from the parameter list
wol.php
Updated to use the supplied broadcast address in the WOL packet rather than 255.255.255.255
Location of files:
Two of the files are within the init.gz file:
{init.gz}/bin/fog.auto.reg
{init.gz}/bin/fog.man.reg
You'll need to unzip and mount your init.gz file to access these two files.
There are details on the wiki on how to do this, but in brief:
(you'll need root access)
cp /tftpboot/fog/images/init.gz .
gunzip init.gz
mkdir initrdtemp
mount -o loop init initrdtemp/
{files can now be accessed via ./initrdtemp/path-to-files}
when done (ensure you are not within the initrdtemp dir):
umount initrdtemp
gzip init
cp init /tftpboot/fog/images/
I'll leave it to you to make a backup of the original file first.
php files:
{fogwwwdir} signifies the base path to your fog www files
For Ubuntu, this is /var/www/fog/ but this will probably vary depending on your distribution:
{fogwwwdir}/service/auto.register.php
{fogwwwdir}/commons/functions.include.php
{fogwwwdir}/lib/fog/WakeOnLan.class.php
{fogwwwdir}/wol/wol.php
The Patches
Patch files attached. These were created by:
diff -Naurw original_file updated_file > file_patch.diff
You should be able to apply these to your originals by:
patch original_file file_patch.diff
Patches to allow WOL over subnets
With the many changes of code base in 1.x.x, this patch will unlikely do anything properly. However, it was never, nor should it have been, needed to WOL across subnets. Subnet branching WOL requests should be managed by the switch and enabled to pass the information from where to where. While this patch worked, I'm sure, if the switch didn't allow the passing of the files, chances are likely it wouldn't have worked anyway.
Those interested in using this can still find and use it, just understand they'll likely need to figure out the new locations and where to implement these changes.