[arch-releng] [PATCH] [syslinux-iso] Add automated_script support

Dieter Plaetinck dieter at plaetinck.be
Sat Jan 29 18:01:38 EST 2011


On Sat, 29 Jan 2011 19:28:19 -0300
Gerardo Exequiel Pozzi <vmlinuz386 at yahoo.com.ar> wrote:

> On 01/28/2011 10:19 AM, Dieter Plaetinck wrote:
> > 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.
> >>
> >> https://bbs.archlinux.org/viewtopic.php?id=111925
> >>
> >> 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
> >> configs/syslinux-iso/overlay/etc/rc.d/functions.d/automated_script
> >>
> >> diff --git
> >> a/configs/syslinux-iso/overlay/etc/rc.d/functions.d/automated_script
> >> b/configs/syslinux-iso/overlay/etc/rc.d/functions.d/automated_script
> >> new file mode 100644 index 0000000..4637ee1 --- /dev/null
> >> +++
> >> b/configs/syslinux-iso/overlay/etc/rc.d/functions.d/automated_script
> >> @@ -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)
> yes.
> > - 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)
> yes.
> > - 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?))
> yes.
> > - 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'.
> >
> Not exactly, depends on what you want.
>
>
> > 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.
> >
> Yes. Errors must be catched. According to Charles, this works OK.
> @Charles: aif tested via the script?
> I guess that MOTD will never appears (guessing an automatic reboot).
> 
> Anyway all these things are responsability of the script creator.
> This patch only add support to launch a custom script, what and how 
> things are doing by script is another issue.

well, i mention running aif explicitly, because this was the original use case
( https://bbs.archlinux.org/viewtopic.php?id=111925)
and this will probably also be -by far- the most common use case.  So we should be sure it works fine before merging. (it seems reasonable to test both an automatic and an interactive install)

maybe there is an easy way to make this script set up another script so that it will be run after the boot process has completed.
for example, the script could be something like:

echo 'aif -p automatic -c <config>' >> /etc/rc.local
chmod +x /etc/rc.local

however, I think that will also be run before the MOTD gets shown.
Ideally, I think the script would set up auto login as root, and then put the aif invocation in /root/.bash_profile, or something like that.
But it's probably too late to set up auto login as root, because that needs to be done by modifying /etc/inittab, but init is already running...

> 
> PS1: Charles, please suscribe to arch-releng ML, so can follow thing 
> more easily.
> PS2: I am a bit busy these days.
> 
> > Dieter
> >
> 



More information about the arch-releng mailing list