Differences between revisions 4 and 5
Revision 4 as of 2008-02-17 15:34:51
Size: 3704
Editor: scott
Revision 5 as of 2008-02-29 15:48:06
Size: 3753
Editor: scott
Deletions are marked like this. Additions are marked like this.
Line 75: Line 75:
''ScottJamesRemnant: interaction with exec?''

Please check the status of this specification in Launchpad before editing it. If it is Approved, contact the Assignee or another knowledgeable person before making changes.


This specification aims at providing a way to set up an environment for all scripts in a job file. This is done by adding a script section containing a shell script that will be executed before any other script.


This feature is needed because if someone wants to define a shell function or a variable that will be used in all the scripts of a job file, he/she will need either to copy the declaration at the beginning of all scripts or will need to put these declarations in another file and source it at the beginning of each script. The solution proposed here will simplify hat by not having to copy and paste the same code many times.

Use cases

  • Often SystemV init scripts are configured by shell scripts sourced before the script. You should be able to source a script once and not have to source it in every script.
  • Some distros use shell functions for starting and stopping the network. You should be able to define these functions once at the beginning of the file and use them everywhere else.



It will be possible to write scripts inside a new section that begins with common script and ends with end script. This script will be executed before any other script and in the same environment. For example:

common script
    source /etc/rc.conf
end script

post-start script
    for if in $INTERFACES; do
        ifup $if
end script



No idea ... sorry.

ScottJamesRemnant: not that difficult, it could be done by simply concatenating the scripts in job_run_process, it may be easier if we force the /dev/fd/NNN trick, but it's possible either way.

Data preservation and migration

These changes are backwards compatible with the previous behaviour.

Unresolved issues

Maybe it could be possible to add a common script that will be sourced after any other script that would for example clean temporary files created in the common script that ran at the beginning. But it is not necessary because this cleanup can be written in a shell function that is easily called at the end of all other scripts.

ScottJamesRemnant: interaction with exec?

CommonScript (last edited 2008-02-29 15:48:06 by scott)