What's new

Use of helper.sh | smb.conf and network shares

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

ZX81

Occasional Visitor
Hi,

using pc_replace of helper .sh I'm struggling to replace text that contains parenthesis characters. Basically my script under /jffs/scripts is working fine, but the processing of text with ( and ) fails.

Example:
I want to replace the entire line of text [entware (at USB-Stick)] by a space (because I can't find a solution to delete the entire line).

So that's my script:
#!/bin/sh
CONFIG=/tmp/etc/smb.conf
source /usr/sbin/helper.sh
pc_replace "[entware (at USB-Stick)]" "" $CONFIG


As result the text keeps completely untouched in smb.conf. I could found out, that the paranthesis have a special meaning in "sed" (I'm not familiar with sed syntax)

Any ideas how to get such text/lines out of the target file?

Thanks

Edit:
If I'm right, there is no other way to make boot-resistent changes to smb.conf - right?
 
Last edited:
Rather than replace the whole line why don't you comment it out. You don't have to match the whole line provided the match is unique.

/jffs/scripts/smb.postconf
Code:
!/bin/sh
CONFIG=$1
source /usr/sbin/helper.sh

pc_replace "[entware" "#[entware" $CONFIG
 
yeah, simple idea ...
:)

I also think about to use "sed" in my script ... just have to figure out "how-to".
Finally I want also to delete the 8 lines coming next to section name [entware
 
It's ugly but it works:

Code:
sed -i '/\[entware/{N;N;N;N;N;N;N;N;d}' $CONFIG

But if you're deleting so much of the entware section would it not be simpler to not have that section created by the router at all and then add in your own with a /jffs/configs/smb.conf.add file.
 
Last edited:
It's ugly but it works:

Code:
sed -i '/\[entware/{N;N;N;N;N;N;N;N;d}' $CONFIG

Works! Thanks for the crash course
:):):)

But if you're deleting so much of the entware section would it not be simpler to not have that section created by the router at all and then add in your own with a /jffs/configs/smb.conf.add file.
Yepp, have already play'd using smb.conf.add.

But I don't have found out yet, how Merlin gets the entware section into smb.conf added on boot (or maybe he already stored entwares smb.conf in the flash ROM?). All I could find on WWW yet - it's just possible to modify smb.conf on boot using the scripts ... ?
 
But I don't have found out yet, how Merlin gets the entware section into smb.conf added on boot (or maybe he already stored entwares smb.conf in the flash ROM?). All I could find on WWW yet - it's just possible to modify smb.conf on boot using the scripts ... ?

Asuswrt creates one share per folder by default. Share access is configurable on the webui.
 
Jesus, RMerlin you're totally right!

Ok - to be honest, kinda hidden ... didn't expect that located under "USB application" in webui.

So doing samba/share administration under Network Place (Samba) Share / Cloud Disk works also good for me. There's just a little downside: On Windows Network Places the "entware" share icon appears always below "RT-N66U", even if it hasn't got R/W access set - but it's not accesible (as expected). If entware share is not listed in smb.conf, "entware" does not appear at all on Network Places.

Thx Colin & Merlin for your kind support!
:)
 
Jesus, RMerlin you're totally right!

Ok - to be honest, kinda hidden ... didn't expect that located under "USB application" in webui.

So doing samba/share administration under Network Place (Samba) Share / Cloud Disk works also good for me. There's just a little downside: On Windows Network Places the "entware" share icon appears always below "RT-N66U", even if it hasn't got R/W access set - but it's not accesible (as expected). If entware share is not listed in smb.conf, "entware" does not appear at all on Network Places.

Thx Colin & Merlin for your kind support!
:)

Should be easy then to just insert a single config line to make that share hidden.
 
I think I'm missing the point here :confused: If you don't want access to the entware share and you don't want it appearing in Network Places why don't you just delete the share? Or is there something special about entware (I don't use it myself).

If you do want the share accessible as R/O or R/W (to those that know of its existence) but just not appear in the Network Places then you'd need to use the "browseable = no" option as alluded to by RMerlin.
 
Yes, it's a little "special". I'm not a real specialist about that, but as I'd understand so far, Asuswrt looks for folders who can be shared (folders on USB-Disk/Stick) and write them into smb.conf

In my case I have web stuff (for lighttpd) stored on a USB-Stick in folder \Web. The router mount that stick as sda1 (sometimes sdb1) and I renamed it to "USB-Stick". So far.

If you install entware, you get asked for the USB-drive/partition, where the installation should be done. Then entware setup creates a folder \entware.

Now I have 2 folders on my USB-Stick:
\entware
\Web

When the router boots up, Asuswrt looks at the USB-Stick and thinks he has to enter both folders in smb.conf for sharing. By default, sharing is enabled.

But to make my home network as easy as possible for others, I don't like to get "entware" noted on any network places - so the 100% perfect way is to remove the "entware" section in smb.conf, or I can go with the 99% solution, just set "No" for read and write access on "entware" share using the routers webui (then "entware" basically appears on network places).

Makes sense?
 
Last edited:
OK. I understand now. I had forgotten that the router automatically creates the shares on boot.:oops:

UPDATE: Don't delete the share. Sorry, this post previously said that deleting the share did not remove the underlying directory. That is wrong, it does.

So the best solution would appear to be to use the "browseable = no" option.

/jffs/scripts/smb.postconf
Code:
#!/bin/sh
CONFIG=$1
source /usr/sbin/helper.sh

pc_insert "[entware" "browseable = no" $CONFIG
 
Last edited:

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top