Changes between Version 13 and Version 14 of HowTo/WriteInstallScript
- Timestamp:
- 09/25/12 13:22:40 (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
HowTo/WriteInstallScript
v13 v14 6 6 7 7 = 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 == 9 9 * 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 10 10 * your script '''does run as a user with [http://en.wikipedia.org/wiki/Sudo sudo privileges]'''. Make sure you use `sudo` when: … … 12 12 * you place things in your home directory 13 13 * 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 }}} 15 22 * 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. 16 23 24 == Choose a scripting language == 17 25 You can use any scripting language you want, popular choices are: 18 26 * [http://en.wikipedia.org/wiki/Shell_script shell scripts], there are many tutorials online that can guide you through it. … … 22 30 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 23 31 32 == Parts of your script == 33 Your 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 24 36 37 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: 38 {{{ 39 go to execution directory 40 if <file> does not exist: 41 create file 42 run one-time commands 43 endif 44 run boot-time commands 45 }}} 46 47 }}} 25 48 = 2. Test your script = 26 49 = 3. Find a Web Server =