Subject: Re: [alpine-devel] Unattended Installation Ideas for 2.1

From: "Matt Smith" <[email-masked]>
Date: Thu, 19 Aug 2010 05:03:07 -0500 (CDT)

On Wednesday, August 18, 2010 9:54am, "Natanael Copa" <[email-masked]> said:
> On Fri, 2010-08-13 at 22:12 -0500, Matt Smith wrote:
> The goal is to make a bootable cdrom or USB that will run the install
> for you and give you a running system.
> 
> The goal is that it should be easy for enduser to create such system and
> it should be simple to understand whats going on.
> 
>> The concept work-flow at the moment, goes something like this:
>>
>> 1. The user will obtain "alpine-iso" via git.
> 
> I think it would be nice if the enduser would not need to create new iso
> if the target was a bootable USB. In other words, it would be nice if it
> would be enough to just copy a file to a bootable usb or something.

I like that idea.

(...snip...)
> We talked about this some really long time ago. The boot scripts used to
> look for a localinit script on the boot media (iso image/usb) and if
> found it was executed as last step in boot process.
> 
> We still have something similar with the /etc/init.d/local "service"
> which executes /etc/rc.local

* For USB: I believe that unattended support should be built into the publicly
available ISOs, where the user could download, dd to a USB stick, and start
adding their scripts.  When booted, the main script is executed if found.

* For ISO: The user could modify the example scripts provided in
alpine-iso/unattended and/or add new scripts altogether.
Then just "make PROFILE=alpine iso" and burn to CD (or dd to USB).

Right now, I'm thinking the bulk of the scripts should be located
at /etc/unattended.

Keep in mind, however, that that path is only "available" from within the
initrd.  For instance, if done via USB, simply copying the scripts to the
USB stick, assuming an "unattended" directory is created at the root
of the USB's filesystem and the USB's filesystem is auto-mounted to
/media/usb, would make them available at /media/usb/unattended. Or in the
case of a CD/ISO, it would be available at /media/cdrom/unattended.

After that, all we would need to do is check either
/media/cdrom/unattended or /media/usb/unattended for the main script.

(Perhaps /media/alpine should be created to point to the install/LiveCD
media, whether its a CD or USB stick.  Then for instance, the APK repositories
file, among others, won't have to be altered from one media type to the other.)

>> => I recommend that we make the system "free-form," allowing for much
>>    flexibility.  I like this idea for two reasons:
>>      1) The implementation will be simple.
>>      2) It will be relatively straight-forward for the user; they will do
>>         everything they would normally do from the installation's "LiveCD"
>>         environment, as well as, e.g., configuring the installed system for
>>         networking with an IP address and OpenSSH.  All in an automated,
>>         non-prompting fashion.
> 
> freeform as in a simple shell script? like /etc/rc.local?

Yeah, pretty much.

>> => The UNATTENDED_SCRIPT can source other shell scripts (like any other shell
>>    script), for use of common functions.  (One handy function would be the one
>>    I've created already that makes it easy to execute lengthy commands via
>>    chroot.)
> 
> Ok, so you want stuff in more than a single file. You'd need a tar
> archive then, like apkovl?

Not sure.  The idea is to allow the user to create as many scripts as they
believe are necessary, programatically stemming from the user's main shell script.

For instance, they could have a DHCP server configured to dole out a specific
IP address to a specific MAC address upon request.  At this point, their scripts
could setup networking for DHCP, and then, based on the IP address obtained,
execute a script that's specific to installing and configuring this particular
machine.

In this manner, the user could create numerous individual machine install
configs, but yet include them all on a single ISO or USB stick or USB stick
image.

