Manually start Samba on Kongmod build

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Goto page 1, 2  Next
Author Message
elFlavio
DD-WRT Novice


Joined: 18 Jan 2016
Posts: 7

PostPosted: Mon Jan 18, 2016 4:43    Post subject: Manually start Samba on Kongmod build Reply with quote
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.

Here's my system specs:

Firmware:
DD-WRT v24-sp2 (06/07/14) stdkong - build 22000M

Hardware:
WNDR3400 v1

If any more info is necessary, I'm happy to provide.

Thanks!
Sponsor
jwh7
DD-WRT Guru


Joined: 25 Oct 2013
Posts: 2670
Location: Indy

PostPosted: Mon Jan 18, 2016 19:58    Post subject: Reply with quote
These:
    stopservice samba3
    startservice samba3
Smile

_________________
# NAT/SFE/CTF: limited speed w/ DD # Repeater issues # DD-WRT info: FAQ, Builds, Types, Modes, Changes, Demo #
OPNsense x64 5050e ITX|DD: DIR-810L, 2*EA6900@1GHz, R6300v1, RT-N66U@663, WNDR4000@533, E1500@353,
WRT54G{Lv1.1,Sv6}@250
|FreshTomato: F7D8302@532|OpenWRT: F9K1119v1, RT-ACRH13, R6220, WNDR3700v4
elFlavio
DD-WRT Novice


Joined: 18 Jan 2016
Posts: 7

PostPosted: Tue Jan 19, 2016 2:12    Post subject: Reply with quote
jwh7 wrote:
These:
    stopservice samba3
    startservice samba3
Smile


Nice try. But didn't work. Thanks tho.
jwh7
DD-WRT Guru


Joined: 25 Oct 2013
Posts: 2670
Location: Indy

PostPosted: Tue Jan 19, 2016 2:36    Post subject: Reply with quote
Ok then...backing up a step, what shows up here:
    ls /tmp/services/

You can also peruse /etc/config/

_________________
# NAT/SFE/CTF: limited speed w/ DD # Repeater issues # DD-WRT info: FAQ, Builds, Types, Modes, Changes, Demo #
OPNsense x64 5050e ITX|DD: DIR-810L, 2*EA6900@1GHz, R6300v1, RT-N66U@663, WNDR4000@533, E1500@353,
WRT54G{Lv1.1,Sv6}@250
|FreshTomato: F7D8302@532|OpenWRT: F9K1119v1, RT-ACRH13, R6220, WNDR3700v4
elFlavio
DD-WRT Novice


Joined: 18 Jan 2016
Posts: 7

PostPosted: Tue Jan 19, 2016 3:40    Post subject: Reply with quote
Looks like /tmp/services/ doesn't exist on my build.

