#!/bin/sh -e

case $(auto-ostype) in
FreeBSD)
    auto-fusefs-install
    pkg remove -y automount     # Duplicates devd-mount actions
    pkg install -y devd-mount npmount qmediamanager
    cat << EOM > /usr/local/etc/automount.conf
FM=/usr/local/bin/qmediamanager
MNT_GROUP=operator
MNT_MODE=775
EOM
    service devd restart
    ;;

NetBSD)
    auto-fusefs-install
    # These may not be available in binary packages yet
    # Install from wip if necessary
    pkgin -y install devpub-mount npmount qmediamanager || true
    cp -f $(auto-pkgsrc-prefix)/share/devpub-mount/03-devpub-mount /libexec/devpubd-hooks/
    chmod 555 /libexec/devpubd-hooks/03-devpub-mount
    auto-enable-service devpubd $0
    ;;

*)
    auto-unsupported-os $0
    exit 1
    ;;

esac