>> => We should add some sort of universal "accept the defaults" option to the
>>    /sbin/setup-* scripts (e.g. setup-disk), such as "--accept-defaults."
>>    (I've already got a basic version of setup-disk that does this.)
> 
> I think it would be nice with some preseeds, that answers some of the
> questions or all or tells the script "use default". User could be asked
> the missing answers. That way you could make an half automated install,
> where end user maybe only need to answer 1 question.

On the other hand, perhaps the user could simply use "expect" to answer
any and all prompts that are normally available for things such as
setup-disk and setup-keymap.  I'm not sure which package "expect" is in,
if it's even available yet?

>> => When the unattended install is complete, we could either "halt" or "reboot."
>>    Assuming the CD/ISO will still be present after doing an automatic reboot,
>>    we would need to do some sort of check to see if a prior unattended install
>>    has completed.  If it has, proceed to booting the MBR of the first HDD, or,
>>    if the user knows in advance what to boot, perhaps that could be added as an
>>    option to the .conf.mk file.
>>    => For example:
>>       ON_FINISH=(halt|reboot)  # Maybe even make this a user-configurable script
>>                                # instead.
>>       ON_REBOOT_BOOT=sda
> 
> Fedora/Redhat uses a boot option, "ks" to fire up the unattended
> install. If you need enter an option at bootprompt it fire the thing up,
> you would not need check if it was previously run. (even if thats
> trivial to implemnt too).
> 
> And you normally want look at the screen to see that it properly boots
> before you leave it unattended.

That is true.  I like it.  I guess I just thought that (most?)
unattended installs were just dropping in a CD and rebooting.

Actually, the CactiEZ ISO I tried a few days ago seemed to require that you
press enter to boot with the default options (which I believe was 32-bit, as
opposed to 64-bit), but still, it did require that you at least do something
before it erased the primary HDD and went about installing everything
automatically).

(...snip...)
> For the unattended install problem, I think we can split it up in
> atleast 3 parts:
> 
> 1. something that kicks in a script at end of boot.
> 2. having preseeded answers to the setup-scripts.
> 3. optionally fix alpine-iso to include #1 and #2 on the iso (trivial)
> 
> Problem #1 can be solved in various ways:
> a. ship an apkovl with the contents:
>   /etc/rc.local
>   /etc/runlevels/default/local -> /etc/init.d/local
> 
> (if rc.local's last thing it does is 'rc-update del local', then it will
> not be execute next run)

IMHO, that seems kind of sloppy.

> b. we could have a boot script parse boot params to kernel and excute
> stuff based on that

I like this the best.

> c. we could have a magic file on boot media, similar to apkovl, but
> instead of beeing a tar archive it is a simple script that gets
> autostarted. (like we did long time ago with localinit)

This is kind of what I did in my experiments, but I like the previous idea,
in that you can choose what to do on boot, instead of having the decision
made based on whether or not a magic file is available.

-- Matt Smith

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Natanael Copa <[email-masked]>
Date: Fri, 20 Aug 2010 14:35:07 +0200

> > On Fri, 2010-08-13 at 22:12 -0500, Matt Smith wrote:

...

> /media/cdrom/unattended or /media/usb/unattended for the main script.

or we could have a boot param: ua=usb:/unattended

With fedora you have 'ks' (for kickstart) and you can specify what
devices to search + a patch to the kickstart file.

> file, among others, won't have to be altered from one media type to the other.)

I like this idea.

> configs, but yet include them all on a single ISO or USB stick or USB stick

I wonder if we want preseeds, or answer files to the setup script(s)
with optional scripting hooks.

something like, unattended.conf (sa=setup-alpine for example) :

sa_keyboard=no
sa_hostname=alpine
sa_net_eth0_type=static

# uncomment row below to avoid prompting user
#sa_net_eth0_address=192.168.8.1/24

sa_net_eth1_type=dhcp

post_hook="echo 'install is done. will reboot in 10 sec' && sleep 10 && reboot"
	
...etc

Maybe lua is a better language for that. IIRC i wrote some experiments
for that some time ago. I wonder where that code went.

> if it's even available yet?

I dont think it is. I saw some expect-like utility that was a bit
smaller and simpler.

I still would prefer a preseed.conf or unattended.conf file over
scripts.

> before it erased the primary HDD and went about installing everything

