summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--abs/core/supplemental-web/PKGBUILD4
-rwxr-xr-xabs/core/supplemental-web/cgi/cardlist.cgi16
-rwxr-xr-xabs/core/supplemental-web/contents/cardmap.shtml11
-rw-r--r--abs/core/supplemental-web/contents/frame.css20
-rw-r--r--abs/core/supplemental-web/contents/header.html1
-rwxr-xr-xabs/core/supplemental-web/contents/list_cardmap.py132
-rw-r--r--abs/core/supplemental-web/contents/process.py124
-rw-r--r--abs/core/supplemental-web/supplemental-web.install1
-rw-r--r--abs/core/supplemental-web/supplemental_web.rules1
9 files changed, 283 insertions, 27 deletions
diff --git a/abs/core/supplemental-web/PKGBUILD b/abs/core/supplemental-web/PKGBUILD
index d3f82d7..257abdd 100644
--- a/abs/core/supplemental-web/PKGBUILD
+++ b/abs/core/supplemental-web/PKGBUILD
@@ -1,7 +1,7 @@
pkgbase=supplemental-web
pkgname=('supplemental-web' 'supplemental-web-slave')
pkgver=1.0
-pkgrel=36
+pkgrel=39
arch=('i686' 'x86_64')
backup=('extra.cfg.txt')
@@ -79,4 +79,4 @@ md5sums=('521714803b5a3df529f0fc5f853c0d55'
'26598fd1dfaf5d36d7b1f9620da5543c'
'fabf825ca07502db40d78f0aae15f90b'
'b41eeb0f0aa67ea06aedff61e53fa774'
- 'c90d7a015783316af2256a37bece62ce')
+ 'd7be6bc265b2b9e775b090b6ac2448da')
diff --git a/abs/core/supplemental-web/cgi/cardlist.cgi b/abs/core/supplemental-web/cgi/cardlist.cgi
new file mode 100755
index 0000000..5ba7343
--- /dev/null
+++ b/abs/core/supplemental-web/cgi/cardlist.cgi
@@ -0,0 +1,16 @@
+#!/usr/bin/env python2
+print "Content-type: text/html"
+print
+exportfile = '/etc/udev/mv-persistent-video.description'
+try:
+ f = open(exportfile,"r")
+ for line in f.readlines():
+ if line.startswith("#"):
+ continue
+ item = line.split(":")
+ if len(item) <= 1 :
+ continue
+ print line
+except :
+ print ""
+ print "Couldn't read static tuner map"
diff --git a/abs/core/supplemental-web/contents/cardmap.shtml b/abs/core/supplemental-web/contents/cardmap.shtml
new file mode 100755
index 0000000..89013c0
--- /dev/null
+++ b/abs/core/supplemental-web/contents/cardmap.shtml
@@ -0,0 +1,11 @@
+<html>
+ <head>
+ <style type="text/css">@import "/frame.css";</style>
+ </head>
+ <body>
+ <h1> List of detected cards and static device path. </h1>
+ <br>
+ <!--#exec cmd=" MYTHCONFDIR=/usr/share/mythtv /data/srv/httpd/htdocs/list_cardmap.py" -->
+ </body>
+</html>
+
diff --git a/abs/core/supplemental-web/contents/frame.css b/abs/core/supplemental-web/contents/frame.css
index eb6db98..42877dd 100644
--- a/abs/core/supplemental-web/contents/frame.css
+++ b/abs/core/supplemental-web/contents/frame.css
@@ -22,7 +22,7 @@ body {
//-o-background-size: 1000px 10000px;
//-moz-background-size: 1000px 10000px, 500px, 500px;
//-webkit-background-size: 1000px 10000px, 500px 500px;
-
+
margin: 10;
margin-left:40px;
padding: 10;
@@ -55,11 +55,29 @@ body {
/*background: #D9D9D9;*/
margin-left:60px;
}
+
#column {
float: right; /* Our column is going to be right aligned */
width: 320px; /* Our total width - content width is 260px */
/*background: #8A8AE6;*/
}
+
+#resultbox {
+ width: 700px ;
+ margin-left: auto ;
+ margin-right: auto ;
+ border-width: .2em;
+ border-style: dotted;
+ border-color: #900;
+ text-align: left;
+ padding-left: 30;
+ padding-right: 30;
+ padding-top: 10;
+ padding-bottom: 10;
+
+}
+
+
#footer {
clear: both; /* We have to clear our floats */
width: 760px; /* We need to set the width on the footer since it's outside the mainContainer, and therefor isn't controlled by it */
diff --git a/abs/core/supplemental-web/contents/header.html b/abs/core/supplemental-web/contents/header.html
index a75d57c..e08cbda 100644
--- a/abs/core/supplemental-web/contents/header.html
+++ b/abs/core/supplemental-web/contents/header.html
@@ -40,6 +40,7 @@ function remyth()
<li><a href="xymon" >System &#187;</a>
<ul>
+ <li><a href="/cardmap.shtml" >List static dev nodes for tuners </a></li>
<li><a href="/exports.shtml" >List file shares </a></li>
<li><a href="/xymon" >System Health</a></li>
<li><a href="/logs/">System Logs</a></li>
diff --git a/abs/core/supplemental-web/contents/list_cardmap.py b/abs/core/supplemental-web/contents/list_cardmap.py
new file mode 100755
index 0000000..0c28e0e
--- /dev/null
+++ b/abs/core/supplemental-web/contents/list_cardmap.py
@@ -0,0 +1,132 @@
+#!/usr/bin/python2
+import subprocess
+import socket,sys
+import urllib2
+from MythTV import MythBE,MythDB,MythLog
+
+def find_slave_hosts():
+ slave_hosts=[]
+ try:
+ be=MythBE()
+ db = MythDB()
+ cursor = db.cursor()
+ except:
+ return slave_hosts
+
+ try:
+ cmd="select hostname from settings where data='Slave_backend';"
+ cursor.execute(cmd)
+ results=cursor.fetchall()
+ for i in results:
+ slave_hosts.append(i[0])
+ except:
+ return slave_hosts
+ return slave_hosts
+
+def read_local_tuner():
+ tuner_list = []
+ exportfile = '/etc/udev/mv-persistent-video.description'
+ try:
+ f = open(exportfile,"r")
+ for line in f.readlines():
+ if line.startswith("#"):
+ continue
+ item = line.split(":")
+ if len(item) <= 1 :
+ continue
+ tuner_list.append(item)
+ except :
+ tuner_list.append(["notfound","notfound","notfound"])
+ return tuner_list
+
+def parse_remote_tuners(the_page):
+ tuner_list=[]
+ the_page = the_page.split("\n")
+ try:
+ for line in the_page:
+ if line.startswith("#"):
+ continue
+ item = line.split(":")
+ if len(item) <= 1 :
+ continue
+ tuner_list.append(item)
+ except :
+ tuner_list.append(["notfound","notfound","notfound"])
+ return tuner_list
+
+
+def remote_tuners(slave_host):
+ default_timeout = 3
+ socket.setdefaulttimeout(default_timeout)
+ slaveurl="http://%s:1337/cardlist.cgi" %slave_host
+ req = urllib2.Request(slaveurl)
+ response = urllib2.urlopen(req)
+ the_page = response.read()
+ #the_page="abc\nadef\na"
+ if the_page :
+ tuner_list = parse_remote_tuners(the_page)
+ print "</br>"
+ for statictuner in tuner_list:
+ if statictuner[1].find("notfound") > -1 :
+ print "Couldn't open tuner map"
+ print "</br>"
+ else:
+ print "<li> %s&nbsp;&nbsp;&nbsp%s" %(statictuner[1] ,statictuner[0])
+ print "</br>"
+ print "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static device node: %s" %statictuner[2]
+ print "</br>"
+ print "</br>"
+ else:
+ print "<li> no tuners found &nbsp;&nbsp;&nbsp"
+
+ return
+
+
+
+mbelist = read_local_tuner()
+slave_hosts = find_slave_hosts()
+
+#--------------MBE-------------
+hostname = socket.gethostname()
+print "<h2>"
+print "__________ %s __________" %(hostname)
+print "</h2>"
+print "</br>"
+print '''
+<div id="navcontainer">
+<ul id="navlist">
+'''
+
+for statictuner in mbelist:
+ if statictuner[1].find("notfound") > -1 :
+ print "Couldn't open tuner map"
+ print "</br>"
+ else:
+ print "<li> %s&nbsp;&nbsp;&nbsp%s" %(statictuner[1] ,statictuner[0])
+ print "</br>"
+ print "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static device node: %s" %statictuner[2]
+ print "</br>"
+ print "</br>"
+
+print '''</ul> </div>'''
+
+#---------Slave tuners
+for i in slave_hosts:
+ print "<h2>"
+ print "__________ %s __________" %(i)
+ print "</h2>"
+ print "</br>"
+ print '''
+ <div id="navcontainer">
+ <ul id="navlist" '''
+ #remote_tuners(i)
+ try:
+ remote_tuners(i)
+ pass
+ except:
+ print "</br>"
+ print "<li> Problem reading list from %s" %i
+ pass
+ print ''' </ul> </div>'''
+
+
diff --git a/abs/core/supplemental-web/contents/process.py b/abs/core/supplemental-web/contents/process.py
index 22ffb0f..988ebfc 100644
--- a/abs/core/supplemental-web/contents/process.py
+++ b/abs/core/supplemental-web/contents/process.py
@@ -4,6 +4,8 @@ import cgi
import os
import socket
import time
+import StringIO
+
try:
import cgitb
cgitb.enable()
@@ -45,10 +47,10 @@ def getform(theform, valuelist, notpresent='', nolist=False):
data[field] = notpresent
else:
# the field is present
- print type(theform[field])
+ #print type(theform[field])
if type(theform[field]) != type([]):
# is it a list or a single item
- print type(theform[field])
+ #print type(theform[field])
data[field] = theform[field].value
else:
if not nolist:
@@ -100,18 +102,43 @@ def go_backup(myhost):
myhostname = socket.gethostname()
results="Nothing happened"
command= "sudo /usr/LH/bin/lh_system_backup_job"
- print command
- command2="sleep 1; /home/xymon/server/ext/hbnotes.py"
+ #print command
+
+ command2="sleep 1; sudo -u nobody /home/xymon/server/ext/hbnotes.py"
results=os.popen(command,'r')
os.popen(command2,'r')
return results
-def go_restore(restorefile,myhost):
+def go_download_backup(dl_file):
+ # Actual File Content will go hear.
+ dlf = "/data/storage/disk0/backup/system_backups/%s" %dl_file
+ fo = open(dlf, "rb")
+
+ str = fo.read()
+ fo.close()
+
+ # HTTP Header
+ print "Content-Type:application/octet-stream; name=\"%s\"\r\n;" %(dl_file)
+ print "Content-Disposition: attachment; filename=\"%s\"\r\n;" %(dl_file)
+ print "Content-Length: %d" % len(str)
+ print ""
+
+ print str
+ return results
+
+
+def go_restore(restorefile,myhost,prestore):
myhostname = socket.gethostname()
+ psc = ''
+ if prestore == "on":
+ psc = "partial"
+
+
if myhostname.strip() == myhost.strip():
- localcommand="sudo /usr/LH/bin/lh_system_restore_job "
- command= localcommand + restorefile
+ command="sudo /usr/LH/bin/lh_system_restore_job %s %s" %(restorefile , psc)
+
+
else:
#this should never execute
@@ -119,15 +146,37 @@ def go_restore(restorefile,myhost):
sshcmd+=myhost.strip()
cmd=' "sudo /usr/bin/restore_job.sh " '
command=sshcmd + cmd + restorefile + " 2>&1 "
- print command
+ #print command
results=os.popen(command,'r')
return results
+def go_upload(up_file):
+ saveDir = "/data/storage/disk0/backup/system_backups/"
+ fPath = "%s/%s" % (saveDir, up_file.filename)
+ buf = up_file.file.read()
+ bytes = len(buf)
+ sFile = open(fPath, 'wb')
+ sFile.write(buf)
+ sFile.close()
+ results=["<b>%s</b> uploaded (%d bytes)." %(up_file.filename, bytes)]
+ line = '''The backup has been uploaded and is now available for restore.
+ To restore from the file, check "Restore database" then select the file from the drop down menu'''
+
+
+ results.append(line)
+
+ command2="sleep 1; sudo -u nobody /home/xymon/server/ext/hbnotes.py"
+ os.popen(command2,'r')
+
+
+ return results
+
+
def go_optimize(myhost):
#myhostname = socket.gethostname()
#if myhostname.strip() == myhost.strip():
command="/usr/LH/bin/optimize_mythdb.py"
- print command
+ #print command
results=os.popen(command,'r')
#else:
#results='This host does not run a database'
@@ -137,17 +186,17 @@ def go_update(myhost,update_type):
cmd=" call pacman update_system "
cmd+=update_type
command="/usr/bin/func \"" + myhost.strip() + "*\" " + cmd
- print command
+ #print command
results=os.popen(command,'r')
return results
def go_updateall(allupdate_type):
- cmd=" sudo /usr/bin/update_system_all "
- cmd+=allupdate_type
- command= cmd + " 2>&1 "
- results=os.popen(command,'r')
- return results
+ cmd=" sudo /usr/bin/update_system_all "
+ cmd+=allupdate_type
+ command= cmd + " 2>&1 "
+ results=os.popen(command,'r')
+ return results
def go_shutdown(myhost):
@@ -209,6 +258,9 @@ def go_kill(myhost,kill_type):
return results
+
+
+
mainpage = '''
<html><head>
<style type="text/css">@import "/frame.css";</style>
@@ -223,11 +275,12 @@ error = '''
result = '''
<h1>%s of %s</h1>
'''
-possible_parameters = ['param1', 'param2', 'param3', 'param4','hiddenparam','param5','param6']
+possible_parameters = ['param1', 'param2', 'param3', 'param4','hiddenparam','param5','param6','param7','uFile','param8']
if __name__ == '__main__':
- cgiprint(contentheader) # content header
- cgiprint() # finish headers with blank line
+
+ #cgiprint(contentheader) # content header
+ #cgiprint() # finish headers with blank line
theform = cgi.FieldStorage()
#print theform
@@ -246,19 +299,31 @@ if __name__ == '__main__':
hidden = formdict['hiddenparam']
all_update_type=formdict['param5']
kill_type = formdict['param6']
+ dl_file = formdict['param7']
+ try:
+ up_file = theform['uFile']
+ except:
+ pass
+ try:
+ prestore = theform['param8'].value
+ except:
+ prestore = "off"
body = result % (radio, hidden)
- print mainpage % body
+ #print mainpage % body
selection=radio
myhost=hidden.lower()
if selection == "Restore":
- mylogfile=go_restore(name,myhost)
+ mylogfile=go_restore(name,myhost,prestore)
elif selection == "Backup":
mylogfile=go_backup(myhost)
+ elif selection == "Dbackup":
+ mylogfile=go_download_backup(dl_file)
+
elif selection == "Update":
mylogfile=go_update(myhost,update_type)
elif selection == "Shutdown":
@@ -275,14 +340,25 @@ if __name__ == '__main__':
mylogfile=go_shutdownall()
elif selection == "Kill":
mylogfile=go_kill(myhost,kill_type)
+ elif selection == "Upload":
+ mylogfile = go_upload(up_file)
+
+
+ cgiprint(contentheader) # content header
+ cgiprint() # finish headers with blank line
+ print mainpage % body
+
+ #box=''' </br> </br>
+ #<div style="border: 1px solid #aaa; width:700px; height:700px; overflow:auto; color:#FFF;text-align:left;">
+ #<code id="box" style="display: block; height: 700px; width: 700px; overflow: auto;">
+ #'''
+ box='''</br> </br>
+ <div id="resultbox" >
- box=''' </br> </br>
- <div style="border: 1px solid #aaa; width:700px; height:700px; overflow:auto; color:#FFF;text-align:left;">
- <code id="box" style="display: block; height: 700px; width: 700px; overflow: auto;">
'''
endbox='''
- </code>
+
</div>
'''
javascript='''
diff --git a/abs/core/supplemental-web/supplemental-web.install b/abs/core/supplemental-web/supplemental-web.install
index 21946b2..55101ba 100644
--- a/abs/core/supplemental-web/supplemental-web.install
+++ b/abs/core/supplemental-web/supplemental-web.install
@@ -9,6 +9,7 @@ pre_install() {
# arg 1: the new package version
post_install() {
setfacl -m u:http:rx /home/mythtv/
+ setfacl -m u:http:rwx /data/storage/disk0/backup/system_backups/
gen_light_include.py
echo "==> Forcing a re-read of lighttpd's configuration file."
echo ""
diff --git a/abs/core/supplemental-web/supplemental_web.rules b/abs/core/supplemental-web/supplemental_web.rules
index f4d477b..f860c3e 100644
--- a/abs/core/supplemental-web/supplemental_web.rules
+++ b/abs/core/supplemental-web/supplemental_web.rules
@@ -1,2 +1,3 @@
#These rules are used by supplemental-web
http ALL = NOPASSWD:/usr/sbin/etherwake
+http ALL = (nobody) NOPASSWD:/home/xymon/server/ext/hbnotes.py