aboutsummaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-03-23 10:29:27 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-03-23 10:29:27 +0200
commitb8f3927e48467ecf196e91a95dd29c4f409709d8 (patch)
treeeea5c59b5e1ad81b9cd03d9fb3b5faa1dc09ff82 /init
Initial bootstrap script
Diffstat (limited to 'init')
-rwxr-xr-xinit49
1 files changed, 49 insertions, 0 deletions
diff --git a/init b/init
new file mode 100755
index 0000000..fdcb318
--- /dev/null
+++ b/init
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+# Init script for build2 buildos.
+#
+# Loosely based on the one that comes in Debian initrd.img (since we are
+# using its kernel image as is).
+#
+trap "exit 1" ERR
+set -o errtrace # Trap in functions.
+
+# Note: diagnostics goes to stdout.
+#
+function info () { echo "$*"; }
+function error () { info "$*"; exit 1; }
+
+export PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+# One would expect rootflags=size=1g to work but it doesn't (perhaps init
+# is expected to interpret it)?
+#
+mount -o remount,size=1G /
+
+mkdir -p /sys /proc
+mount -t sysfs -o nodev,noexec,nosuid sysfs /sys
+mount -t proc -o nodev,noexec,nosuid proc /proc
+
+info "init starting up..."
+
+mount -t devtmpfs -o nosuid,mode=0755 udev /dev
+mkdir -p /dev/pts
+mount -t devpts -o noexec,nosuid,gid=5,mode=0620 devpts /dev/pts || true
+
+mkdir -p /run
+mount -t tmpfs -o "noexec,nosuid,size=10%,mode=0755" tmpfs /run
+
+mkdir -p /tmp
+mount -t tmpfs -o "nodev,nosuid,size=10%,mode=1777" tmpfs /tmp
+
+cmdline="$(cat /proc/cmdline)"
+
+info "boot cmdline: $cmdline"
+
+sleep 2
+
+# --machine-id
+#
+#exec /lib/systemd/systemd #</dev/console >/dev/console 2>&1
+
+exec /bin/bash