#!/bin/env sh

PATH=/usr/bin:/usr/sbin:/bin:/sbin

# Must have sysfs mounted for udevtrigger to function.
mountpoint -q /sys || mount -n -t sysfs sysfs /sys
    
# Ideally devtmpfs will be mounted by kernel, we can mount here anyway:
mountpoint -q /dev || mount -n -t devtmpfs tmpfs /dev

mkdir -p /dev/pts /dev/shm
mountpoint -q /dev/shm || mount -n -t tmpfs -o nodev,nosuid tmpfs /dev/shm
mountpoint -q /dev/pts || mount -n -t devpts -o gid=5 devpts /dev/pts

# /run, and various directories within it
mountpoint -q /run || mount -n -t tmpfs -o mode=775 tmpfs /run
mkdir -p /run/lock /run/udev

# "hidepid=1" doesn't appear to take effect on first mount of /proc,
# so we mount it and then remount:
mountpoint -q /proc || mount -n -t proc -o hidepid=1,gid=30 proc /proc
mount -n -t proc -o remount,hidepid=1,gid=30 proc /proc

if [ -d /sys/kernel/security ]; then
  mount -n -t securityfs securityfs /sys/kernel/security || :
fi

if [ -d /sys/firmware/efi/efivars ]; then
  mount -o nosuid,noexec,nodev -t efivarfs efivarfs /sys/firmware/efi/efivars || :
fi
