VPS boot overrides some configuration files

Problem: I bought a new VPS and did some configuration changes (e.g. hostname setting). I’ve installed some software and wanted to test if my settings are boot resistant. And every time the VPS was  booting the files /etc/hosts and /etc/hostname was overridden by the defaults of the provider.

Reason: Virtuozzo (the software which virtualises my VPS) overrides those files at every  time the VPS is booting.

Solution: Replacing the files /etc/hosts and /etc/hostname at boot-time.

The following description is applied for Ubuntu 14.04. Both replacements are implemented as upstart jobs.

/etc/hosts

Copy the /etc/hosts (e.g. /etc/hosts_my) and adapt it to your needs. Then create the file /etc/init/hosts.conf with the following content:

description "restore my hosts"
start on startup
exec cp /etc/hosts_my /etc/hosts

/etc/hostname

Copy the /etc/hostname (e.g. /etc/hostname_mod) and adapt it to your needs. Then edit the file /etc/init/hostname.conf and change the last exec command to:
exec hostname -b -F /etc/hostname_mod
 

That’s it!

Advertisements

, ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: