#!/bin/bash

# sourcing our current rc.conf requires this to be a bash script
. /usr/lib/rc/functions

mount_sysfs(){
    ck_verbose && substat "Mounting /sys"
    mountpoint -q /sys     || mount -t sysfs sys /sys -o nosuid,noexec,nodev
    ck_verbose && substat "Mounting /sys/kernel/security"
    mountpoint -q /sys/kernel/security || mount -n -t securityfs securityfs /sys/kernel/security
    if [ -d /sys/firmware/efi ]; then
        ck_verbose && substat "Mounting /sys/firmware/efi"
        (mountpoint -q /sys/firmware/efi/efivars || mount -n -t efivarfs -o ro efivarfs /sys/firmware/efi/efivars)
    fi
}

case "$1" in
    start)
        stat_busy "Mounting sys filesystem"
        mount_sysfs
        add_daemon sysfs
        stat_done
        ;;
    *)
        echo "usage: $0 {start}"
        exit 1
        ;;
esac
