All pastes #718516 Raw Edit

Unnamed

public text v1 · immutable
#718516 ·published 2007-09-28 14:05 UTC
rendered paste body
#!/bin/bash
# /sbin/preinit.sh

error() {
    echo $1
    echo "Stalling."
    sleep 999999 # arbitrary longtime
}

if [ -z $HOSTNAME ] ; then
  error "Error hostname not set"
fi

if ! mount -n -t proc proc /proc ; then
  error "/proc failed to mount. Be sure it exists!"
fi

for pp in $(</proc/cmdline) ; do
  if [ "${pp:0:8}" = "nfsroot=" ] ; then
    pp=${pp:8}
    NFSBASE=${pp%/*}
    break
  fi
done

umount /proc

if [ -z "$NFSBASE" ] ; then
  error "Unable to extract NFSBASE. Whoops."
fi

if mount -t nfs -o nolock $NFSBASE/$HOSTNAME /private ; then
  echo "Mounted /private"
else
  error "/private failed to mount. Check settings!"
fi

for n in /private/*/ ; do
  d=${n#/*/}
  m=${n%*/}
  d=${d%*/}
  echo "Mounting $m to /$d"
  if [ -d /$d ] ; then
    if ! mount --bind $m /$d ; then
      error "failed to mount $m on /$d"
    fi
  else
    echo "Skipping $m, /$d doesn't exist!"
  fi
done

echo "Exit preinit, start init..."
exec /sbin/init