drew.arthur@mail.sprint.com
2002-Jul-29 17:37 UTC
[Samba] Looking for a script to add/remove multiple shares from smb.conf
Has anyone ever written a script to remove individual shares from the smb.conf file? I am trying to put together a script that will add & remove multiple shares at once by giving a <sharelist as input to the script. Adding shares is easy because I can just append the shares to the smb.conf file, but removing individual share entries within the smb.conf file without messing up the syntax of the file is the tricky part. Any insights would be appreciated. Thanks,
Joel Hammer
2002-Jul-29 18:30 UTC
[Samba] Looking for a script to add/remove multiple shares from smb.conf
This sounds like the sort of thing a sedoholic would find fun. Why not post an example of what you want to do. I subscribe to the sed mailing list. I'll be happy to pass it along. Joel On Mon, Jul 29, 2002 at 07:35:03PM -0500, drew.arthur@mail.sprint.com wrote:> Has anyone ever written a script to remove individual shares from the > smb.conf file? I am trying to put together a script that will add & > remove multiple shares at once by giving a <sharelist as input to the > script. > > Adding shares is easy because I can just append the shares to the > smb.conf file, but removing individual share entries within the smb.conf > file without messing up the syntax of the file is the tricky part. Any > insights would be appreciated. > > Thanks, > > > -- > To unsubscribe from this list go to the following URL and read the > instructions: http://lists.samba.org/mailman/listinfo/samba
Goetz Rieger
2002-Jul-29 23:59 UTC
[Samba] Looking for a script to add/remove multiple shares from smb.conf
On Mon, 29 Jul 2002 21:27:37 -0400 Joel Hammer <Joel@HammersHome.com> wrote:> This sounds like the sort of thing a sedoholic would find fun. > Why not post an example of what you want to do.And what about the even worse perl-o-maniacs? Not to mention the awklings? ;-) Goetz
Joel Hammer
2002-Jul-30 03:51 UTC
[Samba] Looking for a script to add/remove multiple shares from smb.conf
Those lesser breeds will simply have to wait their turn. Joel On Tue, Jul 30, 2002 at 08:57:27AM +0200, Goetz Rieger wrote:> On Mon, 29 Jul 2002 21:27:37 -0400 > Joel Hammer <Joel@HammersHome.com> wrote: > > > This sounds like the sort of thing a sedoholic would find fun. > > Why not post an example of what you want to do. > > And what about the even worse perl-o-maniacs? Not to mention the awklings? > > ;-) > > Goetz > > -- > To unsubscribe from this list go to the following URL and read the > instructions: http://lists.samba.org/mailman/listinfo/samba
drew.arthur@mail.sprint.com
2002-Jul-30 06:07 UTC
[Samba] Looking for a script to add/remove multiple shares from smb.conf
I would like to easily add/remove share entries in the smb.conf file without removing or deleting lines that are not associated with that section. I use SWAT for single shares. [xxxuser] comment = xxxuser Testing path = /samba/xxxuser Read Only = NO [drew] comment = drew's tmp share path = /tmp [testgroup] path = /samba/testgroup read only = No So, if I wanted to remove the [drew] share I guess I would just need to remove all lines including [drew] between the ending ] and the next beginning [ ? perl-o-maniacs, awklings, sedoholics.... I'll take what I can get. Here is a script that will find the entry "unix" in a file and then split the file. I could do something similar but I still end up with the remaining lines after "[drew]". #!/bin/ksh file="file1" while read -r xx do if [ "$xx" = "unix" ] then file="file2"; else echo "$xx" >> $file ; fi done < $1 Thanks, -----Original Message----- From: Joel [mailto:Joel@HammersHome.com] Sent: Tuesday, July 30, 2002 5:48 AM To: goetz.rieger; samba Subject: Re: [Samba] Looking for a script to add/remove multiple shares from smb.conf Those lesser breeds will simply have to wait their turn. Joel On Tue, Jul 30, 2002 at 08:57:27AM +0200, Goetz Rieger wrote:> On Mon, 29 Jul 2002 21:27:37 -0400 > Joel Hammer <Joel@HammersHome.com> wrote: > > > This sounds like the sort of thing a sedoholic would find fun. > > Why not post an example of what you want to do. > > And what about the even worse perl-o-maniacs? Not to mention theawklings?> > ;-) > > Goetz > > -- > To unsubscribe from this list go to the following URL and read the > instructions: http://lists.samba.org/mailman/listinfo/samba-- To unsubscribe from this list go to the following URL and read the instructions: http://lists.samba.org/mailman/listinfo/samba
Goetz Rieger
2002-Jul-31 06:42 UTC
[Samba] Looking for a script to add/remove multiple shares from smb.conf
Hei, On Tue, 30 Jul 2002 08:05:14 -0500 drew.arthur@mail.sprint.com wrote:> I would like to easily add/remove share entries in the smb.conf file > without removing or deleting lines that are not associated with that > section. I use SWAT for single shares.Ok: Quick and dirty, but seems to work. Give it a try, but please be careful. It leaves two blank lines, but that should not matter. And it would delete shares which are commented out and which follow a share to delete... ;-) Goetz #!/usr/bin/perl my $smbconf="smb.conf"; my @shares_to_delete=qw(printers homes); open(SMBCONF, $smbconf); open(SMBCONFNEW, ">smb.conf.new"); $a=join("", <SMBCONF>); foreach $share (@shares_to_delete) { $a =~ s/^\[$share\]([^^][^\[])*//gm; } print SMBCONFNEW "$a";
Gerald Carter
2002-Jul-31 07:43 UTC
[Samba] Looking for a script to add/remove multiple shares from smb.conf
On Mon, 29 Jul 2002 drew.arthur@mail.sprint.com wrote:> Has anyone ever written a script to remove individual shares from the > smb.conf file? I am trying to put together a script that will add & > remove multiple shares at once by giving a <sharelist as input to the > script. > > Adding shares is easy because I can just append the shares to the > smb.conf file, but removing individual share entries within the smb.conf > file without messing up the syntax of the file is the tricky part. Any > insights would be appreciated.See examples/misc/modify_samba_config.pl for a bare bones perl script. May or may not be what you want. cheers, jerry