aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKylie McClain <somasis@exherbo.org>2016-02-10 00:45:39 -0500
committerKylie McClain <somasis@exherbo.org>2016-02-10 00:45:43 -0500
commite854dc758c5ea503a3d3b6193490385e7d16fa7c (patch)
treefeabb14075f5e23cb9c40f53639292473261a8ec
parent70e3729fb072eb73168d849ad22d9df7aff570b8 (diff)
downloadlighter-e854dc758c5ea503a3d3b6193490385e7d16fa7c.tar.gz
lighter-e854dc758c5ea503a3d3b6193490385e7d16fa7c.tar.xz
lighter-e854dc758c5ea503a3d3b6193490385e7d16fa7c.zip
Add init
-rwxr-xr-xskel/init36
1 files changed, 36 insertions, 0 deletions
diff --git a/skel/init b/skel/init
new file mode 100755
index 0000000..fef50fc
--- /dev/null
+++ b/skel/init
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+mkdir /proc /sys
+touch /proc/mounts
+mount -t proc proc /proc
+mount -t devtmpfs devtmpfs /dev
+mount -t sysfs sysfs /sys
+
+args=$(cat /proc/cmdline | tr ' ' '\n' | grep '.*=.*')
+var() {
+ echo "$args" | grep "^$1" | cut -d= -f2
+}
+arg() {
+ echo "$args" | grep -q "^$1$"
+}
+rescue() {
+ sh
+}
+
+root=$(var root)
+
+if [ -z "$root" ];then
+ echo "No root= parameter was passed to kernel. Defaulting to first non-vfat partition." >&2
+ root=$(blkid -o full -s 'TYPE' | grep -v "vfat" | cut -d: -f1)
+fi
+
+mkdir /mnt
+mkdir /mnt/root
+
+fsck -p /mnt/root || rescue
+
+mount -o ro $(findfs "$root") /mnt/root || rescue
+
+umount /proc /sys /dev
+
+exec switch_root /mnt/root /bin/init