#!/bin/sh
# system-restart: re-enter system-init without rebooting
#
# (C) James Budiono 2012, 2013
# License: GNU GPL Version 3 or later
#
# For this script to work, inittab must be already in "restart" state
# script must be exec-ed from terminal as PID 1.
#
### configuration
BLANK_SFS=/usr/share/blank.sfs
MODULE_SFS=kernel-modules.sfs

### main
[ $$ -ne 1 ] && echo "Must be running as init; please re-exec script as PID 1" && exit
/bin/mount -t proc proc /proc
/bin/mount -o remount,rw /
rm /init; /bin/ln -s /sbin/system-init /init	# this is required by busybox switch_root 
! [ -e /$MODULE_SFS ] && /bin/ln -s $BLANK_SFS /$MODULE_SFS
/bin/umount /proc
/bin/umount /dev
exec /init
