diff options
author | Patrick Simianer <p@simianer.de> | 2013-01-22 11:42:48 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2013-01-22 11:42:48 +0100 |
commit | ad228600dba989475744f9a2142ca4d53ee8cdbe (patch) | |
tree | 120f633b91795749c376cdacc60ae80ecba68eae /init |
init
Diffstat (limited to 'init')
-rwxr-xr-x | init | 66 |
1 files changed, 66 insertions, 0 deletions
@@ -0,0 +1,66 @@ +#!/bin/busybox sh + +#set -x + +ROOT=/dev/disk/by-label/rootfs +HOME=/dev/disk/by-uuid/092fdc4a-4356-47d9-9272-9a5f58e33bbf + +prep_dev() +{ + for opt in `cat /proc/cmdline`; do + name=$(echo $opt | cut -d'=' -f 1) + if [ $name == "root" ] || [ $name == "resume" ] || [ $name == "crypt_part" ]; then + type=$(echo $opt | cut -d'=' -f 2) + id=$(echo $opt | cut -d'=' -f 3) + if [ $type == LABEL ]; then + prefix="/dev/disk/by-label"; + elif [ $type == UUID ]; then + prefix="/dev/disk/by-uuid" + fi + mkdir -p $prefix + full="$prefix/$id" + if [ ! -e $full ]; then + ln -s $(findfs "$type=$id") $full + fi + fi + done +} + +rescue_shell() +{ + echo "Something went wrong. Dropping you to a shell." + busybox --install -s + exec /bin/sh +} + +cryptsetup_do() +{ + echo "cryptsetup $1 $2" + cryptsetup -T 3 luksOpen $1 $2 +} + +mount_root() +{ + echo "mount root $1" + mount -o ro $1 /newroot +} + +# Mount the /dev, /proc and /sys filesystems. +mount -t devtmpfs none /dev +mount -t proc none /proc +mount -t sysfs none /sys + +# Do your stuff here. +prep_dev +cryptsetup_do $HOME home +resume +mount_root $ROOT || rescue_shell + +# Clean up. +umount /dev +umount /proc +umount /sys + +# Boot the real thing. +exec switch_root /newroot /sbin/init + |