#!/bin/sh -e

##########################################################################
#   Script description:
#       
#   Arguments:
#       
#   Returns:
#       
#   History:
#   Date        Name        Modification
#   2024-10-21  izzy Meyer  Start OpenBSD support
##########################################################################

if [ $# != 1 ]; then
    printf "Usage: $0 rc.conf-name\n"
    exit 1
fi
    
case $(auto-ostype) in
FreeBSD)
    service=$1
    grep -q "^${service}_enable=.*YES.*" /etc/rc.conf
    exit $?
    ;;
    
NetBSD)
    service=$1
    grep -q "^${service}=.*YES.*" /etc/rc.conf
    exit $?
    ;;

OpenBSD)
    service=$1
    rcctl ls on | grep -q "${service}"
    exit $?
    ;;

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

esac
