Changes between Version 14 and Version 15 of HowTo/WriteInstallScript
- Timestamp:
- 09/25/12 13:43:12 (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
HowTo/WriteInstallScript
v14 v15 1 1 [[PageOutline]] 2 2 When getting ready to run experiments in GENI, it is always a good idea to automate the setup of your experiment. 3 4 This 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 3 8 4 9 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. … … 14 19 * 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 15 20 {{{ 16 #!<path to your interpreter 21 #!<path to your interpreter> 17 22 }}} 18 23 If you don't know the path, while logged in run (this is an example to figure out where python is installed) … … 21 26 }}} 22 27 * 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. 23 29 24 30 == Choose a scripting language == … … 45 51 }}} 46 52 53 This 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. 54 {{{ 55 #!/bin/sh 56 # Usual directory for downloading software in ProtoGENI hosts is `/local` 57 cd /local 58 59 ##### Check if file is there ##### 60 if [ ! -f "./installed.txt" ] 61 then 62 #### Create the file #### 63 sudo touch "./installed.txt" 64 65 #### Run one-time commands #### 66 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 72 73 # Install custom software 74 sudo git clone git://github.com/myproject.git & EPID=$! 75 wait $EPID 76 cd myproject 77 sudo ./boot.sh & EPID=$! 78 wait $EPID 79 sudo ./configure & EPID=$! 80 wait $EPID 81 sudo make & EPID=$! 82 wait $EPID 83 sudo make install & EPID=$! 84 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 92 fi 93 ##### Run Boot-time commands 94 # Start my service -- assume it was installed at /usr/local/bin 95 sudo /usr/local/bin/myproject-server 96 47 97 }}} 48 98 = 2. Test your script =