#!/bin/sh -e

##########################################################################
#   Title:
#       Optional, defaults to the name of the script sans extention
#
#   Section:
#       8
#
#   Synopsis:
#       
#   Description:
#       
#   Arguments:
#       
#   Returns:
#
#   Examples:
#
#   Files:
#
#   Environment:
#
#   See also:
#       
#   History:
#   Date        Name        Modification
#   2024-11-11  Jason Bacon Add man page template and usage
##########################################################################

usage()
{
    printf "Usage: $0\n"
    exit 1
}


##########################################################################
#   Main
##########################################################################

if [ $# != 0 ]; then
    usage
fi

export AUTO_ASK_TAG_PREFIX=auto-enable-hal-mount

case $(auto-ostype) in
FreeBSD)
    file=/usr/local/etc/PolicyKit/PolicyKit.conf
    if ! fgrep -q org.freedesktop.hal.storage.mount-removable $file; then
	cat << EOM

Allow all users to mount removable media?

Note: Consider the security implications of doing this on shared computers.

EOM
	resp=`auto-ask hal-mount 'Enable auto-mount?' y`
	if [ 0$resp = 0y ]; then
	    # Add all users in operator group
	    sed -i '.bak' -e 's|</config>|\
    <match action="org.freedesktop.hal.storage.mount-removable">\
	<return result="yes"/>\
    </match>\
</config>|g' $file
	    /usr/local/etc/rc.d/hald restart
	fi
    fi
    ;;
    
*)
    auto-unsupported-os $0
    exit 1
    ;;

esac
