Changes between Version 13 and Version 14 of HowTo/WriteInstallScript


Ignore:
Timestamp:
09/25/12 13:22:40 (12 years ago)
Author:
nriga@bbn.com
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • HowTo/WriteInstallScript

    v13 v14  
    66
    77= 1. Write your script =
    8 The first step is to write your install script. While writing your script you should keep in mind that:
     8== Things to remember ==
    99   * 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
    1010   * your script '''does run as a user with [http://en.wikipedia.org/wiki/Sudo sudo privileges]'''. Make sure you use `sudo` when:
     
    1212      * you place things in your home directory
    1313      * you try to write files in protected directories (e.g. `/usr/locac/bin/, /local/)
    14    * 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 add
     14   * 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     {{{
     16     #!<path to your interpreter
     17    }}}
     18    If you don't know the path, while logged in run (this is an example to figure out where python is installed)
     19    {{{
     20    $ which python
     21    }}}
    1522   * 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.
    1623
     24== Choose a scripting language ==
    1725You can use any scripting language you want, popular choices are:
    1826  * [http://en.wikipedia.org/wiki/Shell_script shell scripts], there are many tutorials online that can guide you through it.
     
    2230If an interpreter for the scripting language of your choice is not installed, you can write a short shell script that will first install it 
    2331
     32== Parts of your script ==
     33Your script should have at least two parts:
     34   * the part that needs to be executed only once
     35   * the part that needs to be executed every time the node boots up
    2436
     37The 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:
     38{{{
     39go to execution directory
     40if <file> does not exist:
     41   create file
     42   run one-time commands
     43endif
     44run boot-time commands
     45}}}
     46
     47}}}
    2548= 2. Test your script =
    2649= 3. Find a Web Server =