#!/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-12  Jason Bacon Add man page template and usage
##########################################################################

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


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

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

case $(auto-ostype) in
FreeBSD)
    : ${PORTSDIR:=/usr/ports}
    pkg install -y pkgconf zenity autoconf automake libublio gettext-tools \
	texinfo fusefs-libs
    
    # There were license restrictions up into 2020
    # exfat tools were marked for no binary package at one point
    #if ! auto-package-installed sysutils/fusefs-exfat; then
    #    (cd $PORTSDIR/sysutils/fusefs-exfat && unset BATCH && make deinstall clean reinstall)
    #fi
    #if ! auto-package-installed sysutils/exfat-utils; then
    #    (cd $PORTSDIR/sysutils/exfat-utils && unset BATCH && make deinstall clean reinstall)
    #fi
    pkg install -y exfat-utils fusefs-exfat
    
    pkg install -y fusefs-ntfs fusefs-ext2 fusefs-lkl \
	fusefs-hfsfuse fusefs-simple-mtpfs
    
    kldload fusefs || true
    sysrc kld_list+=fusefs
    ;;

NetBSD)
    : ${PORTSDIR:=/usr/ports}
    pkgin -y install pkgconf zenity autoconf automake gettext-tools \
	gtexinfo fuse
    
    # There were license restrictions up into 2020
    # exfat tools were marked for no binary package at one point
    #if ! auto-package-installed sysutils/fusefs-exfat; then
    #    (cd $PORTSDIR/sysutils/fusefs-exfat && unset BATCH && make deinstall clean reinstall)
    #fi
    #if ! auto-package-installed sysutils/exfat-utils; then
    #    (cd $PORTSDIR/sysutils/exfat-utils && unset BATCH && make deinstall clean reinstall)
    #fi
    pkgin -y install fuse-exfat
    
    # FreeBSD uses fuse-lkl for ext4, NetBSD fuse-ext2 (2023-06)
    pkgin -y install fuse-ntfs fuse-ext2
    
    # FIXME: How to enable fuse on NetBSD?
    #kldload fusefs || true
    #sysrc kld_list+=fusefs
    ;;

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

esac
