.KEY action
.DEF action restart
.BRA {
.KET }
;
; Just a note. This script is:
; *Freeware*
; *Use at your own risk ware*
; *Distribute/modify freely ware*
;
; Just give credit where it is due,
; i.e. keep all name listed, and add your name,
; and please send me any suggestions/changes.
;
; C.R.E.D.I.T.S/T.H.A.N.K.S
;
; /* I must give special to                        
;  * Nicolas Mendoza [mendoza@pvv.ntnu.no]         
;  * who submitted a script to                     
;  * "Ulf Bertilsson" <ulf.bertilsson@adcomdata.no>
;  * in an email on the Amiga Samba ML             
;  * it was his ideas in his script that           
;  * I used it to build mine.                      
;  * Thanks again, and I hope people find this     
; /* script useful.                               
;
; Send bugs/suggestions/updates to
; irperez@yahoo.com
;
; General blah blah blah follows. :)
;
; The author, Alexander Perez, takes
; no responsabilty for anything that
; can occur with the use or misuse of this
; script neither directly or indirectly as
; a result of it's use or misuse.
; 
; Niether does the author make 
; any waranties/guarantees with regards 
; to the overall functionallity of this script.
;
;BEGIN Script S:SAMBA
;
;Give SMBD/NMBD a nice stack. Change as you see fit.
;
 Stack 500000
 Echo ""
;
;Get Process ID of SMBD/NMBD
;
 Status COM=SAMBA:bin/smbd > ENV:SMBDPID
 Status COM=SAMBA:bin/nmbd > ENV:NMBDPID
;
; Lets check the value of {action} and decide what to do.
;
 If {action} EQ clear_logs
    Skip CLEAR_LOGS
 Else
 If {action} EQ start
    Skip STOP
 Else
 If {action} EQ stop
    Skip STOP
 Else
 If {action} EQ restart
    Skip STOP
 Else
 If {action} EQ status
    Skip STATUS
 EndIf
 Echo "Usage: Samba [Stop|Start|Restart|Status|Clear_Logs]"
 Echo ""
 Quit 5
;
;Stop the SMBD/NMBD Daemons if they are running.
;
LAB STOP
 If VAL $nmbdpid GT 0
    Echo "Stopping NMBD " NOLINE
    Break $nmbdpid All
    Echo "[STOPPED] PID $nmbdpid"
    Delete ENV:NMBDPID QUIET FORCE
 Else
    Echo "NMBD is not running."
 EndIf
 If VAL $smbdpid GT 0
    Echo "Stopping SMBD " NOLINE
    Break $smbdpid All
    Echo "[STOPPED] PID $smbdpid"
    Delete ENV:SMBDPID QUIET FORCE
 Else
    Echo "SMBD is not running."
 EndIf
 If {action} EQ stop
    Skip CLEAN
 EndIf
 Wait 3
;
;Start the SMBD/NMBD Daemons
;
LAB START
 Wait 2
 Echo ""
 Echo "Starting NMBD " NOLINE
 Run <>NIL: SAMBA:bin/nmbd
 Echo "[STARTED] PID " NOLINE
 Status COM=SAMBA:bin/nmbd
 Echo "Starting SMBD " NOLINE
 Run <>NIL: SAMBA:bin/smbd
 Echo "[STARTED] PID " NOLINE
 Status COM=SAMBA:bin/smbd
Skip CLEAN
;
; Report the status/PID of NMBD/SMBD.
;
LAB STATUS
 If VAL $nmbdpid GT 0
    Echo "NMBD is running as PID $nmbdpid."
 Else
    Echo "NMBD is not running."
 EndIf
 If VAL $smbdpid GT 0
    Echo "SMBD is running as PID $smbdpid."
 Else
    Echo "SMBD is not running."
 EndIf
 Wait 3
;
; Clean exit
;
LAB CLEAN
 Echo ""
 Quit 0
;END Script S:SAMBA
;
;Delete Log Files from /samba/log
; Use pattern: #?.log or log.#?
;
LAB CLEAR_LOGS
  Delete Samba:log/#?.log All Quiet
  Delete Samba:log/log.#? All Quiet
  Echo Log files cleared
  Echo ""

