1#!/bin/sh
2# Copyright (C) 2011 O.S. Systems Software LTDA.
3# Licensed on MIT
4
5finish_enabled() {
6	return 0
7}
8
9finish_run() {
10	if [ -n "$ROOTFS_DIR" ]; then
11		if [ ! -d $ROOTFS_DIR/dev ]; then
12			fatal "ERROR: There's no '/dev' on rootfs."
13		fi
14
15		info "Switching root to '$ROOTFS_DIR'..."
16
17		debug "Moving /dev, /proc and /sys onto rootfs..."
18		mount --move /dev $ROOTFS_DIR/dev
19		mount --move /proc $ROOTFS_DIR/proc
20		mount --move /sys $ROOTFS_DIR/sys
21
22		cd $ROOTFS_DIR
23		exec switch_root -c /dev/console $ROOTFS_DIR ${bootparam_init:-/sbin/init}
24	else
25		debug "No rootfs has been set"
26	fi
27}
28