Starting/Stopping Vservers automatically on boot/shutdown

The "vserver" way to have virtual machines start on boot is to create the file "/etc/vservers/NAME/apps/init/mark" with the word "default" in it. When "util-vservers" package is run on boot, it scans for this word in that file name for each vserver, and if it finds it, then that vserver is started. (The actual word you put in the file and the number of vservers which will be started in parallel is set in the "/etc/defaults/util-vservers" file.) Unfortunately, util-vserver doesn't give you much control over which vservers are started in which order. They are started and stopped in alphabetical order by the name of the configuration directory in "/etc/vservers". You can specify a group of vservers which others "depend" on so that they will always be started first, but effectively that's your only control. Within the groups of vservers you cannot control the order in which they are started. So we have patched the "start-vserver" script that comes with the "util-vserver" package so it reads an additional a file, 'apps/init/startorder', for each vserver in its configuration directory. (You can get the patch at the bottom of this page.) In that file is a number which is the numeric position for starting that virtual machines. So if that file contains the number "5", then this will be the 5th virtual machine started. (Vservers are stopped in reverse order. So the first vserver started is the last vserver stopped.) In this way we can control exactly the order in which vservers are started. We also have written a small perl script which allows you to see and set the order the vservers will be stopped and started. It creates (or deletes) the 'mark' file and the 'startorder' file automatically. You can get the syntax of the tool, by running "vs-init.pl -h". Here's a short synopsis: vs-init.pl displays the order the vservers will be started. vs-init.pl assign VSERVER POSITION assigns the vserver "VSERVER" to be started as number "POSITION". If you assign a vserver to an existing POSITION, then that existing POSITION becomes POSITION+1 and so on. So if there's already a number '3' and you now assign a new vserver to be number '3', the original number '3' becomes '4', the original number '4' becomes '5', etc. The same thing happens in reverse when you remove a vserver - all higher numbers come down one. So if you remove '3', then '4' becomes '3', '5' becomes '4', etc. vs-init.pl remove VSERVER removes the "startorder" file which means that this vserver will NOT be started automatically. vs-init.pl find VSERVER displays the start order for VSERVER. vs-init.pl is a GPL'ed perl script. If you find any problems or make any improvements, please let us know so we can incorporate them.