newvserver is a truly convenient script to create a new vserver and have it largely preconfigured. Too sad it lacks the necessary flexibility … you think? Think twice. Bash gives newvserver the flexibility that you need!
Alright, so you figured out that /etc/vservers/newvserver-vars gets sourced by newvserver, but how can that help? Well, since we know that functions can override commands or builtins, we will have to find a strategically nice point in the newvserver script where we can override some command. After some searching I found the vserver call quite fitting. This is being done (without giving an explicit path to the vserver script) after the vserver build command, which is called using the absolute (full) path. So how about creating a function that will mimick the behavior of the vserver script under normal circumstances, but will do what we expect it to do under certain circumstances? 😉
Continue reading