Good enough

Reece Arnott <[email protected]>
Newsgroups gmane.org.user-groups.linux.dunedin.general
Message-ID <CALhZJhqsXQbfK5siZRx1maQOx+afSQUKSbTaFH2+=A1yN_cv7A@mail.gmail.com>
I've given up making my own fast one-off boot disk for doing weird and
wonderful tasks, such as getting MAC addresses off machines, and instead
have gone with adding the functionality on top of an already existing
system so that others can easily change it without getting into any messy
modification of filesystems.

The SARDU Multi-boot USB creator (http://www.sarducd.it/) is quite
interesting in that it recognises 20 or so different bootable CD/DVD iso
images and will make a bootable USB from them with a simple menu system to
boot the one you want.

I took the entry for Ubuntu 13.10 and modified it slightly:

LABEL Reece
    Menu label ^0) Run Reece's Menu from 64-bit Ubuntu 13.10 Live terminal
    TEXT HELP
       type "/cdrom/rmenu" when booted
    ENDTEXT
    KERNEL /ubuntu/casper/vmlinuz.efi
#Copied from syslinux "Run Ubuntu 13.10 (64-bit)" and added casper option
'text'
    append  persistent file=/cdrom/ubuntu/preseed/ubuntu.seed boot=casper
text initrd=/ubuntu/casper/initrd.lz ignore_uuid
live-media-path=/ubuntu/casper locale=en_US.UTF-8 --

The addition of the text option boots to the terminal. The ubuntu Live CD
automatically mounts the device containing the squashfs filesystem as
/cdrom so I created a simple shell script on the root of the drive to copy
the scripts to somewhere in the path and display the menu.


This boots as a newly created live system user but the filesystem is
mounted by root so I needed to modify my scripts slightly.

It takes 30 seconds to boot (compared to the 15 second boot time I
previously had) and means you need to type half a dozen extra characters
(if you take advantage of the tab completion of the path /cdrom/rmenu) but
I think it has all the drivers I need loaded.


Below are the scripts and the menu text document:

rmenu
---------
#!/bin/bash
#In this case the USB drive is mounted as /cdrom by the Ubuntu Live boot
process as it is the same one the squashfs is on.
mntpoint=/cdrom
#This is where we copy the scripts off the USB stick to (assumed to be in
the path)
pth=/usr/local/bin
sudo cp $mntpoint/scripts/* $pth
echo "Copied scripts from $mntpoint/scripts to $pth"
menu

menu
--------
cat /cdrom/Reecesmenu

Reecesmenu
------------------





                Menu
                ====

a) Get MAC address info and write to file along with user supplied name.

s) Safe shutdown. Need to do this if files on USB were changed.

Type 'menu' to repeat





a
---
#!/bin/bash
computername=$1
filename=/cdrom/Documents/ifconfigs.txt
tempfile=/tmp/temp.txt
#This has to be done for ubuntu as the owner of the files on the mounted
USB drive is root
cp $filename $tempfile
if [ "$computername" == "" ]
then
     echo Alternate Usage: $0 \<computername\>
     echo You need to enter a computer name.
     read computername
     echo Computername: $computername
fi

# Change the field seperator so can read line by line
old_IFS=$IFS
IFS=$'\n'
# This goes through line by line, and prepends the computer name to it (the
-v means it doesn't show any dummy ones, probably not needed when running
from ubuntu)

for line in $(ifconfig -a | grep "HWaddr" | grep -v "00:00:00:00:00:00" |
grep -v "dummy0")
do
    echo $computername $line >> $tempfile
    echo $computername $line
done
IFS=$old_IFS

sudo rm -rf $filename
sudo cp $tempfile $filename
rm -rf $tempfile

echo Last lines of $filename
echo
tail $filename



s
-----
sudo shutdown -h now

_______________________________________________
DunLUG mailing list
[email protected]
http://lists.ethernal.org/listinfo/dunlug
DunLUG Wiki - http://dunlug.kallisti.net.nz/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.