diff options
Diffstat (limited to 'nslu2-binary-only/nslu2-unslung-ramdisk/unsling')
-rw-r--r-- | nslu2-binary-only/nslu2-unslung-ramdisk/unsling | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/nslu2-binary-only/nslu2-unslung-ramdisk/unsling b/nslu2-binary-only/nslu2-unslung-ramdisk/unsling index e69de29bb2..f0345aba70 100644 --- a/nslu2-binary-only/nslu2-unslung-ramdisk/unsling +++ b/nslu2-binary-only/nslu2-unslung-ramdisk/unsling @@ -0,0 +1,113 @@ +#!/bin/sh + +# Only do this if we have booted from the ramdisk. + +if [ "`cat /proc/sys/kernel/real-root-dev`" != 256 ] ; then + echo "Cannot unsling an active unslung root partition!" + exit 0 +fi + +# Set or seach for target disk + +if [ $# -gt 1 ] ; then + echo "Usage: $0 [flash|hdd]" + exit 1 +fi + +if [ $# -eq 1 ] ; then + if [ "$1" = "flash" -o "$1" = "hdd" ] ; then + targ=/share/$1/conf + else + echo "Usage: $0 [flash|hdd]" + exit 1 + fi +elif [ -d /share/hdd/conf/lost+found ] ; then + targ=/share/hdd/conf +elif [ -d /share/flash/conf/lost+found ] ; then + targ=/share/flash/conf +else + echo "Cannot locate target root partition" + exit 1 +fi + +echo "Target root partition is $targ" + +echo "Removing conflicts from old unslung root partition." +rm -f $targ/bin/ipkg + +# Unsling it! + +copyfiles=".unslung bin dev etc home lib linuxrc mnt sbin usr" + +echo "Copying ramdisk files to new unslung root partition." +cd / +tar cf - $copyfiles | ( cd $targ ; tar xf - ) + +# Create other required directories. + +echo "Creating required mount points and empty directories." + +rm -rf $targ/tmp && mkdir $targ/tmp + +[ ! -d $targ/share ] && mkdir $targ/share +[ ! -d $targ/share/flash ] && mkdir $targ/share/flash +[ ! -d $targ/share/flash/conf ] && mkdir $targ/share/flash/conf +[ ! -d $targ/share/flash/data ] && mkdir $targ/share/flash/data +[ ! -d $targ/share/hdd ] && mkdir $targ/share/hdd +[ ! -d $targ/share/hdd/conf ] && mkdir $targ/share/hdd/conf +[ ! -d $targ/share/hdd/data ] && mkdir $targ/share/hdd/data +[ ! -d $targ/mnt ] && mkdir $targ/mnt +[ ! -d $targ/mnt/backup ] && mkdir $targ/mnt/backup +[ ! -d $targ/mnt/repair ] && mkdir $targ/mnt/repair +[ ! -d $targ/mnt/tmpmnt ] && mkdir $targ/mnt/tmpmnt +[ ! -d $targ/proc ] && mkdir $targ/proc +[ ! -d $targ/upload ] && mkdir $targ/upload +[ ! -d $targ/var ] && mkdir $targ/var +[ ! -d $targ/var/empty ] && mkdir $targ/var/empty +[ ! -d $targ/var/lock ] && mkdir $targ/var/lock +[ ! -d $targ/var/log ] && mkdir $targ/var/log +[ ! -d $targ/var/run ] && mkdir $targ/var/run +[ ! -d $targ/var/tmp ] && mkdir $targ/var/tmp + +# Ensure /unslung is there. + +if [ ! -d $targ/unslung ] ; then + + echo "Creating new /unslung directory on unslung root partition." + + mkdir $targ/unslung + +else + echo "Preserving existing /unslung directory on unslung root partition." +fi + +# Ensure /root is there. + +if [ ! -d $targ/root ] ; then + + echo "Creating new /root directory on unslung root partition." + + mkdir $targ/root + +else + echo "Preserving existing /root directory on unslung root partition." +fi + +# Ensure /opt is there. + +if [ ! -d $targ/opt ] ; then + + echo "Creating new /opt directory on unslung root partition." + + mkdir $targ/opt + +else + echo "Preserving existing /opt directory on unslung root partition." +fi + +echo "Unslinging any default root passwords." + +[ -f $targ/passwd ] && sed -i -e 's/^root:WeeOvKUvbQ6nI:0:0:root:/root:t1PLUeOinN\/eI:0:0:root:/' $targ/passwd +[ -f $targ/usr/local/passwd ] && sed -i -e 's/^root:WeeOvKUvbQ6nI:0:0:root:/root:t1PLUeOinN\/eI:0:0:root:/' $targ/usr/local/passwd + +exit 0 |