DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2009-07-13 03:05:21

neonpolaris
Member
Registered: 2009-06-19
Posts: 20

Customizing Samba shares on startup

Hey guys, I'm trying to find a way to remove the two shares that I never use, "web_page" and "printers".

I'm have 1.07 FW with ffp running off USB.  I made a script to automatically mount my usb share like this:

Code:

#!/ffp/bin/sh

echo "[ USB ]
comment =
path = /mnt/usb
valid users =
read only = no
guest ok = yes
oplocks = no
map archive = no
" >> /etc/samba/smb.conf

smb restart

It works great.  As you can see it simply adds my extra share to smb.conf and then restarts samba.  Unfortunately I don't know an easy way to automatically remove these two sections:

Code:

[ web_page ]
comment = Enter Our Web Page Setting
path = /mnt/web_page
valid users =
read only = yes
guest ok = yes

[printers]
path = /mnt/HD_a4/.lpd
guest ok = Yes
printable = Yes
use client driver = Yes
browseable = No

Has anyone here accomplished this?

---

I know that I could simply save a copy of the whole smb.conf, edit it up, and then have my script replace it on startup.  But I would rather avoid this since it would break the web config pages ability to change settings, etc.

Offline

 

#2 2009-07-13 04:32:44

neonpolaris
Member
Registered: 2009-06-19
Posts: 20

Re: Customizing Samba shares on startup

Got it!

Code:

#!/ffp/bin/sh

sed -e '/\[ web_page \]/,/^$/d' -e '/\[printers\]/,/^$/d' /etc/samba/smb.conf > /etc/samba/smb.conf.new

echo "[ USB ]
comment = 
path = /mnt/usb
valid users = 
read only = no
guest ok = yes
oplocks = no
map archive = no
" >> /etc/samba/smb.conf.new

rm /etc/samba/smb.conf
mv /etc/samba/smb.conf.new /etc/samba/smb.conf

sleep 2

smb restart

Offline

 

#3 2009-07-13 09:36:37

mig
Member
From: Seattle, WA
Registered: 2006-12-21
Posts: 532

Re: Customizing Samba shares on startup

Another technique to accomplish the samba customization, is to store your custom smb.conf
file on your hard disk and use a startup script to copy the custom smb.conf to /etc/samba and
restart samba (no sed editing skills needed) see http://dns323.kood.org/forum/viewtopic. … 7869#p7869


DNS-323 • 2x Seagate Barracuda ES 7200.10 ST3250620NS 250GB SATAII (3.0Gb/s) 7200RPM 16MB • RAID1 • FW1.03 • ext2 
Fonz's v0.3 fun_plug http://www.inreto.de/dns323/fun-plug

Offline

 

#4 2009-07-13 12:02:17

michalzxc
Member
Registered: 2008-08-04
Posts: 9

Re: Customizing Samba shares on startup

Or, just edit /etc/samba/smb.default
And copy it to mtd1 and mtd2:
mount -t minix /dev/mtdblock0 /sys/mtd1
cp /etc/samba/smb.default /sys/mtd1/smb.default
sync
umount /sys/mtd1
mount -t minix /dev/mtdblock1 /sys/mtd2
cp /etc/samba/smb.default /sys/mtd2/smb.default
sync
umount /sys/mtd2

Offline

 

#5 2009-07-14 02:40:03

neonpolaris
Member
Registered: 2009-06-19
Posts: 20

Re: Customizing Samba shares on startup

@mig:  If I did that, I couldn't add or remove shares from the web interface.

@michalzxc: If I understand right, that could be a better, more permanent solution.  It's also a hell of alot scarier to me. I figured my way couldn't brick my device no matter what typos I made. smile

Offline

 

#6 2009-07-14 22:07:39

mig
Member
From: Seattle, WA
Registered: 2006-12-21
Posts: 532

Re: Customizing Samba shares on startup

neonpolaris wrote:

@mig:  If I did that, I couldn't add or remove shares from the web interface.

That is correct.  You have to commit to full manual customization (no web GUI) with the stored customized smb.conf technique.

I see you are trying to keep web GUI functionality and the sed script is a nice viable solution (sed is a very powerful program)

I also agree with your hesitation about writing to flash, that is a very scary technique to me. yikes

Last edited by mig (2009-07-14 22:08:19)


DNS-323 • 2x Seagate Barracuda ES 7200.10 ST3250620NS 250GB SATAII (3.0Gb/s) 7200RPM 16MB • RAID1 • FW1.03 • ext2 
Fonz's v0.3 fun_plug http://www.inreto.de/dns323/fun-plug

Offline

 

#7 2012-04-05 04:00:55

neonpolaris
Member
Registered: 2009-06-19
Posts: 20

Re: Customizing Samba shares on startup

Sorry to dig up an old thread, but I'm re-doing my entire ffp install (usb drive failing) and I noticed that I wasn't using exactly what I posted above anymore. Instead this:

Code:

#!/ffp/bin/sh

sed -e '/\[ Volume_1 \]/,/^$/d' -e '/\[ Volume_2 \]/,/^$/d' -e '/\[ web_page \]/,/^$/d' -e '/\[printers\]/,/^$/d' /etc/samba/smb.conf > /etc/samba/smb.conf.new

echo "[ HD_a2 ]
comment =
path = /mnt/HD_a2
valid users =
read only = no
guest ok = yes
oplocks = no
map archive = no

[ HD_b2 ]
comment =
path = /mnt/HD_b2
valid users =
read only = no
guest ok = yes
oplocks = no
map archive = no

[ USB ]
comment =
path = /mnt/usb
valid users =
read only = no
guest ok = yes
oplocks = no
map archive = no
" >> /etc/samba/smb.conf.new

rm /etc/samba/smb.conf
mv /etc/samba/smb.conf.new /etc/samba/smb.conf

sleep 2

smb restart

This also removes/re-adds the two main shares under a different name, I had found the web interface renaming to be somewhat unreliable.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB