blob: 8db076f4ba65f74d6585c154dfe9f2944c413125 [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
6mount -o remount,rw /
7
8mkdir -p /proc
9mkdir -p /sys
10mkdir -p /run
11mkdir -p /var/run
12
13mount -t proc proc /proc
14mount -t sysfs sysfs /sys
15
16[ -z "$CONSOLE" ] && CONSOLE="/dev/console"
17
Andrew Geissler87f5cff2022-09-30 13:13:31 -050018BASE_OVERLAY_ETC_DIR={OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc
19UPPER_DIR=$BASE_OVERLAY_ETC_DIR/upper
20WORK_DIR=$BASE_OVERLAY_ETC_DIR/work
21LOWER_DIR=$BASE_OVERLAY_ETC_DIR/lower
22
Andrew Geissler595f6302022-01-24 19:11:47 +000023mkdir -p {OVERLAYFS_ETC_MOUNT_POINT}
Andrew Geissler9aee5002022-03-30 16:27:02 +000024if mount -n -t {OVERLAYFS_ETC_FSTYPE} \
25 -o {OVERLAYFS_ETC_MOUNT_OPTIONS} \
26 {OVERLAYFS_ETC_DEVICE} {OVERLAYFS_ETC_MOUNT_POINT}
Andrew Geissler595f6302022-01-24 19:11:47 +000027then
Andrew Geissler87f5cff2022-09-30 13:13:31 -050028 mkdir -p $UPPER_DIR
29 mkdir -p $WORK_DIR
30
31 if {OVERLAYFS_ETC_EXPOSE_LOWER}; then
32 mkdir -p $LOWER_DIR
33
34 # provide read-only access to original /etc content
35 mount -o bind,ro /etc $LOWER_DIR
36 fi
37
Andrew Geissler9aee5002022-03-30 16:27:02 +000038 mount -n -t overlay \
Andrew Geissler87f5cff2022-09-30 13:13:31 -050039 -o upperdir=$UPPER_DIR \
Andrew Geissler9aee5002022-03-30 16:27:02 +000040 -o lowerdir=/etc \
Andrew Geissler87f5cff2022-09-30 13:13:31 -050041 -o workdir=$WORK_DIR \
Andrew Geissler9aee5002022-03-30 16:27:02 +000042 -o index=off,xino=off,redirect_dir=off,metacopy=off \
Andrew Geissler87f5cff2022-09-30 13:13:31 -050043 $UPPER_DIR /etc || \
Andrew Geissler9aee5002022-03-30 16:27:02 +000044 echo "PREINIT: Mounting etc-overlay failed!"
Andrew Geissler595f6302022-01-24 19:11:47 +000045else
46 echo "PREINIT: Mounting </data> failed!"
47fi
48
49echo "PREINIT: done; starting </sbin/init>"
50exec {SBIN_INIT_NAME}