yes, i dont like the idea of a bootable cdrom with written alpine on it
that erases your disk without asking first.

> IMHO, that seems kind of sloppy.

yes, I am :) But it does what you want, without adding any extra code.

> > b. we could have a boot script parse boot params to kernel and excute

I think this is what I prefer too.

So, we have the kick-in mechanism more or less worked out. Some
questions remains. What do we call the beast? alpine-setup? auto-setup?
unattended-setup? kickstart? (redhats)

We should probably make a service that is triggered if the boot param is
found (from initramfs) so it is kicked in before login prompt.

Now, the real question is, how do we do the auto-answer on setup
scripts. I'd like have that part working before we write any code that
triggers it.

-nc

---

---

From: "Matt Smith" <[email-masked]>
Date: Fri, 20 Aug 2010 19:28:56 -0500 (CDT)

...
> devices to search + a patch to the kickstart file.

Yeah, that sounds good.

>> file, among others, won't have to be altered from one media type to the other.)
(Kept above text for reference because it's on-point with the previous idea above.)

...
...
> I still would prefer a preseed.conf or unattended.conf file over

I can tell that you're big on the idea of doing a preseed or some type of
config file.  My issue with that is, and hear me out: even if all of the
custom variables are well-documented on the wiki, the user still has to
look up the documentation to figure out how to do something that's
relatively simple (e.g., what variable format and its syntax will allow me
to do X).  To be fair, I don't mind how ArchLinux does their rc.conf.
Granted that such an implementation would bring a certain level of sanity
to the table, I fear that it also limits the user to what the unattended
install would otherwise be capable of.

If you like the free-form idea a little more now, what if we instead
provided both implementations to the user?

The free-form idea would be easier to implement and I think advanced users
would appreciate it.  It should at least get us started quicker (and
eventually towards working on a preseeded answers method).

...
> unattended-setup? kickstart? (redhats)

What about Alpine Unattended Setup (AUS), or Alpine Linux Unattended Setup (ALUS)?
I kinda like AUS.

> found (from initramfs) so it is kicked in before login prompt.

Sounds good.

> scripts. I'd like have that part working before we write any code that

As for the free-form idea, I say we recommend either "expect" or a simpler
version of "expect".  Simple reason being that without a large amount of
effort, and even then, it's largely impossible to provide an "accept the
defaults" option for anything and everything the user might want to use
during the unattended install.

- Matt Smith

---

---

From: Natanael Copa <[email-masked]>
Date: Tue, 24 Aug 2010 13:02:20 +0200

> What about Alpine Unattended Setup (AUS), or Alpine Linux Unattended Setup (ALUS)?

ok.

> during the unattended install.

I created lua-pty package which lets you control apps from lua via ptys,
similar to what expect does.

We dont have expect so we need a package for it. It does require tcl so
dependencies might be several MB. If we use lua we get away with 300K
probably.

There is a expect-light project, but it seems to require expect
http://expect-lite.sourceforge.net/

Otherwise we have "emtpy" http://empty.sourceforge.net/ which seems like
a good alternative.

-nc

---

---

From: Natanael Copa <[email-masked]>
Date: Tue, 24 Aug 2010 13:15:33 +0200

> Otherwise we have "emtpy" http://empty.sourceforge.net/ which seems like

added package 'empty' to edge/testing.

-nc

---

---

From: "Matt Smith" <[email-masked]>
Date: Thu, 26 Aug 2010 02:16:54 -0500 (CDT)

> Otherwise we have "emtpy" http://empty.sourceforge.net/ which seems like

Yeah, the lua-pty option sounds pretty light-weight, as does "empty."

I'm open to using either option, but I'm thinking "empty" might be a better fit?

- Matt Smith

---

---

From: Natanael Copa <[email-masked]>
Date: Thu, 26 Aug 2010 15:16:48 +0200

> I'm open to using either option, but I'm thinking "empty" might be a better fit?

I'm ok with both. Depends on if you want do it with shell scripts or lua.

-- 
Natanael Copa

---