
#!/bin/sh
# File	: set_vfiler_options.sh
# By	: Maarten.deBoer, 140228
# Subject	: Set options of vfilers
PGM="`basename $0|cut -d\. -f1`"
VER="0.1"
TMP="/tmp/${PGM}.$$"
LOG="${HOME}/log/${PGM}.log"
SSH="/usr/bin/ssh -n"

touch ${TMP}
echo "`date` ${PGM} v${VER} started." |tee -a ${LOG}

FILERS="nlnaf51 nlnaf52 nlnaf53 nlnaf54"
for FILER in ${FILERS}
do
  ${SSH} ${FILER} vfiler status|grep running|grep -v vfiler0|awk '{print $1}'|while read VFILER
  do
    echo "${FILER}/${VFILER} ..."|tee -a ${LOG}
# Set options cifs.rpcfd_timeout -1
    ${SSH} ${FILER} vfiler run -q ${VFILER} options cifs.rpcfd_timeout|tee -a ${LOG}
    ${SSH} ${FILER} vfiler run -q ${VFILER} options cifs.rpcfd_timeout -1
    ${SSH} ${FILER} vfiler run -q ${VFILER} options cifs.rpcfd_timeout|tee -a ${LOG}

# If vscan is enabled, then vscan will be disable and re-enable AV on the filer
    ANSW="`${SSH} ${FILER} vfiler run -q ${VFILER} vscan| grep 'scanning is'|awk '{print $4}'`"
    if [ "${ANSW}" = "enabled." ]; then
      echo "${FILER}/${VFILER} vscan will be dis- & enabled ..."|tee -a ${LOG}
      ${SSH} ${FILER} vfiler run -q ${VFILER} vscan off
      sleep 10
      ${SSH} ${FILER} vfiler run -q ${VFILER} vscan| grep 'scanning is'|awk '{print $4}'|tee -a ${LOG}
      ${SSH} ${FILER} vfiler run -q ${VFILER} vscan on
    fi

  done  # VFILER
done  # for

echo "`date` ${PGM} v${VER} finished." |tee -a ${LOG}
rm ${TMP}
exit 0

