Posted: Mon Jan 18, 2016 4:43 Post subject: Manually start Samba on Kongmod build
Hello all,
I'm currently trying to manually start and stop Samba via SSH. Mostly for the sake of understanding what's going on beneath the GUI. I've researched a few commands that supposedly initiate Samba but they don't seem to work.
My system is apparently unique in that it has Samba and a few other features baked into the firmware, and I haven't yet needed to install or use Optware. However, nearly all documentation I've found on the subject, wrt DD-WRT specifically, is related to Optware.
However, enabling/disabling Samba from the GUI, of course, does work and I can verify this simply by determining the running processes in top.
In addition to knowing how to initiate Samba manually, I'd like to understand how the GUI interfaces with the system and what configuration file(s) it is modifying. This would be helpful for when I run into similar issues in the future that I may be able to determine what commands the GUI is sending to the system.
Thus far I've figured out how to manually mount an external USB drive. And I'd eventually like to write my own initialization script that mounts the drive and loads Samba.
I have an issue with Samba3. Sometimes after restart Samba doesn't work. I want to write a script to check samba is working or not. How can I do that? I can able to start stop service with these commands:
I want to write a script to check samba is working or not. How can I do that?
In the Admin Scripts section, save a startup script like...
sleep 30
stopservice samba3
startservice samba3
Others have done this before; I haven't. Search for "stopservice AND startservice AND samba3 AND script"
Thank you. I'll try maybe it is possible to use ps and grab command. I have some crontab jobs. I want to check every hour samba is working or not but problem occur after reboot (sometimes only) I guess your solution helps me and enough. _________________ Kaan's World | @mkaand | PLEX Archive | Trakt.tv
I just do this in a startup script - basically making sure (up to the first 150s, 75s each for smbd and nmbd) the samba daemons run successfully on system boot. Note that I use the OPKG samba release, which should be the same thing as built-in (strip out the /opt, I am just lazy to change and test):
counter=0
while ( ! (ps | grep -q [s]mbd) ); do
if [[ $counter -gt 5 ]]; then
exit 1
fi
/opt/usr/sbin/smbd -D --configfile=/tmp/samba/smb.conf
counter=$((counter+1))
sleep 15
done
counter=0
while ( ! (ps | grep -q [n]mbd) ); do
if [[ $counter -gt 5 ]]; then
exit 1
fi
/opt/usr/sbin/nmbd -D --configfile=/tmp/samba/smb.conf
counter=$((counter+1))
sleep 15
done
If one is paranoid it's just as simple to set up a cronjob to run this every x minutes/hours/days.
P.S.: I prefer to manage my own startup scripts via SSH instead of the GUI.
I just do this in a startup script - basically making sure (up to the first 150s, 75s each for smbd and nmbd) the samba daemons run successfully on system boot. Note that I use the OPKG samba release, which should be the same thing as built-in (strip out the /opt, I am just lazy to change and test):
counter=0
while ( ! (ps | grep -q [s]mbd) ); do
if [[ $counter -gt 5 ]]; then
exit 1
fi
/opt/usr/sbin/smbd -D --configfile=/tmp/samba/smb.conf
counter=$((counter+1))
sleep 15
done
counter=0
while ( ! (ps | grep -q [n]mbd) ); do
if [[ $counter -gt 5 ]]; then
exit 1
fi
/opt/usr/sbin/nmbd -D --configfile=/tmp/samba/smb.conf
counter=$((counter+1))
sleep 15
done
If one is paranoid it's just as simple to set up a cronjob to run this every x minutes/hours/days.
P.S.: I prefer to manage my own startup scripts via SSH instead of the GUI.
counter=0
while ( ! (ps | grep -q [s]mbd) ); do
if [[ $counter -gt 5 ]]; then
exit 1
fi
/usr/sbin/smbd -D --configfile=/tmp/smb.conf
counter=$((counter+1))
sleep 15
done
counter=0
while ( ! (ps | grep -q [n]mbd) ); do
if [[ $counter -gt 5 ]]; then
exit 1
fi
/usr/sbin/nmbd -D --configfile=/tmp/smb.conf
counter=$((counter+1))
sleep 15
done
Above script works perfectly on Kong's Builds. I changed the paths only.
Glad to help.
Now that you have this setup, if you're up for it, it only takes very little effort to manage the whole Samba config independent of the GUI - you just need to store all your Samba config in a permanent directory (i.e. one of your USB mounts). I prefer it that way for security so no one get access to login/account credentials without actually SSH into the router (since it's not visible on the GUI now). Managing your own smb.conf also lets you optimize things (buffer, deadtime and even SMB dialect version etc.) specifically for your network.