2009年10月5日月曜日

OpenWrt Samba server

All you need is :
# An OpenWRT Compatible device
# Extrenal storage like an USB Harddrive or USB Memory Stick or SD Card with some 50-100 MB space.(For the WL-HDD you just need a regular Harddrive)

The tutorial is based on you having mounted the external storage on /opt !

Installing and Configuring Samba
Installing Samba is easy using Nicos testing packages:
ipkg install http://openwrt.org/downloads/people/nico/testing/mipsel/packages/samba_2.0.10-1_mipsel.ipk

Configuring is done easily by creating the file /etc/samba/smb.conf.
An example of a (simple) working config file could be:
workgroup = WORKGROUP
server string = OpenWRT Samba Server
wins support = no
dns proxy = no
name resolve order = lmhosts hosts bcast
log file = /opt/var/log/samba/log.%m
max log size = 1000
syslog = 0
security = share
encrypt passwords = true
obey pam restrictions = yes
guest account = nobody
passwd program = /usr/bin/passwd %u
load printers = no

[SambaShare]
comment = /opt/samba
path = /opt/samba
browseable = yes
public = yes
guest ok = yes
writeable = yes


Now create the shared directory you defined in the config file, and make it writable by everyone.

mkdir -p /opt/samba
chmod 777 /opt/samba

Now create a startup file called /etc/init.d/S50samba

Mine looks like:
#!/bin/sh

case $1 in
start)
nmbd -D
smbd -D
;;
stop)
killall nmbd
killall smbd
;;
*)
echo "usage: $0 (start|stop)"
exit 1
esac

exit $?

Dont forget to make the file executable :
chmod +x /etc/init.d/S50samba


Now you can try to start your samba server:
ps |grep "mbd"

If your Samba server is running, this should give you something like:
2170 root 908 S nmbd -D
2172 root 924 S smbd -D
2176 root 316 S grep mbd

Now you should be able to browse your share called "SambaShare" from any computer that is a member of "WORKGROUP" (the default workgroup name in Windows).
All users are able to both read and write on the share, since users all use the "nobody" account.

0 件のコメント: