#!/bin/sh

# smbctrl - Control (e.g., start or stop) the SAMBA server
#
# Usage: smbctrl <command> <logfile>
# This script must be run by a user with appropriate privileges (e.g., root)
#
# command: the command to be issued to the SAMBA server (e.g. "start", "stop")
# logfile: the filename of the log file to create
#
# Return Codes:
# 13 - smb command failed

COMMAND=$1
LOG=$2

echo -e "-> smbctrl\n" >> $LOG

if ! /etc/init.d/smb $COMMAND >> $LOG 2>&1; then
    echo -e "SAMBA command failed.. exiting\n" >> $LOG
    exit 13
fi

echo -e "<- smbctrl\n" >> $LOG

exit 0
