Linux Install/MBRHostname
From FSI
|
Automatic hostname from zenworks MBR
- Save the following script into /root/heivs_hostname.sh:
#!/bin/bash TMP=`dd if=/dev/sda bs=512 count=1 skip=5 2> /dev/null | iconv -f utf16 -t ascii -c` HOSTNAME_HD=`dd if=/dev/sda bs=512 count=1 skip=5 2> /dev/null | iconv -f utf16 -t ascii -c | sed ';s/.*CN=//g' | sed 's/\.[^\.]*//g'` if [ ! "$TMP" == *CN=* ] then HOSTNAME_HD= fi echo HOSTNAME_HD=\'$HOSTNAME_HD\' if [ -n "$HOSTNAME_HD" ] then echo hostname found in MBR echo $HOSTNAME_HD.hevs.ch > /etc/hostname else echo hostname not found in MBR fi hostname -b -F /etc/hostname
- Then modify the /etc/init/hostname.conf file as follow:
# # This task is run on startup to set the system hostname from /etc/hostname, # falling back to "localhost" if that file is not readable or is empty and # no hostname has yet been set. description "set system hostname" start on startup task #exec hostname -b -F /etc/hostname exec /root/heivs_hostname.sh