We’ve been asked several times what’s the proper way on a NetScaler to make changes to the default system configuration persistent so that they survive a reboot. There are several articles already covering different ways highlighting this topic for your user interface customizations, however a similar process applies to nsapimgr commands you may need in your environment.

Most articles tell you to put everything in rc.netscaler. There are two other files though you can put your special configuration depending on what you want to archive. So what files are there to put your scripts, nsapimgr commands and anything else you want to break your box with? 🙂 Technical Support published the follwing list in article CTX122271:

nsbefore.sh runs before the network components or packet engine is initialized.
nsafter.sh runs after the network / packet engine is initialized.
rc.netscaler runs after the ns.conf file is loaded.

Why did our engineers have this three options for us? For most scenarios rc.netscaler is the right place but sometimes that will not do the job. Example? Some customers for instance need a VPN vServer of type HTTP for more than debugging purposes (see  CTX120639). You may notice while reading this article that the configuration options only work in case the nsapimgr command is set to 1. Timing is crucial therefore and you need to make sure that the flag is set before the ns.conf content is applied to the running configuration. In this case, rc.netscaler won’t help you – the configuration for the vServer will be skipped without the kernel flag “add_http_vpn_vserver=1″.

To make sure that the configuration will persist a reboot and is applied in the right order nsbefore.sh or nsafter.sh is the correct place to add the configuration.

echo “/netscaler/nsapimgr -ys add_http_vpn_vserver=1” >> /nsconfig/nsbefore.sh

To make a long story short, for nsapimgr commands which are required by NetScaler configuration commands rc.netscaler is not necessarily the right place and you should make use of the other outlined options. For most other tasks, rc.netscaler is the right place. When in doubt, ask your Citrix partner or call Citrix Support for guidance.