#!/bin/bash

CONFDIR=/etc/samba
INCLUDEFILE=$CONFDIR/smb.include.conf
INCLUDEDIR=$CONFDIR/include.d

if [ ! -d "$CONFDIR" ]
then
  echo "Cannot find config dir $CONFDIR"
  exit 1
fi

if [ ! -d "$INCLUDEDIR" ]
then
  echo "Cannot find include dir $INCLUDEDIR"
  exit 1
fi

if [ ! -w "$INCLUDEFILE" ]
then
  echo "Include file $INCLUDEFILE is missing or is not writable"
  exit 1
fi

find "$INCLUDEDIR" -type f | sed 's/^/include = /' > "$INCLUDEFILE"
