'''This page is still under constructions, please email comments to help@geni.net''' [[PageOutline]] When getting ready to run experiments in GENI, it is always a good idea to automate the setup of your experiment. This page assumes you know * how to create a sliver with all the nodes that you need * how to [wiki:HowTo/LoginToNodes login to your nodes] * know what steps of your experiment you want to automate with the install scripts In GENI [wiki:GENIExperimenter/RSpecs RSpecs], you have the capability of instructing an Aggregate Manager to download software from the web, and execute install scripts at boot up time. This page provides step by step instructions about how to write and use install scripts. = 1. Write your script = == Things to remember == * your script '''does not run in the context of your user''', make sure that you change the permissions of anything installed in your home directory so that you have access to them when you login * your script '''does run as a user with [http://en.wikipedia.org/wiki/Sudo sudo privileges]'''. Make sure you use `sudo` when: * you execute privileged commands (e.g. `yum`, `apt-get`, `service`) * you place things in your home directory * you try to write files in protected directories (e.g. `/usr/local/bin/, /local/) * the [http://en.wikipedia.org/wiki/PATH_(variable) $PATH environment variable] is not necessarily set, make sure you use the full path of commands in your scripts; for example don't use `ifconfig`, but use `/sbin/ifconfig`. This is also true for the interpreters used for your script.Make sure you start your script with a line like {{{ #! }}} If you don't know the path, while logged in run (this is an example to figure out where python is installed) {{{ $ which python }}} * your script runs '''every time the host reboots''', so if you reboot the host as part of your script you have to '''check if your script has already ran''' or you will end up in a cycle of reboots. * your script should be '''fully automated'''. You won't be able to interact with your script when it runs so make sure it doesn't need any input to run. For example if you use `apt-get`, use the `-y` flag so that `apt-get` assumes `yes` to any interactive question. == Choose a scripting language == You can use any scripting language you want, popular choices are: * [http://en.wikipedia.org/wiki/Shell_script shell scripts], there are many tutorials online that can guide you through it. * [http://www.perl.org/ Perl]. Make sure that perl is installed by default in the Image you are using. Login to your nodes and type `perl -h`. * [http://www.python.org/ Python]. Make sure that Python is installed by default in the Image you are using. Login to your nodes and type `python -h`. If an interpreter for the scripting language of your choice is not installed, you can write a short shell script that will first install it == Parts of your script == Your script should have at least two parts: * the part that needs to be executed only once * the part that needs to be executed every time the node boots up The easiest way to achieve this is by adding a file the first time your script runs and then check for the existence of that file before running one-time commands. Independent on which scripting language you decide to use, your script would look like: {{{ go to execution directory if does not exist: create file run one-time commands endif run boot-time commands }}} After you write your script make sure it is executable by doing: {{{ chmod +x