init_rootfs
# Needed for NFS
- /etc/init.d/portmap start >/dev/tty1 2>&1 || die "/etc/init.d/portmap start failed!"
+ /etc/init.d/portmap start >/dev/null 2>&1 || die "/etc/init.d/portmap start failed!"
# For some reason NFS mounts hang if /e/i/networking is not run.
# For the time beeing I'm too lazy to investigate ;)
- /etc/init.d/networking start || die "/etc/init.d/networking start failed!"
+ /etc/init.d/networking start >/dev/null 2>&1 || die "/etc/init.d/networking start failed!"
sleep 2
mkdir -p /media/nfsroot || die "mkdir -p /media/nfsroot failed!"
echo -n "Mounting NFS root..."
+
+ if ( mount | grep -q "/media/nfsroot" )
+ then
+ echo "/media/nfsroot already used, tying to umount..."
+ umount /media/image
+ losetup -d /dev/loop0
+ umount /media/nfsroot || die "umount failed!"
+ fi
+
mount -t nfs "$selection" /media/nfsroot && echo ok || die "mount -t nfs "$selection" /media/nfsroot failed!"
# Use configured resolv.conf in the pivoted rootfs
mount -o remount,ro / >/dev/null 2>&1
+ test "$ENABLE_IMAGECONF" = yes && image_conf $1
+
do_pivot "$1" "$RL"
}
echo ""
- echo "Using [$IMAGE_NAME]"
mkdir -p /media/image || die "mkdir -p /media/image failed"
- echo "Setting up loopback (/dev/loop0) for $IMAGE_NAME"
losetup /dev/loop0 $1/$IMAGE_PATH/$IMAGE_NAME || die "losetup /dev/loop0 $1/$IMAGE_PATH/$IMAGE_NAME failed!"
check_fs /dev/loop0 $IMAGE_TYPE
- echo -e "\n* * * Booting rootfs image * * *\n"
+ echo -e "\n* * * Mounting rootfs image * * *\n"
# Busybox's "mount" doesn't seem to like "-o loop" for some reason
# It works on collie and b0rks on poodle.
if [ "$IMAGE_TYPE" = "" ]; then
IMAGE_TYPE="auto"
fi
+
# If mount fails it has the tendency to spew out a _lot_ of error messages.
# We direct the output to /dev/null so the user can see which step actually failed.
mount /dev/loop0 -t $IMAGE_TYPE /media/image >/dev/null 2>&1 || die "mount -t $IMAGE_TYPE /dev/loop0 /media/image failed!"
mkdir -p /media/image/media/ROM || die "mkdir -p /media/image/media/ROM failed"
+ test "$ENABLE_IMAGECONF" = yes && image_conf /media/image
+
do_pivot /media/image "$RL"
}
}
+# $1: Path to mounted rootfs
+image_conf(){
+ ! test -d "$1" && die "image_conf: [$1] not found / no directory"
+
+ test -e "$1/etc/.image_conf.done" && return
+
+ echo -e "\n\n* * * rootfs configuration * * *\n"
+ echo -e "This setup lets you reconfigure your new rootfs."
+ echo "Most probably the rootfs is configured with"
+ echo "defaults based on a flash installation."
+ echo "If unsure, go with the defaults by pressing <ENTER>."
+ echo ""
+
+ if ( cat $1/etc/fstab | grep -v "^#" | grep -q "/home " )
+ then
+ while true
+ do
+ echo "Usually your /home directory is located on another flash partition."
+ echo -n "Do you want me to move /home inside the loop-image? [N|y] "
+ read junk
+
+ if test "$junk" = "y" -o "$junk" = "Y"
+ then
+ cat $1/etc/fstab | sed "/.*\/home.*/s/\/home/\/home.orig/" > $1/etc/fstab_
+ mv $1/etc/fstab_ $1/etc/fstab
+ break
+ fi
+
+ test "$junk" = "" -o "$junk" = n -o "$junk" = N && break
+ done
+
+ fi
+
+ echo ""
+
+# if ( cat $1/etc/fstab | grep -v "^#" | grep -q "/var" )
+# then
+# while true
+# do
+# echo "This is mainly for testing purposes."
+# echo -n "Do you want to configure /var as a normal non-tmpfs directory? [N|y] "
+# read junk
+#
+# if test "$junk" = "y" -o "$junk" = "Y"
+# then
+# cat $1/etc/fstab | sed "/.*\/var.*/s/\(.*\)/#\ \1/" > $1/etc/fstab_
+# mv $1/etc/fstab_ $1/etc/fstab
+# break
+# fi
+#
+# test "$junk" = "" -o "$junk" = n -o "$junk" = N && break
+# done
+# fi
+
+ echo ""
+
+ if ( cat $1/etc/ipkg.conf | grep -q ^lists_dir )
+ then
+ while true
+ do
+ echo -e "Wasting RAM is never a good idea.\nOnly say Y if your rootfs is very small in size"
+ echo -n "Do you want to store ipkg package data in RAM? [N|y] "
+ read junk
+
+ if test "$junk" = "" -o "$junk" = n -o "$junk" = N
+ then
+ cat $1/etc/ipkg.conf | sed "/^lists_dir.*/s/\(.*\)/#\ \1/"> $1/etc/ipkg.conf_
+ mv $1/etc/ipkg.conf_ $1/etc/ipkg.conf
+ break
+ fi
+
+ test "$junk" = "y" -o "$junk" = "Y" && break
+ done
+ fi
+
+ echo ""
+
+ if ( cat $1/etc/ipkg.conf | grep -q "^dest sd" )
+ then
+ while true
+ do
+ echo -n "Do you want to keep the SD, CF and /home ipkg install targets? [N|y] "
+ read junk
+
+ if test "$junk" = "" -o "$junk" = n -o "$junk" = N
+ then
+ cat $1/etc/ipkg.conf | sed "/^dest\ \(sd\|cf\|home\).*/s/\(.*\)/#\ \1/" > $1/etc/ipkg.conf_
+ mv $1/etc/ipkg.conf_ $1/etc/ipkg.conf
+ break
+ fi
+
+ test "$junk" = "y" -o "$junk" = "Y" && break
+ done
+ fi
+
+
+ touch "$1/etc/.image_conf.done"
+}
+
# This functions configures the master password for altboot if none is set
set_password() {
mount -o remount,rw /