Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | echo "PREINIT: Start" |
| 4 | |
| 5 | PATH=/sbin:/bin:/usr/sbin:/usr/bin |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 6 | if {CREATE_MOUNT_DIRS}; then |
| 7 | mount -o remount,rw / |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 8 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 9 | mkdir -p /proc |
| 10 | mkdir -p /sys |
| 11 | mkdir -p /run |
| 12 | mkdir -p /var/run |
| 13 | mkdir -p {OVERLAYFS_ETC_MOUNT_POINT} |
| 14 | fi |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 15 | |
| 16 | mount -t proc proc /proc |
| 17 | mount -t sysfs sysfs /sys |
| 18 | |
| 19 | [ -z "$CONSOLE" ] && CONSOLE="/dev/console" |
| 20 | |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 21 | BASE_OVERLAY_ETC_DIR={OVERLAYFS_ETC_MOUNT_POINT}/overlay-etc |
| 22 | UPPER_DIR=$BASE_OVERLAY_ETC_DIR/upper |
| 23 | WORK_DIR=$BASE_OVERLAY_ETC_DIR/work |
| 24 | LOWER_DIR=$BASE_OVERLAY_ETC_DIR/lower |
| 25 | |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 26 | if mount -n -t {OVERLAYFS_ETC_FSTYPE} \ |
| 27 | -o {OVERLAYFS_ETC_MOUNT_OPTIONS} \ |
| 28 | {OVERLAYFS_ETC_DEVICE} {OVERLAYFS_ETC_MOUNT_POINT} |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 29 | then |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 30 | 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 Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 40 | mount -n -t overlay \ |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 41 | -o upperdir=$UPPER_DIR \ |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 42 | -o lowerdir=/etc \ |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 43 | -o workdir=$WORK_DIR \ |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 44 | -o index=off,xino=off,redirect_dir=off,metacopy=off \ |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 45 | $UPPER_DIR /etc || \ |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 46 | echo "PREINIT: Mounting etc-overlay failed!" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 47 | else |
| 48 | echo "PREINIT: Mounting </data> failed!" |
| 49 | fi |
| 50 | |
| 51 | echo "PREINIT: done; starting </sbin/init>" |
| 52 | exec {SBIN_INIT_NAME} |