blob: b05e3957a38252b73e57bb2447a6d0f3b5b60b0c [file] [log] [blame]
Andrew Geissler595f6302022-01-24 19:11:47 +00001#!/bin/sh
2
3echo "PREINIT: Start"
4
5PATH=/sbin:/bin:/usr/sbin:/usr/bin
Patrick Williams73bd93f2024-02-20 08:07:48 -06006if {CREATE_MOUNT_DIRS}; then
7 mount -o remount,rw /
Andrew Geissler595f6302022-01-24 19:11:47 +00008
Patrick Williams73bd93f2024-02-20 08:07:48 -06009 mkdir -p /proc
10 mkdir -p /sys
11 mkdir -p /run
12 mkdir -p /var/run
13 mkdir -p {OVERLAYFS_ETC_MOUNT_POINT}
14fi
Andrew Geissler595f6302022-01-24 19:11:47 +000015
16mount -t proc proc /proc
17mount -t sysfs sysfs /sys
18
19[ -z "$CONSOLE" ] && CONSOLE="/dev/console"
20
Andrew Geissler87f5cff2022-09-30 13:13:31 -050021BASE_OVERLAY_ETC_DIR={OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc
22UPPER_DIR=$BASE_OVERLAY_ETC_DIR/upper
23WORK_DIR=$BASE_OVERLAY_ETC_DIR/work
24LOWER_DIR=$BASE_OVERLAY_ETC_DIR/lower
25
Andrew Geissler9aee5002022-03-30 16:27:02 +000026if mount -n -t {OVERLAYFS_ETC_FSTYPE} \
27 -o {OVERLAYFS_ETC_MOUNT_OPTIONS} \
28 {OVERLAYFS_ETC_DEVICE} {OVERLAYFS_ETC_MOUNT_POINT}
Andrew Geissler595f6302022-01-24 19:11:47 +000029then
Andrew Geissler87f5cff2022-09-30 13:13:31 -050030 mkdir -p $UPPER_DIR
31 mkdir -p $WORK_DIR
32
33 if {OVERLAYFS_ETC_EXPOSE_LOWER}; then
34 mkdir -p $LOWER_DIR
35
36 # provide read-only access to original /etc content
37 mount -o bind,ro /etc $LOWER_DIR
38 fi
39
Andrew Geissler9aee5002022-03-30 16:27:02 +000040 mount -n -t overlay \
Andrew Geissler87f5cff2022-09-30 13:13:31 -050041 -o upperdir=$UPPER_DIR \
Andrew Geissler9aee5002022-03-30 16:27:02 +000042 -o lowerdir=/etc \
Andrew Geissler87f5cff2022-09-30 13:13:31 -050043 -o workdir=$WORK_DIR \
Andrew Geissler9aee5002022-03-30 16:27:02 +000044 -o index=off,xino=off,redirect_dir=off,metacopy=off \
Andrew Geissler87f5cff2022-09-30 13:13:31 -050045 $UPPER_DIR /etc || \
Andrew Geissler9aee5002022-03-30 16:27:02 +000046 echo "PREINIT: Mounting etc-overlay failed!"
Andrew Geissler595f6302022-01-24 19:11:47 +000047else
48 echo "PREINIT: Mounting </data> failed!"
49fi
50
51echo "PREINIT: done; starting </sbin/init>"
52exec {SBIN_INIT_NAME}