As for /etc/config/, the following is found:
    -rwxr-xr-x 1 root root 7229 Jun 7 2014 5wifidog.webhotspot
    -rw-r--r-- 1 root root 17309 Jun 7 2014 base.nvramconfig
    -rw-r--r-- 1 root root 10632 Jun 7 2014 base.webconfig
    -rwxr-xr-x 1 root root 505 Jun 7 2014 conntrack.26.startup
    -rwxr-xr-x 1 root root 314 Jun 7 2014 dhcpd.startup
    -rwxr-xr-x 1 root root 4808 Jun 7 2014 dhcpd.webservices
    -rwxr-xr-x 1 root root 728 Jun 7 2014 eop-tunnel.firewall
    -rw-r--r-- 1 root root 2294 Jun 7 2014 eop-tunnel.nvramconfig
    -rwxr-xr-x 1 root root 954 Jun 7 2014 eop-tunnel.startup
    -rwxr-xr-x 1 root root 4269 Jun 7 2014 ftp.webnas
    -rwxr-xr-x 1 root root 1033 Jun 7 2014 http-redirect.firewall
    -rwxr-xr-x 1 root root 212 Jun 7 2014 http-redirect.nvramconfig
    -rwxr-xr-x 1 root root 2834 Jun 7 2014 http-redirect.webhotspot
    -rw-r--r-- 1 root root 189 Jun 7 2014 ipv6.nvramconfig
    -rwxr-xr-x 1 root root 468 Jun 7 2014 ipv6.startup
    -rw-r--r-- 1 root root 1357 Jun 7 2014 ipv6.webconfig
    -rw-r--r-- 1 root root 102 Jun 7 2014 jffs2.nvramconfig
    -rwxr-xr-x 1 root root 897 Jun 7 2014 jffs2.startup
    -rw-r--r-- 1 root root 1391 Jun 7 2014 jffs2.webconfig
    -rwxr-xr-x 1 root root 1143 Jun 7 2014 kumount.sesbutton
    -rw-r--r-- 1 root root 32 Jun 7 2014 language.nvramconfig
    -rwxr-xr-x 1 root root 112 Jun 7 2014 language.startup
    -rw-r--r-- 1 root root 262 Jun 7 2014 language.webconfig
    -rw-r--r-- 1 root root 289 Jun 7 2014 minidlna.nvramconfig
    -rwxr--r-- 1 root root 1312 Jun 7 2014 minidlna.startup
    -rw-r--r-- 1 root root 2050 Jun 7 2014 minidlna.webnas
    -rw-r--r-- 1 root root 234 Jun 7 2014 networksettings.brcm.nvramconfig
    -rw-r--r-- 1 root root 1517 Jun 7 2014 networksettings.brcm.webconfig
    -rwxr-xr-x 1 root root 584 Jun 7 2014 nocat.nvramconfig
    -rwxr-xr-x 1 root root 105 Jun 7 2014 nocat.startup
    -rwxr-xr-x 1 root root 5082 Jun 7 2014 nocat.webhotspot
    -rw-r--r-- 1 root root 396 Jun 7 2014 notifier.nvramconfig
    -rw-r--r-- 1 root root 2269 Jun 7 2014 notifier.websecurity
    -rwxr-xr-x 1 root root 428 Jun 7 2014 olsrd.nvramconfig
    -rwxr-xr-x 1 root root 747 Jun 7 2014 pptpd_client.ip-down
    -rwxr-xr-x 1 root root 747 Jun 7 2014 pptpd_client.ip-up
    -rwxr-xr-x 1 root root 522 Jun 7 2014 pptpd_client.nvramconfig
    -rwxr-xr-x 1 root root 398 Jun 7 2014 pptpd_client.options
    -rwxr-xr-x 1 root root 1131 Jun 7 2014 pptpd_client.sh
    -rwxr-xr-x 1 root root 788 Jun 7 2014 pptpd_client.startup
    -rwxr-xr-x 1 root root 2654 Jun 7 2014 pptpd_client.vpn
    -rwxr-xr-x 1 root root 619 Jun 7 2014 proftpd.nvramconfig
    -rw-r--r-- 1 root root 232 Jun 7 2014 proxywatchdog.nvramconfig
    -rwxr-xr-x 1 root root 1950 Jun 7 2014 proxywatchdog.sh
    -rwxr-xr-x 1 root root 376 Jun 7 2014 proxywatchdog.startup
    -rw-r--r-- 1 root root 1431 Jun 7 2014 proxywatchdog.webalive
    -rw-r--r-- 1 root root 109 Jun 7 2014 radiooff.nvramconfig
    -rw-r--r-- 1 root root 1029 Jun 7 2014 radiooff.webservices
    -rw-r--r-- 1 root root 1282 Jun 7 2014 routerstyle.webconfig
    -rwxr-xr-x 1 root root 517 Jun 7 2014 samba3.nvramconfig
    -rwxr-xr-x 1 root root 1054 Jun 7 2014 samba3.webnas
    -rwxr-xr-x 1 root root 203 Jun 7 2014 sambafs.nvramconfig
    -rwxr-xr-x 1 root root 907 Jun 7 2014 sambafs.startup
    -rwxr-xr-x 1 root root 2055 Jun 7 2014 sambafs.webconfig
    -rw-r--r-- 1 root root 352 Jun 7 2014 schedulerb.nvramconfig
    -rwxr-xr-x 1 root root 119 Jun 7 2014 schedulerb.sh
    -rwxr-xr-x 1 root root 1001 Jun 7 2014 schedulerb.startup
    -rw-r--r-- 1 root root 2531 Jun 7 2014 schedulerb.webalive
    -rwxr-xr-x 1 root root 571 Jun 7 2014 smtp-redirect.firewall
    -rwxr-xr-x 1 root root 169 Jun 7 2014 smtp-redirect.nvramconfig
    -rwxr-xr-x 1 root root 2454 Jun 7 2014 smtp-redirect.webhotspot
    -rwxr-xr-x 1 root root 1602 Jun 7 2014 snmp.webservices
    -rwxr-xr-x 1 root root 2297 Jun 7 2014 sshd.webservices
    -rw-r--r-- 1 root root 783 Jun 7 2014 syslog.webservices
    -rw-r--r-- 1 root root 479 Jun 7 2014 telnet.webservices
    -rw-r--r-- 1 root root 88 Jun 7 2014 ttraff.nvramconfig
    -rw-r--r-- 1 root root 481 Jun 7 2014 ttraff.webservices
    -rw-r--r-- 1 root root 502 Jun 7 2014 usb_adv.nvramconfig
    -rw-r--r-- 1 root root 3669 Jun 7 2014 usb_adv.webusb
    -rw-r--r-- 1 root root 162 Jun 7 2014 wdswatchdog.nvramconfig
    -rwxr-xr-x 1 root root 617 Jun 7 2014 wdswatchdog.sh
    -rwxr-xr-x 1 root root 297 Jun 7 2014 wdswatchdog.startup
    -rw-r--r-- 1 root root 1137 Jun 7 2014 wdswatchdog.webalive
    -rwxr-xr-x 1 root root 754 Jun 7 2014 wifidog.nvramconfig
    -rwxr-xr-x 1 root root 141 Jun 7 2014 zfilesharing.webnas

