How to update a hostname script for VPS on Ubuntu 12.04?

I managed with about 30 easy steps to get Ubuntu 12.04 running on VPS instances which have old kernels and ‘do not’ support anything higher than 10.04.

Virtualmin runs very nicely on it, with many thanks again to Eric.

My problem now, however is when a reboot occurs, the VPS container rewrites the hostname to another setting. To get around this, I have used a script which works fine under 10.04 but which causes the issue of ‘missing LSB information’ under 12.04:

HOSTNAME=something.domain.com

[ -f /etc/hostname ] && echo $HOSTNAME > /etc/hostname

[ -f /etc/HOSTNAME ] && echo $HOSTNAME > /etc/HOSTNAME

[ -f /etc/sysconfig/network ] && sed -i.hebackup s/HOSTNAME=".*"/HOSTNAME="$HOSTNAME"/
/etc/sysconfig/network

/bin/hostname $HOSTNAME

[ -f /etc/my.resolv.conf ] && cp /etc/my.resolv.conf /etc/resolv.conf

[ -f /etc/my.hosts ] && cp /etc/my.hosts /etc/hosts

exit 0

after creating the script I run

‘chmod +x /etc/init.d/hostname_vps’

and then

‘update-rc.d hostname_vps defaults 09’

Then I get: warning: /etc/init.d/hostname_vps missing LSB information

I must be overlooking something, but there seems to be a very strict reading in the newest Debian.

Howdy,

LSB is a standard that describes the format for init scripts in /etc/init.d… you might have an easier time placing your script into /usr/local/sbin, and calling it from /etc/rc.local.

That said, if you were interested in making it work as an init script, there’s details on doing that here:

http://wiki.debian.org/LSBInitScripts/