#!/bin/sh # Installed as /sbin/init on DFS CD initrdloc=/initrd newrdloc=/opt/dfsruntime/runtimemnt newrdfiles=/opt/dfsruntime/runtimerd cleanup_union() { while read to; do umount "$to" done < /opt/dfsruntime/binds } do_ramdisk_aufs() { while read to; do mkdir -p "$newrdloc"/"$to" chown --reference "$to" "$newrdloc"/"$to" chmod --reference "$to" "$newrdloc"/"$to" mount -n -t aufs -o br:"$newrdloc"/"$to":"$to" none "$to" || { cleanup_union; return 1; } done < /opt/dfsruntime/binds } do_ramdisk_unionfs() { while read to; do mkdir -p "$newrdloc"/"$to" chown --reference "$to" "$newrdloc"/"$to" chmod --reference "$to" "$newrdloc"/"$to" mount -n -t unionfs -o dirs="$newrdloc"/"$to":"$to" none "$to" || { cleanup_union; return 1; } done < /opt/dfsruntime/binds } do_ramdisk_copy() { while read to; do cp -a "$to" "$newrdloc"/ mount -n --bind "$newrdloc"/"$to" "$to" done < /opt/dfsruntime/binds } if [ -f $newrdloc/etc/fstab ] ; then echo " *** DFS startup: system already running, calling real init" exec /sbin/init.real "$@" return 1 fi echo "" echo " *** Debian From Scratch CD initializing ***" echo "PID: $$" cd / echo -n "Creating new runtime ramdisk: " mount -n -t tmpfs none $newrdloc echo $newrdloc echo -n "Populating runtime ramdisk: " do_ramdisk_aufs || do_ramdisk_unionfs || do_ramdisk_copy echo "done." echo -n "Initializing configuration files: /etc/fstab" echo "proc /proc proc defaults 0 0" > /etc/fstab echo "." echo "" echo " *** Now booting system ***" exec /sbin/init.real "$@"