
#!/bin/sh
# File	: create-cifs-terminate-script.sh
# By	: Maarten.deBoer@Atos.net, 151014
# Subject	: Script to create a cifs-terminate-<filer>.sh
PGM="`basename $0|cut -d\. -f1`"
VER="0.1"
TMP="/tmp/${PGM}.$$"
SSH="/usr/bin/ssh"

if [ "${1}" = "" ]; then
  echo "${PGM} <filername>. No filername given. Exiting ..."
  exit 1
fi

FILER="${1}"
SCRIPTDIR="${HOME}/scripts/"
SCRIPT="${SCRIPTDIR}/cifs-terminate-${FILER}"

echo "`date` creating cifs-terminate-${FILER} in ${SCRIPTDIR} ..."

echo "# `date` for ${FILER}" > ${SCRIPT}
${SSH} ${FILER} vfiler status|grep -v vfiler0|grep running|awk '{print $1}'|while read VFILER
do
  echo "${SSH} ${FILER} vfiler run ${VFILER} cifs terminate -t 0 " >> ${SCRIPT}
done

echo "`date` ${SCRIPT} has been created."
exit 0

