Ken Teague
unread,Oct 2, 2023, 5:47:56 PM10/2/23You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
I have an smb.conf file that is essentially of INI file format.
I'm trying to construct an awk 1-liner that will:
* check for the existence of the following line.
* If it doesn't exist, add it to the *end* of the [global] section.
* If it does exist, make sure it's as follows, or edit it to be as follows:
<tab>dfree command = /bin/dfree
I found this command that somewhat does what I need, but it's prepending a newline before adding the preferred line, so this:
[global]
...
log file = /var/log/samba/%m.log
guest account = guest
[samba]
path = /mount/samba
...
becomes this:
[global]
...
log file = /var/log/samba/%m.log
guest account = guest
dfree command = /bin/dfree
[samba]
path = /mount/samba
...
I'd like for it to look like this:
[global]
...
log file = /var/log/samba/%m.log
guest account = guest
dfree command = /bin/dfree
[samba]
path = /mount/samba
...
It also appears that it's not looking for and editing the line to match my preference (it's just appending):
[global]
...
log file = /var/log/samba/%m.log
guest account = guest
dfree command = /sbin/dfree
dfree command = /bin/dfree
[samba]
path = /mount/samba
...
This smb.conf file is part of a Linux distribution that is used on a hardware appliance. The contents and arrangement of items may change at any time, which is why I'm looking to do this the way I've described. I'm open to ideas if it can be done in a more efficient and reliable manner. Thanks in advance!