Sambastatus: my first module for nethserver

Hm, as @robb reported, the command and the Share tab is working for me in Windows 10 and Firefox but if the command result is empty there may be another problem…

Thanks for your effort!

The machines joined to domain was not working for me because they’re not listed in /var/lib/nethserver/home.
I added /usr/bin/net to sudoers and changed the command in the Joined.php template.

/etc/sudoers.d/30_nethserver_sambastatus:

#
# 30_nethserver_sambastatus
#
%srvmgr ALL=NOPASSWD: /usr/bin/smbstatus, /usr/bin/net

/usr/share/nethesis/NethServer/Template/SambaStatus/Joined.php:

$command = "sudo /usr/bin/net ads search -P objectClass=Computer | grep 'cn: ' | cut -f 2 -d ' ' | sort";
$pc = shell_exec($command);
$arrpc = explode("\n", $pc);
1 Like

Ops! I wasn’t thinking and do those modifications…
but, that changes aren’t for me, right?

Because I see machines listed in /var/lib/nethserver/home

Yes but maybe I have a problem because my machines are not listed in /var/lib/nethserver/home. I use local AD provider and login from my Windows machines is working. Do you use linux clients or remote AD?

Using local AD (avion.lan), some Windows computers joined and logged.
Mine is a virtualbox windows 8.
Some other are real hardware that are logged just one is using the shared folders.

I’m working on this NethServer AD (inside proxmox) is prepared to replace a really old Windows 2000 SBS PDC.
Something that I’m notice right now, the folder shows even computers that aren’t joined to this domain (avion.lan), those computers still are joined in the old one (avion.local)
:upside_down_face::thinking:

EDIT1:
If I edit the script Joined.php; I need to do something for this to work or is used instantly after being edited?

EDIT2:
If I run the php script from the terminal, I got this error:

php /usr/share/nethesis/NethServer/Template/SambaStatus/Joined.php

PHP Notice: Undefined variable: view in /usr/share/nethesis/NethServer/Template/SambaStatus/Joined.php on line 2
PHP Fatal error: Call to a member function header() on a non-object in /usr/share/nethesis/NethServer/Template/SambaStatus/Joined.php on line 2

It’s working instantly but it does not solve your “Share” problem, it’s just for the joined computers.

It’s for running a browser and not for running in terminal.

Right! :upside_down_face:

Now I understand a little more, inside “/usr/share/nethesis/NethServer/Template/” are located the scripts that run in the SambaStatus module".

Now I see the source for “Share.php” if I run the “smbstatus -S” I just see something like this:

> Service      pid > Machine       Connected at                     Encryption   Signing
> sistemas     14126   192.16b.xy.23 Tue Oct  2 10:32:43 AM 2018 MDT  -            -           
> movilizacion 7285    192.16b.xx.90 Fri Oct  5 08:16:52 AM 2018 MDT  -            -           
> sistemas     7380    192.16b.xx.25 Fri Oct  5 08:18:37 AM 2018 MDT  -            -           
> sistemas     7010    192.16b.xx.18 Fri Oct  5 08:12:02 AM 2018 MDT  -            -           
> movilizacion 7250    192.16b.xx2.91 Fri Oct  5 08:16:11 AM 2018 MDT  -            - 

The script for Share runs
$command= $sudo . “smbstatus -S | grep CEST | awk '{print $1 “\t” $3 “\t” $4”/"$5"/"$6 " " $7}’ | sort";

And there is no “CEST” info to show.

3 Likes

You found the bug, it’s not compatible to other timezones!

3 Likes

LOL :rofl:

image

1 Like

How did you solve it?

You solved.
I just simple change CEST for MDT my time zone:
$command= $sudo . “smbstatus -S | grep MDT | awk '{print $1 “\t” $3 “\t” $4”/"$5"/"$6 " " $7}’ | sort";

:upside_down_face:

2 Likes

What about this? Compatible to any timezone:

$command= $sudo . "smbstatus -S | grep `date +%Z` | awk '{print $1 \"\t\" $3 \"\t\" $4\"/\"$5\"/\"$6 \" \" $7}' | sort";
3 Likes

It works!

Now I wonder why I don’t see the “filenames” in the “Locked” tab
It only shows the Directories in “File Name”:
image

Right now I have an image file opened since I began to post here today.


Stop the press! It shows filenames now!
I just start browsing for more image files and they shows now:


Then after some moments (writing this comment) again the filenames disappear…
This is an expected behavior?
image

1 Like

@gecco I guess you should modify your code after @mrmarkuz suggestion?

1 Like

i fix it!

new version, with all patch and bugfix, is ready
http://minucci.net/nethserver/nethserver-sambastatus-7.0-2.x86_64.rpm

3 Likes

Too bad I can not install it, probably gives a problem with the language file!

[root@openzwo ~]# rpm -i nethserver-sambastatus-7.0-2.x86_64.rpm
    	file /usr/share/nethesis/NethServer/Language/de from install of nethserver-sambastatus-7.0-2.x86_64 conflicts with file from package nethserver-lang-de-1.2.15-1.ns7.noarch
    [root@openzwo ~]#

I got this messages:

rpm -i nethserver-sambastatus-7.0-2.x86_64.rpm
file /etc/sudoers.d/30_nethserver_sambastatus from install of nethserver-sambastatus-7.0-2.x86_64 conflicts with file from package nethserver-sambastatus-7.0-1.x86_64
file /usr/share/nethesis/NethServer/Language/en/NethServer_Module_SambaStatus.php from install of nethserver-sambastatus-7.0-2.x86_64 conflicts with file from package nethserver-sambastatus-7.0-1.x86_64
file /usr/share/nethesis/NethServer/Language/it/NethServer_Module_SambaStatus.php from install of nethserver-sambastatus-7.0-2.x86_64 conflicts with file from package nethserver-sambastatus-7.0-1.x86_64
file /usr/share/nethesis/NethServer/Template/SambaStatus/Joined.php from install of nethserver-sambastatus-7.0-2.x86_64 conflicts with file from package nethserver-sambastatus-7.0-1.x86_64
file /usr/share/nethesis/NethServer/Template/SambaStatus/Share.php from install of nethserver-sambastatus-7.0-2.x86_64 conflicts with file from package nethserver-sambastatus-7.0-1.x86_64

I can confirm this issue, as soon as german language is installed the update of sambastatus does not work.
It’s not possible to have German language and sambastatus installed.

I didn’t get these messages. As a workaround you may try to remove sambastatus with yum remove nethserver-sambastatus and reinstall with yum install nethserver-sambastatus-7.0-2.x86_64.rpm.

I investigated but i don’t know where is the problem. If you want you can install this package http://minucci.net/nethserver/nethserver-sambastatus-7.0-3.x86_64.rpm and then add manually the “de” localization from github https://github.com/carlominucci/SambaStatus/tree/master/Language/de

2 Likes

Maybe because I manually edit the php scripts?
Tomorrow I’ll try your suggestions
Regards!