#!/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