Here's an example script that manages the dynamic use of samba. It manages the installation and startup, stopping and uninstall and restart of samba. It seems to work for me but that doesn't mean it's flawless.
#!/bin/sh
# bigpcman May 25, 2009
# Samba Prep
# Download samba3.tczl to tce/optional
# My usb persistent storage = /mnt/sdc1
# Make directories - sudo mkdir -p /var/lib/samba /etc/samba/private
# Edit conf file - /etc/samba/smb.conf
# Create samba password - /usr/local/bin/smbpasswd
# Save the conf file - sudo cp -a /etc/samba/smb.conf /mnt/sdc1/samba
# Save the pass word file - sudo cp -a /etc/samba/private/smbpasswd /mnt/sdc1/samba
# Run this script - sambaserver start, sambaserver stop, sambaserver restart
stop()
{
echo "Stopping Samba..."
sudo killall smbd 2>&1 > /dev/null &
sudo killall nmbd 2>&1 > /dev/null &
sleep 1
tcz-uninstall samba3 --force --purge 2>&1 > /dev/null &
sleep 2
tcz-uninstall cups --force --purge 2>&1 > /dev/null &
sleep 2
sudo rm -R /etc/cups 2>&1 > /dev/null &
sudo rm -R /etc/samba 2>&1 > /dev/null &
sudo rm -R /usr/local/share/doc/cups 2>&1 > /dev/null &
sudo rm -R /usr/local/include/cups 2>&1 > /dev/null &
sudo rm -R /usr/local/share/cups 2>&1 > /dev/null &
sudo rm -R /usr/local/tce.flwm/cups 2>&1 > /dev/null &
sudo rm -R /usr/local/lib/cups 2>&1 > /dev/null &
sudo rm -R /var/lib/samba 2>&1 > /dev/null &
sudo rm -R /var/run/smbd.pid 2>&1 > /dev/null &
sudo rm -R /var/run/nmbd.pid 2>&1 > /dev/null &
}
start()
{
echo "Starting Samba..."
tce-load /mnt/sdc1/tce/optional/samba3.tczl 2>&1 > /dev/null &
sleep 3
sudo mkdir -p /etc/samba/private /var/lib/samba 2>&1 > /dev/null &
sudo cp -a /mnt/sdc1/samba/smb.conf /etc/samba 2>&1 > /dev/null &
sudo cp -a /mnt/sdc1/samba/smbpasswd /etc/samba/private 2>&1 > /dev/null &
sudo /usr/local/sbin/smbd 2>&1 > /dev/null &
sudo /usr/local/sbin/nmbd 2>&1 > /dev/null &
}
restart()
{
echo "Restarting Samba.."
stop
sleep 3
start
}
case "$1" in
stop) stop;;
restart) restart;;
start) PID=$(pidof smbd)
[ -n "$PID" ] && echo "Samba already started" || start;;
*)
echo "Usage: $0 {start|stop|restart}"
esac