The current samba init script has a few errors when not parsed in a bash shell. I will attach a patch that addresses this and makes a few improvements such as localizing all variables.
Created attachment 112677 [details, diff] Fixes to samba init script
*** Bug 170091 has been marked as a duplicate of this bug. ***
Done. Thanks!