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