#!/bin/sh

. /etc/prplconfig

path_is_absolute() {
    case "$1" in
        /*)
            true;;
        *) false;;
    esac
}
do_mount_read_only_dirs() {
    for dir in $CONFIG_SAH_BOARD_CONFIGURATOR_READONLY_DIR_LIST; do
        path_in_rom="/rom/${dir#/}"
        if path_is_absolute "$dir" && test -d "$path_in_rom"
        then
            mount --bind -o ro "$path_in_rom" "$dir"
        else
            echo "error $dir is not a valid directory"
        fi
    done
}

boot_hook_add preinit_main do_mount_read_only_dirs
