[Grml] grml cdrom script to import Debian network configuration
Marc Haber
mh+grml at zugschlus.de
Fri Dec 16 20:55:14 CET 2005
Hi,
today, I have written a /cdrom/scripts script which imports the
network configuration from an installed Debian system. That way, it
becomes possible to have _one_ grml medium around which could then in
turn be used as a rescue system for _all_ Debian systems at the place
for remote rescue, as long as the root filesystem is still reachable.
The script searches all found hard disk partitions and LVM devices for
a mounteable filesystem containing a file /etc/network/interfaces and
then proceeds to copy /etc/network from that filesystem into the grml
system before restarting the network devices. That way, the grml
system comes up with a network configuration that is likely to work.
The script doesn't integrate nicely into grml, it is written in bash,
not in zsh, and doesn't use the fancy colorful output of the normal
grml init procedure. Maybe one of the grml makers can adapt it to
integrate more nicely and then publish it as an example on the grml
wiki.
One issue that I find especiall annoying is the fact that grml starts
a pump process which is still around when our script runs, and will
take down the freshly configured interface after timing out. pump -k
will also wait for that timeout, and thus impose a delay in system boot.
Greetings
Marc
--
-----------------------------------------------------------------------------
Marc Haber | "I don't trust Computers. They | Mailadresse im Header
Mannheim, Germany | lose things." Winona Ryder | Fon: *49 621 72739834
Nordisch by Nature | How to make an American Quilt | Fax: *49 621 72739835
-------------- next part --------------
#!/bin/bash
# Builtin filesystems
BUILTIN_FS="iso9660 ext2 vfat"
mountit(){
# Usage: mountit src dst "options"
# Uses builtin mount of ash.grml
for fs in $BUILTIN_FS; do
test -b $1 && mount -t $fs $3 $1 $2 >/dev/null 2>&1 && return 0
done
return 1
}
DEVICES="$(< /proc/partitions tail +3 | awk '{print "/dev/"$4}' | tr "\n" " ")"
DEVICES="$DEVICES $(ls /dev/mapper/*)"
FOUND_DEBNET=""
for i in $DEVICES; do
echo -n "Looking for Debian network configuration on $i... "
if mountit $i /mnt "-o ro" >/dev/null 2>&1; then
echo -n "mounted... "
if [ -f /mnt/etc/network/interfaces ]; then
echo "found."
FOUND_DEBNET="$i"
break
else
echo -n "not found. umounting... "
fi
umount /mnt
echo "done."
else
echo "not mounted."
fi
done
if [ -n "$FOUND_DEBNET" ]; then
pump -k
/etc/init.d/networking stop
echo -n "Copying Debian network configuration from $FOUND_DEBNET... "
rm -rf /etc/network/run
cp -a /mnt/etc/network /etc
rm -rf /etc/network/run
mkdir /etc/network/run
echo "done."
echo -n "Umounting $FOUND_DEBNET... "
umount /mnt
echo "done."
/etc/init.d/networking start
fi
More information about the Grml
mailing list