I apologize for how obnoxious that is, unfortunately I don't know of a better way to provide the output.

Anyway it looks like there's a few samba related items here. But when the GUI initializes samba these are the processes that are created:

    3151 root 3536 S /usr/sbin/nmbd -D --configfile=/tmp/smb.conf
    3153 root 3712 S /usr/sbin/smbd -D --configfile=/tmp/smb.conf

Thanks again!
jwh7
DD-WRT Guru


Joined: 25 Oct 2013
Posts: 2670
Location: Indy

PostPosted: Tue Jan 19, 2016 15:39    Post subject: Reply with quote
elFlavio wrote:
Looks like /tmp/services/ doesn't exist on my build.
Backing up another step...
    find / | grep -i service
I presume you're using Kong 22000++ usb-ftp-samba3-vpn-nv64k-broadcom.bin

_________________
# NAT/SFE/CTF: limited speed w/ DD # Repeater issues # DD-WRT info: FAQ, Builds, Types, Modes, Changes, Demo #
OPNsense x64 5050e ITX|DD: DIR-810L, 2*EA6900@1GHz, R6300v1, RT-N66U@663, WNDR4000@533, E1500@353,
WRT54G{Lv1.1,Sv6}@250
|FreshTomato: F7D8302@532|OpenWRT: F9K1119v1, RT-ACRH13, R6220, WNDR3700v4
elFlavio
DD-WRT Novice


Joined: 18 Jan 2016
Posts: 7

PostPosted: Wed Jan 20, 2016 4:29    Post subject: Reply with quote
Found stopservice and startservice under /sbin/. Amongst other things.

I SSH'd in from my phone and I've attached a screenshot of the output the command.

And yes that is the version I'm using.

Thanks!



Screenshot_20160119-212423.png
 Description:
 Filesize:  138.94 KB
 Viewed:  14092 Time(s)

Screenshot_20160119-212423.png


elFlavio
DD-WRT Novice


Joined: 18 Jan 2016
Posts: 7

PostPosted: Wed Jan 20, 2016 4:32    Post subject: Reply with quote
I apologize for the last post. That is also a very obnoxious way to display the output of a command.
mkaand
DD-WRT User


Joined: 06 Jan 2008
Posts: 307
Location: Istanbul

PostPosted: Wed Sep 06, 2017 10:28    Post subject: Reply with quote
Hi,

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:

startservice samba3
stopservice samba3

_________________
Kaan's World | @mkaand | PLEX Archive | Trakt.tv
jwh7
DD-WRT Guru


Joined: 25 Oct 2013
Posts: 2670
Location: Indy

PostPosted: Wed Sep 06, 2017 14:05    Post subject: Reply with quote
mkaand wrote:
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"

_________________
# NAT/SFE/CTF: limited speed w/ DD # Repeater issues # DD-WRT info: FAQ, Builds, Types, Modes, Changes, Demo #
OPNsense x64 5050e ITX|DD: DIR-810L, 2*EA6900@1GHz, R6300v1, RT-N66U@663, WNDR4000@533, E1500@353,
WRT54G{Lv1.1,Sv6}@250
|FreshTomato: F7D8302@532|OpenWRT: F9K1119v1, RT-ACRH13, R6220, WNDR3700v4
mkaand
DD-WRT User


Joined: 06 Jan 2008
Posts: 307
Location: Istanbul

PostPosted: Wed Sep 06, 2017 18:57    Post subject: Reply with quote
jwh7 wrote:
mkaand wrote:
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
dragonC
DD-WRT User


Joined: 23 May 2015
Posts: 272

PostPosted: Wed Sep 06, 2017 19:26    Post subject: Reply with quote
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.
mkaand
DD-WRT User


Joined: 06 Jan 2008
Posts: 307
Location: Istanbul

PostPosted: Fri Sep 08, 2017 15:31    Post subject: Reply with quote
dragonC wrote:
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.


Very nice! Thank you Laughing

_________________
Kaan's World | @mkaand | PLEX Archive | Trakt.tv
mkaand
DD-WRT User


Joined: 06 Jan 2008
Posts: 307
Location: Istanbul

PostPosted: Fri Sep 08, 2017 15:50    Post subject: Reply with quote
Quote:

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.

_________________
Kaan's World | @mkaand | PLEX Archive | Trakt.tv
dragonC
DD-WRT User


Joined: 23 May 2015
Posts: 272

PostPosted: Fri Sep 08, 2017 18:33    Post subject: Reply with quote
mkaand wrote:
Quote:

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.
Goto page 1, 2  Next Display posts from previous:    Page 1 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum