#"!/usr/bin/env bash PIDS=`ps aux | grep "/usr/local/samba/sbin/samba" | grep -v grep | awk '{print$2}'` if [ "X${PIDS}X" = "XX" ];then echo -e "\n[Error]: Samba Service seems to be down. Try to (re)start .." /etc/init.d/samba4 stop > /dev/null 2>&1 /etc/init.d/samba4 start > /dev/null sleep 2 NEW_PIDS=`ps aux | grep "/usr/local/samba/sbin/samba" | grep -v grep | awk '{print$2}'` if [ "X${NEW_PIDS}X" = "XX" ]; then echo -e "" echo -e "\t[Error]: Restarting samba services failed !!" echo -e "\n\t[Error]: Restarting samba services failed !!\n" echo -e "" else PIDS="" for pid in $NEW_PIDS ; do PIDS="$PIDS $pid" done echo -e echo -e "\tI have restarted the samba services. The new PIDs are $PIDS" echo -e fi fi exit 0