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

Dieter Plaetinck dieter at plaetinck.be
Sat Feb 5 05:12:21 EST 2011


On Fri, 04 Feb 2011 12:07:08 +0100
Charles Vejnar <ce at vejnar.org> wrote:

> Le jeudi 3 février 2011 21:21:08, Dieter Plaetinck a écrit :
> > On Thu, 03 Feb 2011 21:04:51 +0100
> > 
> > Charles Vejnar <ce at vejnar.org> wrote:
> > > I agree 100%. I am saying that, in case auto root-login is activated,
> > > adding with the script something to .bash_profile compared the submited
> > > patch is a better solution.
> > 
> > Not sure what you mean. the submitted patch only enables the script hook,
> > so the patch would be a necessity before you can even add something to
> > .bash_profile from the script.
> > 
> > > > but first address the concerns..
> > > 
> > > If I am not missing one, and if auto root-login is activated on tty1 then
> > > your only remaining concerns was about error handling (stat_error in
> > > case the script isn't retrieved correctly). Is that right ?
> > 
> > you should really look at the script yourself and imagine any possible
> > thing that could go wrong, and make sure the script handles it properly.
> > 
> > my other concern is: if the user wants to run an automatic or interactive
> > install (configured by the script): - the actual installation should not
> > happen during the init process. - it should be run when the environment is
> > set up correctly (i.e. user is logged in, .bash_profile and .bashrc are
> > sourced) - it should be run after the MOTD has shown
> > 
> > I want to see 2 working scripts which actually implement starting an
> > automatic and an interactive install (properly, as explained above).  We
> > could ship those as example scripts in the archiso repository (I
> > considered putting them in the overlay directory, so they end up on the
> > images, but I don't think that's useful).
> > 
> > Also, the documentation needs to be updated for this:
> > 1) the official installation guide (in AIF repository)
> > 2) Maybe also the archiso README, I let Djgera decide on that
> > 
> > Dieter
> 
> Hi Dieter,
> 
> Here are my patches:
> 
> 1/ Modified automated_script
> 
> . /etc/archiso/functions
> 
> automated_script ()
> {
>     script="$(cmdline_param script)"
>     if [ -n $script ] ; then
>         stat_busy "Configuring $script"
>         if [[ $script =~ ^http:// || $script =~ ^ftp:// ]] ; then
>             wget "$script" -q -O /tmp/startup_script >/dev/null
>             rt=$?
>         else
>             cp $script /tmp/startup_script
>             rt=$?
>         fi
>         if [ $rt -eq 0 ] ; then
>             chmod +x /tmp/startup_script
>             echo "/tmp/startup_script" >> /root/.bash_profile
>             stat_done
>         else
>             stat_fail
>         fi
>     fi
> }
> 
> add_hook multi_end automated_script

looks good.
> 
> 2/ Modified inittab
> 
> c1:2345:respawn:/sbin/agetty -n -l /usr/bin/autologin -8 38400 tty1 linux
> 
> 3/ New /usr/bin/autologin
> 
> #!/bin/bash
> /bin/login -f root

why like this and not just run login -f root directly from inittab?

 
> I tested successfully everyting (through PXE) with the following scripts:
> 
> #!/bin/bash
> aif -p interactive
> 
> And also (for automatic install, this procedure needs a web server, I wrote 
> something for that purpose and will publish it):
> 
> #!/bin/bash
> mac=$(ifconfig eth0 | sed -n 's/.*HWaddr \([a-zA-Z0-9:]*\).*/\1/p')
> wget "http://192.168.3.2:8086/get/$mac" -q -O /tmp/aif_profile >/dev/null
> aif -p automatic -c /tmp/aif_profile
> wget "http://192.168.3.2:8086/remove/$mac" -q -O - >/dev/null
> reboot

this seems good, although you should probably error out if anything failed (aif/wget/ifconfig/sed calls), so that the 2nd http request only happens if everything went fine.
using /bin/bash -e on the first line should do just that.
 
> The MOTD get displayed in both cases.

thanks, this is starting to look good.
but you will need to provide patches (using git-format-patch and git-send-mail)
and don't forget to add a patch for the official installation guide in the aif repository.

anyway, I'm at FOSDEM all weekend, so if you happen to be there, let me know (or find me: I'm the only guy in the world with a black Arch Linux polo)


Dieter




More information about the arch-releng mailing list