#!/bin/sh

#
# Global Settings
#

# The location of all the TFTP stuff
D_TFTP=/srv/tftp

# Full path of this project:
D_ROOTDIR=/root/pxe-bootserver
D_RESRC=${D_ROOTDIR}/resrc.d

# the ip and FQDN for this server
HOST_IP=192.168.75.3
HOST_FQDN=tftp.ostrach.tld


#
# Functions
#

fservice (){
# $1 is enabled yes/no
# $2 is the command
# $3 is the program name
# $4 is a list of packages

if [ "$1" = "yes" ] || [ "$1" = "YES" ]; then
 echo "$3 is enabled:"
 case $2 in
   # INIT
   # Install needed Debian Packages:
   init)
    echo "  installing: $4"
    apt install -y $4
   ;;
   start)
    if ! [ "$3" = "none" ]; then
      echo "  starting $3 ..."
      systemctl start $3
    fi
   ;; 
   stop)
    if ! [ "$3" = "none" ]; then
      echo "  stopping $3 ..."
      systemctl stop $3
    fi
   ;; 
   restart)
    if ! [ "$3" = "none" ]; then
      echo "  restarting $3 ..."
      systemctl restart $3
    fi
   ;; 
 esac
else
 echo "$3 is disabled. "
 if ! [ "$3" = "none" ]; then
  systemctl stop $3
 fi
fi



}


