Having looked at automating the install of Citrix XenServer we can now take this one step further and customize XenServer with scvripts that run after the XenServer has rebooted. This was we join the server to pool, add the license information, connect to storgae repositries or anything really. What we have to realize that any script that runs during the intsall is limited to the context of the installtion OS and not Xenserver. So these scripts are used to copy scripts from a network location to the XenServer to be run of first boot. looking at the answer file we can see that it calls a script called file-copy.sh
<script stage="filesystem-populated" type="url"> http://192.168.1.1/suse/file-copy.sh </script>
That script copies another script to the XenServer and creates a sym-link to it within the rc3.d directory. This means it will run of boot so loand as the link start with an uppper-case S as we have created here.
#!/bin/sh touch $1/tmp/post-executed wget http://192.168.1.1/suse/first-run.sh -O $1/tmp/first-run.sh chmod 755 $1/tmp/first-run.sh ##set premissions ln -s /tmp/first-run.sh $1/etc/rc3.d/S99zzpostinstall
The first-run script then will executes the required xe commands to customize XenServera s required and to ensure it does not run again deletes the link. It may look a little ugly but, as with all scripting, it is easy with a little practice.
Watch the video for the full and gory details, but this also illustrates how having basic Linux skills is required when managing Linux based HyperVisors.