Modifying the init image to truncate hostname to 15 characters

FOG Version: 0.32
OS Version: Ubuntu 10.04 LTS Server i386

I have the problem of naming hosts after users. Usually it’s LastnameFirstname, and sometimes this goes over the 15 character limit allowed by FOG. The database limits the host name to 16 characters, but the registration script only allows 15 characters (see function isSafeHostName() in /var/www/fog/commons/functions.include.php).

Normally if you do a full registration via PXE and you put in a host name longer than 15 characters, the hostname gets switched to the MAC address of the host (without the “:”).

The webUI lets you use 16 characters, which matches the database field length.

save the file and exit. Do the steps in the wiki to exit the init environment and gzip it back.

Now if you are doing a full registration and inventory, you no longer have to count the hostname to make sure it doesn’t go over 15 characters. It will truncate it and alert you to the new truncated name, and proceed with the next steps.

Note: If you reinstall or upgrade FOG, your customizations to init.gz may be lost. Always backup init.gz before doing FOG updates other than kernel swaps.