diff options
author | Rod Whitby <rod@whitby.id.au> | 2006-01-04 12:08:04 +0000 |
---|---|---|
committer | OpenEmbedded Project <openembedded-devel@lists.openembedded.org> | 2006-01-04 12:08:04 +0000 |
commit | 5eccfb8fa47f3bb6a55252bbe4cc7e108f9c410d (patch) | |
tree | 52ce096c38620e7e8d351746f544af9a75d240f0 /packages/nslu2-binary-only/unslung-rootfs-2.3r63 | |
parent | de6622c1519b1a6c6de00009546e3a7122a228d8 (diff) |
unslung: Usability updates for Unslung 6.x - ipkg prints message when booted on flash, motd prints at login indicating status of on-disk or on-flash, status appears on home page in web interface, unsling now asks for root password, and some additional checks are made by unsling to avoid known problems that can prevent a successful unsling, added new unslung logo.
Diffstat (limited to 'packages/nslu2-binary-only/unslung-rootfs-2.3r63')
5 files changed, 153 insertions, 15 deletions
diff --git a/packages/nslu2-binary-only/unslung-rootfs-2.3r63/ipkg-fl b/packages/nslu2-binary-only/unslung-rootfs-2.3r63/ipkg-fl new file mode 100755 index 0000000000..514ccd4ec8 --- /dev/null +++ b/packages/nslu2-binary-only/unslung-rootfs-2.3r63/ipkg-fl @@ -0,0 +1,11 @@ +#! /bin/sh +echo +echo "Error: The ipkg command cannot currently be used because this" +echo "system is running from its internal flash; it is not currently" +echo "\"uNSLUng\" to an external disk or flash device." +echo +echo "Please complete the process of \"unslinging\" this system, or" +echo "resolve the issues that did not permit it to boot from the" +echo "external device before installing any ipkg packages or updates." +echo +exit 1 diff --git a/packages/nslu2-binary-only/unslung-rootfs-2.3r63/linuxrc b/packages/nslu2-binary-only/unslung-rootfs-2.3r63/linuxrc index cc53d447c3..d8a0e5d06c 100755 --- a/packages/nslu2-binary-only/unslung-rootfs-2.3r63/linuxrc +++ b/packages/nslu2-binary-only/unslung-rootfs-2.3r63/linuxrc @@ -15,8 +15,8 @@ cnt=20 while [ $cnt -gt 0 ] ; do echo -ne "\r$cnt " sleep 1 - [ -f /proc/hdd_sdb ] && cnt=0 - [ -f /proc/hdd_sda ] && cnt=0 + [ -e /.sda1root -a -f /proc/hdd_sda ] && cnt=0 + [ -e /.sdb1root -a -f /proc/hdd_sdb ] && cnt=0 cnt=`expr $cnt - 1` done echo @@ -25,10 +25,10 @@ sleep 5 mounted= -for prefroot in sdb1 sda1 ; do - if [ -z "$mounted" ] ; then +for prefroot in sda1 sdb1 ; do + if [ -z "$mounted" -a -e /.${prefroot}root ] ; then if /bin/mount -rt ext3 /dev/$prefroot /mnt ; then - if [ -x /mnt/bin/init ] ; then + if [ -e /mnt/.${prefroot}root -a -x /mnt/bin/init ] ; then /bin/echo "Root filesystem will be mounted from /dev/$prefroot ..." mounted=/mnt else diff --git a/packages/nslu2-binary-only/unslung-rootfs-2.3r63/motd-fl b/packages/nslu2-binary-only/unslung-rootfs-2.3r63/motd-fl new file mode 100644 index 0000000000..aafcd21cb5 --- /dev/null +++ b/packages/nslu2-binary-only/unslung-rootfs-2.3r63/motd-fl @@ -0,0 +1,11 @@ + +Welcome to Unslung @v@ + + -------- NOTE: RUNNING FROM INTERNAL FLASH -------- + +This system is currently running from the internal flash memory, +it has NOT booted up into "unslung" mode from an external drive. + +In this mode, very few services are running, and available disk +space is extremely limited. This mode is normally only used +for initial installation, and system maintenance and recovery. diff --git a/packages/nslu2-binary-only/unslung-rootfs-2.3r63/motd-un b/packages/nslu2-binary-only/unslung-rootfs-2.3r63/motd-un new file mode 100644 index 0000000000..5439b08be6 --- /dev/null +++ b/packages/nslu2-binary-only/unslung-rootfs-2.3r63/motd-un @@ -0,0 +1,4 @@ + +Welcome to Unslung @v@ + + ---------- NOTE: THIS SYSTEM IS CURRENTLY UNSLUNG ---------- diff --git a/packages/nslu2-binary-only/unslung-rootfs-2.3r63/unsling b/packages/nslu2-binary-only/unslung-rootfs-2.3r63/unsling index bed1789a6f..3c25316751 100755 --- a/packages/nslu2-binary-only/unslung-rootfs-2.3r63/unsling +++ b/packages/nslu2-binary-only/unslung-rootfs-2.3r63/unsling @@ -1,23 +1,30 @@ #!/bin/sh -usage="Usage: $0 disk1|disk2" - -# Set target disk +usage="Usage: $0 [-nopw] disk1|disk2" +nopw=0 if [ $# -gt 1 ] ; then - echo $usage - exit 1 + if [ "$1" = "-nopw" ] ; then + nopw=1 + shift + fi fi +# Set target disk + if [ $# -eq 1 ] ; then if [ "$1" = "disk1" ] ; then mtch="/dev/sdb1 /share/hdd/data ext3 rw 0 0" targ=/share/hdd/data - flag=.sda1root + targconf=/share/hdd/conf + flag=.sdb1root + htmlinfo="disk1, /dev/sdb1" elif [ "$1" = "disk2" ] ; then mtch="/dev/sda1 /share/flash/data ext3 rw 0 0" targ=/share/flash/data - flag=.sdb1root + targconf=/share/flash/conf + flag=.sda1root + htmlinfo="disk2, /dev/sda1" else echo $usage exit 1 @@ -27,13 +34,57 @@ else exit 1 fi +# Check that we can unsling at all! An unsling operation creates a new +# rootfs, but it also marks the flash rootfs (with a flag file such as +# ".sda1root") so that subsequent boots do not create the "var.state" +# and "dev.state" mounts. Without those mounts, though, an attempt to +# unsling will write a new rootfs on the target with an empty /dev +# directory, which doesnt' work really well. So this check is all about +# making sure that we are in a state in which we are capable of +# performing the unsling operation. + +echo "Checking if able to unsling..." +echo +m1="/dev/root /dev.state jffs2 rw 0 0" +m2="/dev/root /var.state jffs2 rw 0 0" +if ! grep "$m1" /proc/mounts >/dev/null 2>&1 || ! grep "$m2" /proc/mounts >/dev/null 2>&1 ; then + echo "Error: This system is unable to properly unsling because certain" + echo "required mounts (dev.state and/or var.state) are not available." + echo "This is most probably because you have already unslung this system." + echo + + if [ -f /.sda1root ] ; then + rm -f /.sda1root + elif [ -f /.sdb1root ] ; then + rm -f /.sdb1root + elif [ -f /.sda2root ] ; then + rm -f /.sda2root + elif [ -f /.sdb2root ] ; then + rm -f /.sdb2root + else + echo "However, in this case, the flags that indicate an already-unslung" + echo "system seem to be missing. Try restarting your NSLU2 to correct," + echo "but if the problem persists, try re-flashing your NSLU2." + exit 1 + fi + echo "The flags that indicate an already-unslung system have now been" + echo "removed and the required mounts should now become present after" + echo "reboot of the NSLU2." + echo + echo "1) Please unplug all drives from the NSLU2," + echo "2) reboot," + echo "3) and retry the unslinging process." + exit 1 +fi + # Check it's a real mount point -echo "Waiting for $targ" +echo "Waiting for $targ ..." CNT=120 while [ $CNT -gt 0 ] do if grep "$mtch" /proc/mounts >/dev/null 2>&1 ; then + echo echo "Target disk is $targ" CNT=-1 else @@ -43,10 +94,52 @@ do fi done if [ $CNT -eq 0 ] ; then - echo "Error: $targ is not a mounted disk" + echo + echo "Error: $targ ($htmlinfo) is not a mounted disk" exit 1 fi +# Do a quick sanity check to make sure we're unslinging to a disk that's been +# formatted by the Linksys code. + +echo "Checking that $targ has been properly formatted..." +if ! [ -d $targ/public ] || ! [ -f $targconf/.dongle ] || ! [ -f $targconf/passwd ] ; then + echo + echo "Error: $targ does not appear to have been formatted by the" + echo "Linksys formatting utility. Please go to the web interface," + echo "and format the drive before unslinging." + exit 1 +fi + +echo "Checking that $targ is clean..." +if [ -f $targ/.unslung ] ; then + echo + echo "Error: $targ appears to have already been unslung to:" + cat $targ/.unslung + echo "Please go to the web interface, and format the drive before" + echo "unslinging." + echo + echo "(Or, if you wish to unsling without removing the current root" + echo "filesystem, simply remove the file $targ/.unslung and retry" + echo "the unsling -- but beware, you enter uncharted territory!)" + exit 1 +fi + +# Change the root password +if [ "$nopw" = 0 ] ; then + echo + echo "Please enter the new root password. This will be the new root" + echo "password used when the NSLU2 boots up with or without disks" + echo + passwd + if [ $? != 0 ] ; then + echo "Error setting password." + exit 1 + fi + cp /etc/passwd /usr/local/passwd + cp /etc/passwd $targconf/passwd +fi + # Start at the root directory cd / @@ -60,7 +153,8 @@ fi # Copy the complete rootfs to the target. -echo "Copying the complete rootfs from / to $targ." +echo +echo "Copying the complete rootfs from / to $targ ..." /usr/bin/find / -print0 -mount | /usr/bin/cpio -p -0 -d -m -u $targ rm -rf $targ/dev ; mv $targ/dev.state $targ/dev rm -rf $targ/var ; mv $targ/var.state $targ/var @@ -75,6 +169,16 @@ fi echo "Linking /usr/bin/ipkg executable on target disk." rm -f $targ/usr/bin/ipkg ; ln -s /usr/bin/ipkg-cl $targ/usr/bin/ipkg +echo "Linking /etc/motd to the unslung motd on target disk." +rm -f $targ/etc/motd ; ln -s /etc/motd-un $targ/etc/motd + +echo "Updating /home/httpd/html/home.htm with target disk info." +sedcommand="s#Running.from.Internal.Flash#Unslung to $htmlinfo#" +rm -f $targ/home/httpd/html/home.htm_bak +cp $targ/home/httpd/html/home.htm $targ/home/httpd/html/home.htm_bak +sed "$sedcommand" $targ/home/httpd/html/home.htm_bak > $targ/home/httpd/html/home.htm +chmod 644 $targ/home/httpd/html/home.htm + # Create the boot flag file. rm -f /.sd??root $targ/.sd??root @@ -83,4 +187,12 @@ echo "Creating /$flag to direct switchbox to boot from $targ." echo > /$flag echo > $targ/$flag +# Done + +echo +echo "Unsling complete." +echo +echo "Leave the device $htmlinfo plugged in, and reboot" +echo "in order to boot this system up into unslung mode." + exit 0 |