* [gentoo-user] SMBBrowser for automount
@ 2006-02-10 10:49 CapSel
2006-02-10 15:16 ` Robert Cernansky
0 siblings, 1 reply; 9+ messages in thread
From: CapSel @ 2006-02-10 10:49 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 312 bytes --]
This is my script that scans configured subnetwork for guest shares,
makes entries for automount and restarts it.
Is this script helpful to someone? Is it worth to continue making it,
or is there a better way to allow normal programs to browse smb
network.
I don't have a inet page yet, but on next week... :D
[-- Attachment #2: smbbrowser --]
[-- Type: application/octet-stream, Size: 2667 bytes --]
#!/usr/bin/perl
sub init {
$min = 1;
$max = 15;
$smbdir = "/mnt/smb";
$autodir = "/var/smb";
$afsfile = "/etc/autofs/auto.smb";
$ip = "192.168.0";
$log = "/var/log/smbbrowser";
if( ! system( "cat /tmp/smbbrowser 2>&1 >/dev/null" ) )
{
exit 0;
}
system( "touch /tmp/smbbrowser >/dev/null" );
};
sub scan {
my $n = 0;
for ($i=$min; $i <= $max; $i++ ) {
$list[$n]="$ip.$i";
$n++;
};
};
sub scanshare {
my $host = shift;
$host =~ s/~[\d.]//g;
print logi $host,"\n";
open( com, "source /etc/profile; smbclient -N -L $host 2>/dev/null |" );
my @output = <com>;
close( com );
open( p, ">/tmp/$host.smb" );
foreach (@output) {
my $line = $_;
if( $line =~ /Disk/ ) {
$line =~ s/\s*Disk.*$//;
$line =~ s/^\s*//;
$line =~ s/^$\n//;
if ( ! ($line =~ /\$$/) ) {
print p $line;
print logi $line;
};
};
};
close( p );
};
sub autofsfile {
system( "cat $afsfile.static > $afsfile 2>/dev/null" );
open( OUT, ">$afsfile" );
foreach (@list) {
my $hostname = $_;
scanshare $hostname;
#print $hostname,":\n";
open( IN, "</tmp/$hostname.smb" );
my @lines = <IN>;
foreach (@lines) {
my $line = $_;
$line =~ s/\ /\\\ /g;
$line =~ s/\n$//;
$wline = "$hostname\_$line\t-fstype=smbfs,uid=samba,gid=samba,fmask=770,dmask=770,credentials=/root/hasla\t://$hostname/$line";
$wline =~ s/\n//g;
print OUT $wline,"\n";
};
close(IN);
};
close(OUT);
};
sub links {
system( "rm -rf $smbdir/* >/dev/null" );
foreach (@list) {
my $host = $_;
$host =~ s/\n//;
if ( ! system( "ls -l /tmp/$host.smb | grep -v -e ' 0 ' >/dev/null" ) ) {
system( "mkdir $smbdir/$host >/dev/null" );
};
open( IN, "</tmp/$host.smb" );
my @lines = <IN>;
foreach (@lines) {
my $line = $_;
$line =~ s/\ /\\\ /g;
$line =~ s/\n$//;
my $source = $autodir;
$source .= "/";
$source .= $host;
$source .= "_";
$source .= $line;
print logi "`","ln -s $source $smbdir/$host/$line","'\n";
system( "ln -s $source $smbdir/$host/$line >/dev/null" );
};
close( IN );
};
};
sub hostnames {
};
#-----------------------------------------
#@list = ("localhost");
my @list;
init;
open( logi, ">>$log" );
scan;
autofsfile;
links;
if( system( "kill -HUP `ps w -C automount | grep smb | cut -c -5` 2>&1 >/dev/null" ) ) {
#system( "/etc/init.d/autofs restart >/dev/null" );
system( "/etc/init.d/autofs stop >/dev/null" );
system( "/etc/init.d/autofs zap >/dev/null" );
system( "/etc/init.d/autofs start >/dev/null" );
# };
};
system( "rm /tmp/smbbrowser >/dev/null" );
close( logi );
#debug lines:
#my $cos = "192.168.0.11";
#scanshare $cos;
#system("cat /tmp/192.168.0.11.smb" );
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-user] SMBBrowser for automount
2006-02-10 10:49 [gentoo-user] SMBBrowser for automount CapSel
@ 2006-02-10 15:16 ` Robert Cernansky
2006-02-10 15:29 ` CapSel
2006-02-10 16:19 ` CapSel
0 siblings, 2 replies; 9+ messages in thread
From: Robert Cernansky @ 2006-02-10 15:16 UTC (permalink / raw
To: gentoo-user
On Fri, 10 Feb 2006 11:49:32 +0100 CapSel <capsel@gmail.com> wrote:
C> This is my script that scans configured subnetwork for guest shares,
C> makes entries for automount and restarts it.
C>
C> Is this script helpful to someone? Is it worth to continue making it,
C> or is there a better way to allow normal programs to browse smb
C> network.
In the past I've also used similar script to mount smb shares. But recently
I've discovered SMBNetFS (http://smbnetfs.airm.net/) and I'm happy.
Robert
--
Robert Cernansky
E-mail: hslists2@zoznam.sk
Jabber: HS@jabber.sk
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-user] SMBBrowser for automount
2006-02-10 15:16 ` Robert Cernansky
@ 2006-02-10 15:29 ` CapSel
2006-02-10 16:19 ` CapSel
1 sibling, 0 replies; 9+ messages in thread
From: CapSel @ 2006-02-10 15:29 UTC (permalink / raw
To: gentoo-user
Thank you very much Robert, I'll try it right away.
On 2/10/06, Robert Cernansky <hslists2@zoznam.sk> wrote:
> On Fri, 10 Feb 2006 11:49:32 +0100 CapSel <capsel@gmail.com> wrote:
>
> C> This is my script that scans configured subnetwork for guest shares,
> C> makes entries for automount and restarts it.
> C>
> C> Is this script helpful to someone? Is it worth to continue making it,
> C> or is there a better way to allow normal programs to browse smb
> C> network.
>
> In the past I've also used similar script to mount smb shares. But recently
> I've discovered SMBNetFS (http://smbnetfs.airm.net/) and I'm happy.
>
> Robert
>
>
> --
> Robert Cernansky
> E-mail: hslists2@zoznam.sk
> Jabber: HS@jabber.sk
>
> --
> gentoo-user@gentoo.org mailing list
>
>
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-user] SMBBrowser for automount
2006-02-10 15:16 ` Robert Cernansky
2006-02-10 15:29 ` CapSel
@ 2006-02-10 16:19 ` CapSel
2006-02-10 21:38 ` Re[2]: " Robert Cernansky
1 sibling, 1 reply; 9+ messages in thread
From: CapSel @ 2006-02-10 16:19 UTC (permalink / raw
To: gentoo-user
On 2/10/06, Robert Cernansky <hslists2@zoznam.sk> wrote:
> On Fri, 10 Feb 2006 11:49:32 +0100 CapSel <capsel@gmail.com> wrote:
>
> C> This is my script that scans configured subnetwork for guest shares,
> C> makes entries for automount and restarts it.
> C>
> C> Is this script helpful to someone? Is it worth to continue making it,
> C> or is there a better way to allow normal programs to browse smb
> C> network.
>
> In the past I've also used similar script to mount smb shares. But recently
> I've discovered SMBNetFS (http://smbnetfs.airm.net/) and I'm happy.
>
> Robert
>
>
> --
> Robert Cernansky
> E-mail: hslists2@zoznam.sk
> Jabber: HS@jabber.sk
>
> --
> gentoo-user@gentoo.org mailing list
>
>
I did everything as on their page but I don't see any dirs or files
inside. When I type cd komputer-name it shows shares, but I wanted to
also see computer names as they wrote on page.
Do you know how to force it?
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re[2]: [gentoo-user] SMBBrowser for automount
2006-02-10 16:19 ` CapSel
@ 2006-02-10 21:38 ` Robert Cernansky
2006-02-11 11:46 ` CapSel
0 siblings, 1 reply; 9+ messages in thread
From: Robert Cernansky @ 2006-02-10 21:38 UTC (permalink / raw
To: gentoo-user
On Fri, 10 Feb 2006 17:19:39 +0100 CapSel <capsel@gmail.com> wrote:
C> > In the past I've also used similar script to mount smb shares. But recently
C> > I've discovered SMBNetFS (http://smbnetfs.airm.net/) and I'm happy.
C> >
C> I did everything as on their page but I don't see any dirs or files
C> inside. When I type cd komputer-name it shows shares, but I wanted to
C> also see computer names as they wrote on page.
C> Do you know how to force it?
In my case I see (I have mounted it in /mnt/smb):
$ ls /mnt/smb/
<WORKGROUP>
$ ls /mnt/smb/<WORKGROUP>
PC1 PC2 PC3 ...
It is also possible omit <WORGROUP>, for example:
$ ls /mnt/smb/PC1
share1 share2 ...
I did not force it in any way. Did you specify your workgorup/domain in
config file?
Robert
--
Robert Cernansky
E-mail: hslists2@zoznam.sk
Jabber: HS@jabber.sk
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Re[2]: [gentoo-user] SMBBrowser for automount
2006-02-10 21:38 ` Re[2]: " Robert Cernansky
@ 2006-02-11 11:46 ` CapSel
2006-02-11 16:03 ` Re[4]: " Robert Cernansky
0 siblings, 1 reply; 9+ messages in thread
From: CapSel @ 2006-02-11 11:46 UTC (permalink / raw
To: gentoo-user
On 2/10/06, Robert Cernansky <hslists2@zoznam.sk> wrote:
>
> In my case I see (I have mounted it in /mnt/smb):
>
> $ ls /mnt/smb/
> <WORKGROUP>
>
> $ ls /mnt/smb/<WORKGROUP>
> PC1 PC2 PC3 ...
>
> It is also possible omit <WORGROUP>, for example:
>
> $ ls /mnt/smb/PC1
> share1 share2 ...
>
> I did not force it in any way. Did you specify your workgorup/domain in
> config file?
capsel@capsel ~ $ smbnetfs ./smb
SMBNetFs-0.3.3
capsel@capsel ~ $ cd smb
capsel@capsel ~/smb $ ls
Maybe I missed something but there is no option in smbnetfs.conf to
specify workgroup, it's only specified in smb.conf which I linked from
/etc/samba.
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re[4]: [gentoo-user] SMBBrowser for automount
2006-02-11 11:46 ` CapSel
@ 2006-02-11 16:03 ` Robert Cernansky
2006-02-11 16:45 ` CapSel
0 siblings, 1 reply; 9+ messages in thread
From: Robert Cernansky @ 2006-02-11 16:03 UTC (permalink / raw
To: gentoo-user
On Sat, 11 Feb 2006 12:46:36 +0100 CapSel <capsel@gmail.com> wrote:
C> On 2/10/06, Robert Cernansky <hslists2@zoznam.sk> wrote:
C> >
C> > In my case I see (I have mounted it in /mnt/smb):
C> >
C> > $ ls /mnt/smb/
C> > <WORKGROUP>
C> >
C> > $ ls /mnt/smb/<WORKGROUP>
C> > PC1 PC2 PC3 ...
C> >
C> > It is also possible omit <WORGROUP>, for example:
C> >
C> > $ ls /mnt/smb/PC1
C> > share1 share2 ...
C> >
C> > I did not force it in any way. Did you specify your workgorup/domain in
C> > config file?
C>
C> capsel@capsel ~ $ smbnetfs ./smb
C> SMBNetFs-0.3.3
C>
C> capsel@capsel ~ $ cd smb
C> capsel@capsel ~/smb $ ls
C>
C> Maybe I missed something but there is no option in smbnetfs.conf to
C> specify workgroup, it's only specified in smb.conf which I linked from
C> /etc/samba.
Strange. It is corect to specify workgroup in ~/.smb/smb.conf (or copy it
from /etc/samba) so your configs are probably OK. Do you have "fuse" module
loaded or compiled into kernel?
--
Robert Cernansky
E-mail: hslists2@zoznam.sk
Jabber: HS@jabber.sk
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Re[4]: [gentoo-user] SMBBrowser for automount
2006-02-11 16:03 ` Re[4]: " Robert Cernansky
@ 2006-02-11 16:45 ` CapSel
2006-02-11 18:53 ` Re[6]: " Robert Cernansky
0 siblings, 1 reply; 9+ messages in thread
From: CapSel @ 2006-02-11 16:45 UTC (permalink / raw
To: gentoo-user
On 2/11/06, Robert Cernansky <hslists2@zoznam.sk> wrote:
>
> Strange. It is corect to specify workgroup in ~/.smb/smb.conf (or copy it
> from /etc/samba) so your configs are probably OK. Do you have "fuse" module
> loaded or compiled into kernel?
Yes, I do have it. smbnetfs works at least when I 'cd' to computer
name from my LAN, but when I 'cd ..' from it there is still nothing. I
noticed that when I 'cd' to my workgroup it stays but inside there is
only my router with smbd running and no other computers even after
hour of testing (restarting computers, smbd on my router...).
So it somekind of works, like windows :)
Thanks for help
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re[6]: [gentoo-user] SMBBrowser for automount
2006-02-11 16:45 ` CapSel
@ 2006-02-11 18:53 ` Robert Cernansky
0 siblings, 0 replies; 9+ messages in thread
From: Robert Cernansky @ 2006-02-11 18:53 UTC (permalink / raw
To: gentoo-user
On Sat, 11 Feb 2006 17:45:31 +0100 CapSel <capsel@gmail.com> wrote:
C> On 2/11/06, Robert Cernansky <hslists2@zoznam.sk> wrote:
C> >
C> > Strange. It is corect to specify workgroup in ~/.smb/smb.conf (or copy it
C> > from /etc/samba) so your configs are probably OK. Do you have "fuse" module
C> > loaded or compiled into kernel?
C>
C> Yes, I do have it. smbnetfs works at least when I 'cd' to computer
C> name from my LAN, but when I 'cd ..' from it there is still nothing. I
C> noticed that when I 'cd' to my workgroup it stays but inside there is
C> only my router with smbd running and no other computers even after
C> hour of testing (restarting computers, smbd on my router...).
C> So it somekind of works, like windows :)
Yeah, they say on homepage that it behaves like in windows, so that's it. ;-)
One more thing - We're using WINS server on our network. My ~/.smb/smb.conf
looks like (replace <WORKGROUP> and <WINS_IP> with your values):
# cat ~/.smb/smb.conf
[global]
workgroup = <WORKGROUP>
encrypt passwords = yes
wins server = <WINS_IP>
dos charset = 852
unix charset = utf-8
--
Robert Cernansky
E-mail: hslists2@zoznam.sk
Jabber: HS@jabber.sk
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2006-02-11 18:59 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-10 10:49 [gentoo-user] SMBBrowser for automount CapSel
2006-02-10 15:16 ` Robert Cernansky
2006-02-10 15:29 ` CapSel
2006-02-10 16:19 ` CapSel
2006-02-10 21:38 ` Re[2]: " Robert Cernansky
2006-02-11 11:46 ` CapSel
2006-02-11 16:03 ` Re[4]: " Robert Cernansky
2006-02-11 16:45 ` CapSel
2006-02-11 18:53 ` Re[6]: " Robert Cernansky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox