forked from ghostbsd/ghostbsd-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh.in
52 lines (37 loc) · 1.25 KB
/
init.sh.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
PATH="/rescue"
if [ "`ps -o command 1 | tail -n 1 | ( read c o; echo ${o} )`" = "-s" ]; then
echo "==> Running in single-user mode"
SINGLE_USER="true"
fi
echo "==> Remount rootfs as read-write"
mount -u -w /
echo "==> Make mountpoints"
mkdir -p /cdrom /memdisk /sysroot
echo "Waiting for GhostBSD media to initialize"
while : ; do
[ -e "/dev/iso9660/GHOSTBSD" ] && echo "found /dev/iso9660/GHOSTBSD" && break
sleep 1
done
echo "==> Mount cdrom"
mount_cd9660 /dev/iso9660/@VOLUME@ /cdrom
echo "==> mdmfs /cdrom/data/system.uzip in /sysroot"
mdmfs -P -F /cdrom/data/system.uzip -o ro md.uzip /sysroot
echo "==> Mount swap-based memdisk"
MEMDISK_SIZE="$(($(sysctl -n hw.usermem) / 1024 / 1024 / 2))"
mdmfs -s "${MEMDISK_SIZE}m" md /memdisk || exit 1
echo "==> tar zxfv /cdrom/data/mfs.tgz -C /memdisk"
tar zxf /cdrom/data/mfs.tgz -C /memdisk
while read uniondir; do
mount_nullfs /memdisk/${uniondir} /sysroot/${uniondir}
done < /cdrom/data/uniondirs
echo "==> mount_nullfs in /cdrom in /sysroot"
mount_nullfs -o ro /cdrom /sysroot/cdrom
echo "==> Mount devfs /sysroot/dev"
mount -t devfs devfs /sysroot/dev
if [ "$SINGLE_USER" = "true" ]; then
echo "Starting interactive shell in temporary rootfs ..."
sh
fi
kenv init_shell="/bin/sh"
exit 0