Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/busybox sh
- echo "Loading, please wait..."
- # /bin/mount, otherwise busybox builtin would get used
- echo -n "Mounting /sys and /proc..."
- /bin/mount -t sysfs -o nodev,noexec,nosuid none /sys
- /bin/mount -t proc -o nodev,noexec,nosuid none /proc
- echo "Done."
- # Export relevant variables
- export TARGET=/root
- echo -n "Loading essential drivers..."
- if [ -e /etc/modules ]; then
- cat /etc/modules | while read m; do
- # Skip empty lines
- if [ -z "$m" ]; then
- continue
- fi
- # Skip comments - d?ash removes whitespace prefix
- com=$(printf "%.1s" "${m}")
- if [ "$com" = "#" ]; then
- continue
- fi
- modprobe $m
- done
- fi
- echo "Done."
- # pxelinux sets BOOTIF to 01-??-??-??-??-??-?? (MAC)
- bootif_mac=""
- IFS='-'
- for x in ${BOOTIF} ; do
- bootif_mac="$bootif_mac:$x"
- done
- unset IFS
- bootif_mac=${bootif_mac#:*:}
- # find DEVICE to bootif_mac
- for device in /sys/class/net/* ; do
- if [ -f "$device/address" ]; then
- current_mac=$(cat "$device/address")
- if [ "$bootif_mac" = "$current_mac" ]; then
- DEVICE=${device##*/}
- break
- fi
- fi
- done
- echo "Starting network..."
- # Loopback
- ifconfig lo up
- # Ethernet
- ifconfig ${DEVICE} up
- # DHCP
- udhcpc -i ${DEVICE} -q -s /sbin/setup-net
- # source output of script /sbin/setup-net (HOSTNAME, SERVER)
- . /tmp/net.conf
- echo "Network Done."
- echo -n "Mounting root file system..."
- NFSOPTS="nfsvers=3,udp,nolock,retrans=10"
- # mount the xino dir
- /bin/mount -t tmpfs -o size=16M none /aufs/xino
- # mount the clients specific dir
- /bin/mount -t nfs -o rw,${NFSOPTS} ${SERVER}:/target/export/${HOSTNAME} /aufs/private
- # mount the clients general dir
- /bin/mount -t nfs -o ro,${NFSOPTS} ${SERVER}:/target/export/clients /aufs/clients
- # mount the server root dir
- /bin/mount -t nfs -o ro,${NFSOPTS} ${SERVER}:/target/ /aufs/server
- # do the union
- /bin/mount -t aufs -o noplink,xino=/aufs/xino/root,dirs=/aufs/private=rw:/aufs/clients=ro+wh:/aufs/server=ro none ${TARGET}
- echo "Done."
- # Kludge for strange aufs behaviour
- # whithout this, mounted directories will be lost on command-completion
- # don't ask me why this works
- echo "ls /root > /dev/null"
- /bin/mount --move /aufs/xino ${TARGET}/aufs/xino
- /bin/mount --move /aufs/private ${TARGET}/aufs/private
- /bin/mount --move /aufs/clients ${TARGET}/aufs/clients
- /bin/mount --move /aufs/server ${TARGET}/aufs/server
- # Move virtual filesystems over to the real filesystem
- /bin/mount --move /sys ${TARGET}/sys
- /bin/mount --move /proc ${TARGET}/proc
- # Chain to real filesystem
- exec /bin/run-init ${TARGET} /sbin/init "$@" <${TARGET}/dev/console >${TARGET}/dev/console
Advertisement
Add Comment
Please, Sign In to add comment