Changes between Version 14 and Version 15 of HowTo/WriteInstallScript

09/25/12 13:43:12 (10 years ago)



  • HowTo/WriteInstallScript

    v14 v15  
    22When getting ready to run experiments in GENI, it is always a good idea to automate the setup of your experiment.
     4This page assumes you know
     5  * how to create a sliver with all the nodes that you need
     6  * how to [wiki:HowTo/LoginToNodes login to your nodes]
     7  * know what steps of your experiment you want to automate with the install scripts
    49In 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.
    1419   * the [ $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
    1520     {{{
    16      #!<path to your interpreter
     21     #!<path to your interpreter>
    1722    }}}
    1823    If you don't know the path, while logged in run (this is an example to figure out where python is installed)
    2126    }}}
    2227   * 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.
     28   * 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.
    2430== Choose a scripting language ==
     53This is an example of a script that installs some packages, download and install a software, change some parameters and reboot the node in the end.
     56# Usual directory for downloading software in ProtoGENI hosts is `/local`
     57cd /local
     59##### Check if file is there #####
     60if [ ! -f "./installed.txt" ]
     62       #### Create the file ####
     63        sudo touch "./installed.txt"
     65       #### Run  one-time commands ####
     67       #Install necessary packages
     68        sudo apt-get update& EPID=$!
     69        wait $EPID
     70        sudo apt-get -y install git-core unzip cmake libpcap-dev libxerces-c2-dev libpcre3-dev flex bison g++ autoconf libtool pkg-config libboost-dev libboost1.40-all-dev gawk & EPID=$!
     71        wait $EPID
     73       # Install custom software
     74       sudo git clone git:// & EPID=$!
     75       wait $EPID
     76       cd myproject
     77       sudo ./ & EPID=$!
     78       wait $EPID
     79       sudo ./configure & EPID=$!
     80       wait $EPID
     81       sudo make & EPID=$!
     82       wait $EPID
     83       sudo make install & EPID=$!
     85       # For my experiment I need to disable IPV6
     86       echo "#disable ipv6" | sudo tee -a /etc/sysctl.conf
     87       echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
     88       echo "net.ipv6.conf.default.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
     89       echo "net.ipv6.conf.lo.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
     90       ## Reboot the OS to run a latest kernel without IPv6.
     91       sudo reboot
     93##### Run Boot-time commands
     94# Start my service -- assume it was installed at /usr/local/bin
     95sudo /usr/local/bin/myproject-server
    4898= 2. Test your script =