[arch-releng] [PATCH] [syslinux-iso] Add automated_script support
dieter at plaetinck.be
Fri Jan 28 08:19:50 EST 2011
On Thu, 27 Jan 2011 22:25:13 -0300
Gerardo Exequiel Pozzi <vmlinuz386 at yahoo.com.ar> wrote:
> Via kernel parameter "script=/path/to/script".
> /path/to/script can be a ftp:// or http:// or an absolute path.
> Original idea by "Charles", I just changes few things to use
> initscripts hooks.
> Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386 at yahoo.com.ar>
> .../overlay/etc/rc.d/functions.d/automated_script | 21
> ++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-)
> create mode 100644
> diff --git
> new file mode 100644 index 0000000..4637ee1 --- /dev/null
> @@ -0,0 +1,21 @@ +. /etc/archiso/functions
> +automated_script ()
> + script="$(cmdline_param script)"
> + if [ -n $script ] ; then
> + stat_busy "Running $script"
> + if [[ $script =~ ^http:// || $script =~ ^ftp:// ]] ; then
> + wget "$script" -q -O /tmp/startup_script >/dev/null
> + else
> + cp $script /tmp/startup_script
> + fi
> + if [ -s /tmp/startup_script ] ; then
> + chmod +x /tmp/startup_script
> + /tmp/startup_script
> + fi
> + stat_done
> + fi
> +add_hook multi_end automated_script
Can you explain how it works?
An explanation will be needed for the README anyway.
If it does what I think it does, then we need to put it in the official
installation guide as well.
What I think it does:
- this hook is always executed during boot (independent of boot metod
such as pxe, cd-rom or usb)
- it checks if the kernel has a "script" argument (as given by the
bootloader - never in the official builds - but can easily be
specified when booting over pxe, or making your own iso builds)
- it will download the script if it starts with 'http://' or 'ftp://',
otherwise it will copy it (in this case, you should have have built
your own images with the script in them, otherwise there is no way
to have acess to the script, or is there? (network mount?))
- it then executes the script if it is copied/downloaded successfully.
in the script you can put something like 'aif -p automatic -c <path
to config>' or 'aif -p interactive'.
I would suggest some error handling.
if the wget fails (and/or /tmp/startup_script does not exist), you
should not do a stat_done, but stat_error or whatever it's called.
another thing, if /tmp/startup_script takes a long time (like, when
running aif), doing this all in the "boot process" and then doing a
stat_done doesn't seem right. aif is supposed to be run after boot has
completed. (to which extent this gives problems, I don't know, maybe
the ncurses dialogs will be rendered incorrectly etc)
also, we use MOTD to show some info before the installation is
invoked, with this approach it will show the MOTD after aif has run.
More information about the arch-releng