summaryrefslogtreecommitdiffstats
path: root/linhes/linhes-web/website/contents/list_exports.py
diff options
context:
space:
mode:
Diffstat (limited to 'linhes/linhes-web/website/contents/list_exports.py')
-rwxr-xr-xlinhes/linhes-web/website/contents/list_exports.py85
1 files changed, 85 insertions, 0 deletions
diff --git a/linhes/linhes-web/website/contents/list_exports.py b/linhes/linhes-web/website/contents/list_exports.py
new file mode 100755
index 0000000..79c2c38
--- /dev/null
+++ b/linhes/linhes-web/website/contents/list_exports.py
@@ -0,0 +1,85 @@
+#!/usr/bin/python2
+import subprocess
+
+def nfs_export_list():
+ nfslist = []
+ exportfile = "/etc/exports"
+ proc = subprocess.Popen(["showmount", "-a"] , stdout=subprocess.PIPE,stderr=subprocess.PIPE)
+ stdout,stderr = proc.communicate()
+ rc = proc.returncode
+ if rc == 0:
+ try:
+ f = open(exportfile,"r")
+ for line in f.readlines():
+ if line.startswith("#"):
+ continue
+ item = line.split()
+ if len(item) <= 1 :
+ continue
+ nfslist.append(item)
+ except :
+ pass
+ else:
+ nfslist.append(["NFS server is not running",'NFS server is not running'])
+ return nfslist
+
+
+def smb_share_list():
+ smblist=[]
+
+ proc = subprocess.Popen(["smbclient", "-L", "\\localhost" , "-N"], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
+ stdout,stderr = proc.communicate()
+ outstuff = stderr.split("\n")
+ for line in outstuff:
+ try:
+ heading1 = line.split()[0]
+ except:
+ continue
+ #print heading1
+ #print heading1.find("Domain")
+ if heading1.find("Domain") > -1 :
+ #smblist.append('')
+ smblist.append(heading1)
+ break
+
+ outstuff = stdout.split("\n")
+ for line in outstuff:
+ try:
+ heading1,heading2 = line.split()
+ except:
+ continue
+ if heading1 == "Server" and heading2 == "Comment":
+ break
+ smblist.append(line)
+
+ return smblist
+
+
+nfslist = nfs_export_list()
+smblist = smb_share_list()
+
+
+print "</br>"
+print "<h2>__________ NFS Shares __________</h2>"
+print "</br>"
+print '<ul id="navlist">'
+for sharename in nfslist:
+ if sharename[1].find("noaccess") > -1 :
+ print "<h3>%s \t no access</h3>" %sharename[0]
+ else:
+ print "<li>%s</li>" %sharename[0]
+
+print '</ul>'
+
+print "</br>"
+print "<h2>__________ SMB Shares __________</h2>"
+print "</br>"
+print '<ul id="navlist">'
+if len(smblist) == 0:
+ print "<h3>Samba is not running or no shares are listed</h3>"
+ print "</br>"
+else:
+ for sharename in smblist:
+ print "<li>%s</li>" %(sharename.split()[0])
+
+print '</ul>'