diff options
Diffstat (limited to 'abs/core/supplemental-web/contents')
25 files changed, 1378 insertions, 0 deletions
diff --git a/abs/core/supplemental-web/contents/calllog.py b/abs/core/supplemental-web/contents/calllog.py new file mode 100644 index 0000000..a96813e --- /dev/null +++ b/abs/core/supplemental-web/contents/calllog.py @@ -0,0 +1,66 @@ +#!/usr/bin/python +# import MySQL module + +import MySQLdb +import sys +import getopt +import socket + + +def main(argv): + grandtotal=0 + grandtotal_current=0 + db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="ncid") + # create a cursor + cursor = db.cursor() + # execute SQL statement + cursor.execute("select name,number,count(number) as '# calls' from cid group by number,name order by '# calls' DESC limit 20;") + result = cursor.fetchall() + + +#Top shows + #print '<div id="content"> <p></p>' + print '<div> <p></p>' + print '<table class="calllog">' + print "Top 20 callers" + searchstring='''<td> <a href="http://www.google.com/search?q=%s" > %s </a> </td> ''' + cursor.execute("select name,number,count(number) as '# calls' from cid group by number,name order by '# calls' DESC limit 20;") + result = cursor.fetchall() + for row in result: + print " <tr>" + #print " <td>",row[0],"</td>" + print searchstring % (row[0], row [0]) + print " <td>",row[2],"</td>" + #print " <td>",row[1],"</td>" + print searchstring % (row[1], row [1]) + print " </tr>" + #print "%40s %26s %10s" %(row[0],row[2],row[1]) + print "</table>" + print "</div>" +#Top categorys + + + print '<br>' + print '<br>' + #print '<div id="content"> <p></p>' + print '<div> <p></p>' + print '<table class="calllog">' + print "Last 20 calls" + print '<br>' + cursor.execute("select date,time,name,number from cid order by date(ts) DESC ,time DESC limit 20 ;" ) + result = cursor.fetchall() + for row in result: + print " <tr>" + print " <td> %s </td>" %(row[0]) + print " <td>",row[1],"</td>" + #print " <td>",row[2],"</td>" + print searchstring % (row[2], row [2]) + #print " <td>",row[3],"</td>" + print searchstring % (row[3], row [3]) + print " </tr>" +# print "%26s %26s %26s %26s " %(row[0],row[1],row[2],row[3]) + print "</table>" + print "</div>" + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/abs/core/supplemental-web/contents/calllog.shtml b/abs/core/supplemental-web/contents/calllog.shtml new file mode 100644 index 0000000..ddf3d88 --- /dev/null +++ b/abs/core/supplemental-web/contents/calllog.shtml @@ -0,0 +1,20 @@ +<html> +<head> +<style type="text/css">@import "/frame.css";</style> +</head> + +<body> +<div id="mainContainer"> +<!-- <div id="header"><p></p></div> + <div id="content"> + <p></p>--> + + <!--#exec cmd="/data/srv/httpd/htdocs/calllog.py" --> + + +</br> +</br> + +</body> +</html> + diff --git a/abs/core/supplemental-web/contents/count.py b/abs/core/supplemental-web/contents/count.py new file mode 100644 index 0000000..6d813c1 --- /dev/null +++ b/abs/core/supplemental-web/contents/count.py @@ -0,0 +1,89 @@ +#!/usr/bin/python +# import MySQL module + +import MySQLdb +import sys +import getopt +import socket + + +def main(argv): + grandtotal=0 + grandtotal_current=0 + db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg") + # create a cursor + cursor = db.cursor() + # execute SQL statement + cursor.execute("SELECT unix_timestamp(starttime),unix_timestamp(endtime),title FROM oldrecorded ORDER by starttime;") + result = cursor.fetchall() + + for row in result: + # print row[0], row[1] ,row [2] + start=row[0] + end=row[1] + if ( end > start ): + total = (end - start) /60 + grandtotal+=total + hours = grandtotal / 60.0 + days = hours / 24.0 + + cursor.execute("SELECT unix_timestamp(starttime),unix_timestamp(endtime),title FROM recorded where not (recgroup=(%s)) ORDER by starttime",("LiveTV")) + result_current = cursor.fetchall() + for row in result_current: + start=row[0] + end=row[1] + if ( end > start ): + total = (end - start) /60 + grandtotal_current+=total + hours_current = grandtotal_current / 60.0 + days_current = hours_current / 24.0 + + print '<div id="header">' + + print "<table>" + print " <tr>" + print " <td> Currently there are " , len(result_current) , " recorded programs. With a viewing time of %.2f days or %.2f hours. </td>" %(days_current,hours_current) + print " </tr>" + print "</table>" + print "</br> " + + print "<table>" + print " <tr>" + print " <td> Overall there have been " , len(result) , "shows recorded. With viewing time of %.2f days or %.2f hours </td>"%(days,hours) + print " </tr>" + print "</table>" + print '</div>' + print "</br> </br> " +#Top shows + print '<div id="content"> <p></p>' + print '<table class="sample">' + print "Top 20 Shows" + cursor.execute("select title,count(title),category as numtitle from oldrecorded group by title having (COUNT(title) > 1) order by (COUNT(title)) DESC limit 20;" ) + result = cursor.fetchall() + for row in result: + print " <tr>" + print " <td>",row[0],"</td>" + print " <td>",row[2],"</td>" + print " <td>",row[1],"</td>" + print " </tr>" + # print "%40s %26s %10s" %(row[0],row[2],row[1]) + print "</table>" + print "</div>" +#Top categorys + + print '<div id="column"></div>' + print '<table class="sample">' + print "Top 20 Categories" + cursor.execute("select category,count(category) as numtitle from oldrecorded group by category having (COUNT(category) > 1) order by (COUNT(category)) DESC limit 20; " ) + result = cursor.fetchall() + for row in result: + print " <tr>" + print " <td>",row[0],"</td>" + print " <td>",row[1],"</td>" + print " </tr>" + #print "%16s %16s" %(row[0],row[1]) + print "</table>" + print "</div>" + +if __name__ == "__main__": + main(sys.argv[1:])
\ No newline at end of file diff --git a/abs/core/supplemental-web/contents/docs.html b/abs/core/supplemental-web/contents/docs.html new file mode 100644 index 0000000..c4a934b --- /dev/null +++ b/abs/core/supplemental-web/contents/docs.html @@ -0,0 +1,65 @@ +<html> +<head> +<style type="text/css">@import "frame.css";</style> +</head> + +<body> +Package Management +</br> + +<div id="navcontainer"> +<ul id="navlist"> + <li>pacman -Sy to refresh pkg database</li> + <li>pacman -Ss $keyword to search pkg database</li> + <li>pacman -Su to update all install packages</li> + <li>pacman -S $pkg to update one pkg</li> + <li>pacman -h for a list of pacman operations .</li> + <li>pacman -S --help for a full list of options associated with the -S command.</li> +</ul> +</div> +<br> +Starting and stopping services. +<br> + +<div id="navcontainer"> +<ul id="navlist"> + <li>sv {stop,start,restart} frontend. This will start/stop the entire X proccess that runs mythfrontend</li> + <li>sv {stop,start,restart} mysql</li> + <li>sv {stop,start,restart} mythbackend</li> + <li>sv {stop,start,restart} lircd</li> +</ul> +<br> +</div> +<div id="navcontainer"> + Other Random notes +<br> +<ul id="navlist"> + <li>The root password is blank. You will not be able to remotely access this account until the password is set.</li> + <li>The mythtv account is locked, reset the password if you wish login with this account.</li> + <li>The mythtv account has full sudo privileges. </li> + <li>All access from public ip address are blocked. Edit /etc/hosts.deny /etc/hosts.allow to change this.</li> + <li>Mythfilldatabase will automaticlly run when mythbackend is started. If the last attempt was successful then it will skip this step and mythfilldatabase will run normally.</li> + <li>To keep a host from showing up in the network map, add it to: + /data/srv/hobbit/server/ext/ignoreclient.py + </li> + <li>remove "func" from bb-hosts to stop hobbit from running a func check on it </li> + <li>if /tmp/nomfe is present then mythfrontend will not restart </li> + <li>if /tmp/debug is present then mythfrontend and mythbackend will run with gdb. Debug packages will need to be installed for this to be useful </li> + + <li>create_master.sh will copy the contents of the cdrive to a "Gold" image for network/diskless installation. Dhcp server must be enabled for netboot to work, please turn off any other dhcp servers on your network. </li> + <li>On the misc screen the nfsmap section will accept entries pointing to different servers. For instance 192.168.1.5:nfsmap will pull the nfsmap file from the ip 192.168.1.5 (hostnames may also be used) </li> + <li>adding pkg names to /etc/pkgname.blacklist will stop MythVantage from autoinstalling a package.</li> +</div> +<br> +<div id="navcontainer"> + Menu Navigation +<br> + +<ul id="navlist"> + <li> <A HREF="images/classic-menugraph.png">Classic menu</A> </li> + <li> <A HREF="images/menu_diagram_color.png">Standard menu</A> </li> + <li> <A HREF="images/dvr_menugraph.png">DVR menu</A> </li> + +</body> +</html> + diff --git a/abs/core/supplemental-web/contents/error-handler.html b/abs/core/supplemental-web/contents/error-handler.html new file mode 100644 index 0000000..49e406f --- /dev/null +++ b/abs/core/supplemental-web/contents/error-handler.html @@ -0,0 +1,9 @@ +<html> +<head> +<style type="text/css">@import "/frame.css";</style> +</head> + +<body> +Module or page not found +</body> +</html>
\ No newline at end of file diff --git a/abs/core/supplemental-web/contents/error/hobbit.html b/abs/core/supplemental-web/contents/error/hobbit.html new file mode 100644 index 0000000..18450f2 --- /dev/null +++ b/abs/core/supplemental-web/contents/error/hobbit.html @@ -0,0 +1,11 @@ +<html> +<head> +<style type="text/css">@import "/frame.css";</style> +</head> + +<body> +Hobbit does not appear to be installed. +</br> +Please visit the MythVantage advanced screen to enable Hobbit. +</body> +</html> diff --git a/abs/core/supplemental-web/contents/error/mythweb.html b/abs/core/supplemental-web/contents/error/mythweb.html new file mode 100644 index 0000000..fe76a9a --- /dev/null +++ b/abs/core/supplemental-web/contents/error/mythweb.html @@ -0,0 +1,16 @@ +<html> +<head> +<style type="text/css">@import "/frame.css";</style> +</head> + +<body> +MythWeb does not appear to be installed. +</br> +To install MythWeb either +</br> +1) Visit the MythVantage advanced screen to enable mythweb. </br> +2) type "pacman -S mythweb-release-fixes" at the console. + + +</body> +</html> diff --git a/abs/core/supplemental-web/contents/error/phpadmin.html b/abs/core/supplemental-web/contents/error/phpadmin.html new file mode 100644 index 0000000..dbdd4d3 --- /dev/null +++ b/abs/core/supplemental-web/contents/error/phpadmin.html @@ -0,0 +1,28 @@ +<html> +<head> +<style type="text/css">@import "/frame.css";</style> +</head> + +<body> +phpMyAdmin is a tool written in PHP intended to handle the administration of MySQL over the Web. +</br> +Currently it's not installed,but if you wish to install phpmyadmin, type the following at a command prompt +</br> +</br> + +pacman -S phpmyadmin + +</br> +</br> +PHP must be enabled for phpMyAdmin. +</br> +The easiest way to enable php is to enable Mythweb under the advanced settings for MythVantage. +</br> +</br> +</br> + +Please be carefull, phpMyAdmin is a powerful tool and can easily mess with your settings. + + +</body> +</html> diff --git a/abs/core/supplemental-web/contents/error/status-404.html b/abs/core/supplemental-web/contents/error/status-404.html new file mode 100644 index 0000000..49e406f --- /dev/null +++ b/abs/core/supplemental-web/contents/error/status-404.html @@ -0,0 +1,9 @@ +<html> +<head> +<style type="text/css">@import "/frame.css";</style> +</head> + +<body> +Module or page not found +</body> +</html>
\ No newline at end of file diff --git a/abs/core/supplemental-web/contents/frame.css b/abs/core/supplemental-web/contents/frame.css new file mode 100644 index 0000000..eb6db98 --- /dev/null +++ b/abs/core/supplemental-web/contents/frame.css @@ -0,0 +1,193 @@ +* /* Our "universal rule" */ +{ + padding: 0; + margin: 0; + border: 0; +} +body { + background: url("page_background.jpg") repeat-y #9FA9B3; + +//background-color: #ebb81c; +//background-image: -webkit-gradient(linear, left top, left bottom, from(#ebb81c), to(#0072bc)); /* Saf4+, Chrome */ +//background-image: -webkit-linear-gradient(top, #ebb81c, #0072bc); /* Chrome 10+, Saf5.1+, iOS 5+ */ +//background-image: -moz-linear-gradient(top, #ebb81c, #0072bc) ; /* FF3.6 */ +//background-image: -moz-linear-gradient(top, #0072bc,#ebb81c) ; /* FF3.6 */ +//background-image: -ms-linear-gradient(top, #ebb81c, #0072bc); /* IE10 */ +//background-image: -o-linear-gradient(top, #ebb81c, #0072bc); /* Opera 11.10+ */ +//background-image: linear-gradient(top, #ebb81c, #0072bc); +/filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#ebb81c', EndColorStr='#0072bc'); /* IE6-IE9 */ + + +//background-size: 1000px 1000px, 500px 500px; +//-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; + border: 10; + min-width: 770px; + font-family: Arial, Tahoma, Helvetica, sans-serif; + font-size: 11px; + color: #FFFFFF; + text-align: center; + font-size: 18px; + font-family: tahoma, verdana, geneva, arial, helvetica, sans-serif; + + +} + + + +#mainContainer { + width: 770px; + margin: 0 auto; /* We are going to center this design */ + text-align: left; /* Since we used text-align: center in the body to be sure some older IE versions are going to center our design, we now align the text left */ +} +#header { + background: #000; + color: #fff; +} +#content { + float: left; /* Our content is going to be left aligned */ + width: 320px; /* And it's going to have a 500px width */ + /*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;*/ +} +#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 */ + margin: 0 auto; /* We need to center the footer also */ + background: black; + color: gold; + text-align: center; + font-size: 10px; +} + +#navlist { + margin-left: 50; + padding-left: 0; + list-style-type: square; + text-align: left; +} + +#navlist li { + +} +#navlist a:link +{ + color: #fff; +# background-color: #FDB14F; + text-decoration: underline ; + + +} + +#navlist a:visited +{ +# color: #FDB14F; + color: gold; + text-decoration: underline; +} + +table.sample { + border-width: 4px; + border-spacing: 2px; + border-style: outset; + border-color: #808080; + border-collapse: separate; + width:300px; +} + +table.sample td { + border-width: 1px; + padding: 1px; + border-style: inset; + border-color: #808080; + /*width:300px;*/ + -moz-border-radius: ; +} + + +table.calllog { + border-width: 4px; + border-spacing: 2px; + border-style: outset; + border-color: #808080; + border-collapse: separate; + width:500px; +} + +table.calllog td { + border-width: 1px; + padding: 1px; + border-style: inset; + border-color: #808080; + /*width:300px;*/ + -moz-border-radius: ; +} + + +.n { + font-weight: normal; + text-align: left; + width: 250px; + color: white; +} + +.s { + font-weight: normal; + text-align: left; + width: 150px; + color: white; + text-decoration: none; +} + +.m { + font-weight: normal; + text-align: left; + width: 350px; + color: white; + text-decoration: none; +} + +.t { + font-weight: normal; + text-align: left; + width: 350px; + color: white; + text-decoration: none; + visibility:hidden +} + + +a:link +{ + color: #fff; +# background-color: #FDB14F; + text-decoration: underline ; + + margin-left:10px; + +} + +a:visited +{ +# color: #FDB14F; + color: gold; + text-decoration: underline; + margin-left:10px; +} + +#submitbutton { + background-color: #010101; + font-size: 100%; + color: gold; + text-decoration: underline;margin-left:150px; + padding: 10px; font-weight: bold; } diff --git a/abs/core/supplemental-web/contents/header.html b/abs/core/supplemental-web/contents/header.html new file mode 100644 index 0000000..e476799 --- /dev/null +++ b/abs/core/supplemental-web/contents/header.html @@ -0,0 +1,34 @@ +<html>
+<style type="text/css">@import "mv.css";</style>
+<head>
+
+<script type="text/javascript">
+function r()
+{
+ current_hostname=parent.location.hostname
+ top.frames["content"].location.href = ( "http://" + current_hostname + ":6544" ) ;
+
+}
+</script>
+</head>
+
+<BODY BGCOLOR=#ebb81c>
+
+<div id='header'>
+ </div>
+
+<base target="content" />
+<div id="navcontainer">
+ <ul id="navlist">
+ <li id="active"><a href="home.shtml" TARGET="content" id="current">Home</a></li>
+ <li><a href="xymon" >Xymon</a></li>
+ <li><a href="docs.html" >Documentation</a></li>
+ <li><a href="links.html" >Links</a></li>
+ <!-- <li><a href="webcal/" >Calendar</a></li> -->
+ <li><a onClick=r() >Myth Backend Status</a></li>
+ <li><a href="mythweb/" >MythWeb</a></li>
+ <li><a href="phpMyAdmin/" >phpMyAdmin</a></li>
+ </ul>
+</div>
+</body>
+</html>
diff --git a/abs/core/supplemental-web/contents/header.jpg.mv b/abs/core/supplemental-web/contents/header.jpg.mv Binary files differnew file mode 100644 index 0000000..3bf128e --- /dev/null +++ b/abs/core/supplemental-web/contents/header.jpg.mv diff --git a/abs/core/supplemental-web/contents/home.shtml b/abs/core/supplemental-web/contents/home.shtml new file mode 100644 index 0000000..fe70014 --- /dev/null +++ b/abs/core/supplemental-web/contents/home.shtml @@ -0,0 +1,23 @@ +<html> +<head> +<style type="text/css">@import "frame.css";</style> +</head> + +<body> +<div id="mainContainer"> +<!-- <div id="header"><p></p></div> + <div id="content"> + <p></p>--> + + <!--#exec cmd="/data/srv/httpd/htdocs/count.py" --> + + +</br> +</br> + <img src="/xymon/gifs/network.png" > + +<div id="footer"><p>Thank you for choosing LinHES</p></div> + +</body> +</html> + diff --git a/abs/core/supplemental-web/contents/images/classic-menugraph.png b/abs/core/supplemental-web/contents/images/classic-menugraph.png Binary files differnew file mode 100644 index 0000000..bedbd93 --- /dev/null +++ b/abs/core/supplemental-web/contents/images/classic-menugraph.png diff --git a/abs/core/supplemental-web/contents/images/dvr_menugraph.png b/abs/core/supplemental-web/contents/images/dvr_menugraph.png Binary files differnew file mode 100644 index 0000000..712ab36 --- /dev/null +++ b/abs/core/supplemental-web/contents/images/dvr_menugraph.png diff --git a/abs/core/supplemental-web/contents/images/menu_diagram_color.png b/abs/core/supplemental-web/contents/images/menu_diagram_color.png Binary files differnew file mode 100644 index 0000000..d364d94 --- /dev/null +++ b/abs/core/supplemental-web/contents/images/menu_diagram_color.png diff --git a/abs/core/supplemental-web/contents/index.htm b/abs/core/supplemental-web/contents/index.htm new file mode 100644 index 0000000..faf09fb --- /dev/null +++ b/abs/core/supplemental-web/contents/index.htm @@ -0,0 +1,14 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> +<html> + <head><title>LinHES: The Linux Home Entertainment System</title> + </head> + <frameset rows="217, 80%" frameborder="no" border="3" bordercolor="#000000"> + <frame src="header.html" name="menuframe" /> + <frame src="home.shtml" name="content" /> + <noframes> + <body> + There is no frame support on your browser. + </body> + </noframes> + </frameset> + </html> diff --git a/abs/core/supplemental-web/contents/linhes_header.png b/abs/core/supplemental-web/contents/linhes_header.png Binary files differnew file mode 100644 index 0000000..fd50187 --- /dev/null +++ b/abs/core/supplemental-web/contents/linhes_header.png diff --git a/abs/core/supplemental-web/contents/links.html b/abs/core/supplemental-web/contents/links.html new file mode 100644 index 0000000..a44fefc --- /dev/null +++ b/abs/core/supplemental-web/contents/links.html @@ -0,0 +1,30 @@ + + + +<html> +<head> +<style type="text/css">@import "frame.css";</style> +</head> + +<body> +Other Links +</br> + + + + + +<div id="navcontainer"> +<ul id="navlist"> + <li><a href="/logs/" >System log files</a> </li> + <li><a href="/calllog.shtml" >Phone call log</a> </li> + <!-- <li><a href="/mvpmc.shtml" >Media MVP setup</a> (dhcp server must be enabled) </li> --> + <li><a href="http://www.linhes.org" >linhes.org </a>Bugtracker</li> + <li><a href="http://linhes.org/bugs/projects/linhes/wiki" >Wiki </a></li> + <li><a href="http://mysettopbox.tv/phpBB2/" >Online User Forums</a></li> + <li><a href="http://www.mythtv.com" >mythtv.com</a></li> +</ul> +</div> + +</body> +</html> diff --git a/abs/core/supplemental-web/contents/mv.css b/abs/core/supplemental-web/contents/mv.css new file mode 100644 index 0000000..54e70b0 --- /dev/null +++ b/abs/core/supplemental-web/contents/mv.css @@ -0,0 +1,100 @@ +#header { + // width: 820px; + position: relative; + height: 182px; + #background: #000011 url(linhes_header.png) no-repeat center top; + background: #ebb81c url(linhes_header.png) no-repeat center bottom ; + padding: 0; + padding-top: 1px; + font-size: 14px; + color: #FFF; +} + +#header h1#logo-text { + // position: absolute; + margin: 0; padding: 0; + font: bolder 3.3em 'Trebuchet MS', Arial, Sans-serif; + letter-spacing: -2px; + color: #FFFFFF; + text-transform: none; + text-align: center; + /* change the values of top and left to adjust the position of the logo*/ + top: 0px; left: 150px; +} + +#content +{ + color: #FFFFFF; + text-transform: none; + text-align: center; +} + +#navcontainer +{ + width: 100%; + float: left; + background-color:#0072bc; +} + +#navcontainer ul { padding: 0; } +#navcontainer ul li { display: inline; } + +#navcontainer ul +{ + margin: 0; + padding: 0 0 0 7%; + color: #FFFFFF; + font-family: tahoma, verdana, geneva, arial, helvetica, sans-serif; + //font-size: .65em; + letter-spacing: 2px; + font-weight: bold; + float: right; + //background:#ebb81c; + background-color: #0072bc; + +} + + +#navcontainer ul li a +{ + padding: 0.2em 12px;// background-color: #ebb81c; + background-color: #0072bc; + color: #FFFFFF; + text-decoration: none; + float: left; + //border-right: 1px solid #94B473; + + border-top-right-radius: 15px; + -moz-border-top-right-radius: 15px; + + border-top-left-radius: 15px; + -moz-border-top-left-radius: 15px; +} + + +#navcontainer a:active +{ + background-color: #ECECEC; + color: #333; + border-top-right-radius: 25px; + -moz-border-top-right-radius: 25px; + border-top-left-radius: 25px; + -moz-border-top-left-radius: 22px; +} + +#navcontainer ul li a:hover +{ + background-color: #ECECEC; + color: #333; +} + +#navlist li a:hover, #navlist li a:active li:active +{ + color: #FFFFFF; + text-decoration: none; + background:black; + text-align: right; + font-family: tahoma, verdana, geneva, arial, helvetica, sans-serif; +} + + diff --git a/abs/core/supplemental-web/contents/mvp_process.py b/abs/core/supplemental-web/contents/mvp_process.py new file mode 100644 index 0000000..b01ed8b --- /dev/null +++ b/abs/core/supplemental-web/contents/mvp_process.py @@ -0,0 +1,195 @@ +#!/usr/bin/python +import sys +import cgi +import os +import socket +import time +import shutil +try: + import cgitb + cgitb.enable() +except ImportError: + sys.stderr = sys.stdout +def cgiprint(inline=''): + sys.stdout.write(inline) + sys.stdout.write('\r\n') + sys.stdout.flush() +contentheader = 'Content-Type: text/html' + +thepage = '''<html><head> +<title>%s</title> +</head><body> +%s +</body></html> +''' +h1 = '<h1>%s</h1>' + +def getform(theform, valuelist, notpresent='', nolist=False): + """ + This function, given a CGI form as a + FieldStorage instance, extracts the + data from it, based on valuelist + passed in. Any non-present values are + set to '' - although this can be + changed. (e.g. to return None so you + can test for missing keywords - where + '' is a valid answer but to have the + field missing isn't.) It also takes a + keyword argument 'nolist'. If this is + True list values only return their + first value. + """ + data = {} + for field in valuelist: + + + if not theform.has_key(field): + # if the field is not present (or was empty) + data[field] = notpresent + else: + # the field is present + data[field] = theform.getlist(field) + +# print type(theform[field]) + return data + +def getall(theform, nolist=False): + """ + Passed a form (cgi.FieldStorage + instance) return *all* the values. + This doesn't take into account + multipart form data (file uploads). + It also takes a keyword argument + 'nolist'. If this is True list values + only return their first value. + """ + data = {} + for field in theform.keys(): + # we can't just iterate over it, but must use the keys() method + if type(theform[field]) == type([]): + if not nolist: + data[field] = theform.getlist(field) + + else: + data[field] = theform.getfirst(field) + else: + data[field] = theform[field].value + + + return data + +def isblank(indict): + """ + Passed an indict of values it checks + if any of the values are set. Returns + True if the indict is empty, else + returns False. I use it on the a form + processed with getform to tell if my + CGI has been activated without any + form values. + """ + for key in indict.keys(): + if indict[key]: + return False + return True + + +def update_mvp_list(maclist): + outfile = open("/etc/dnsmasq.mvpmc.conf","w") + mvpline="dhcp-boot=net:mvp,dongle.bin" + mvpmacline='dhcp-host=net:mvp,%s' + results="The following media mvp devices have been added:" + results+='</br>' + havemvp = "false" + #print maclist + for i in range(len(maclist)): + if maclist[i] != '': +# print mvpmacline % maclist[i] + outfile.write(mvpmacline % maclist[i] + '\n' ) + havemvp="true" + results+=maclist[i] + results+='</br>' + if havemvp == "true": +# print mvpline + outfile.write(mvpline + '\n' ) + outfile.flush + outfile.close + #time.sleep(5) + + else: + outfile.close + return results + + +mainpage = ''' + <html><head> + <style type="text/css">@import "/frame.css";</style> + <!--<meta http-equiv="refresh" content="6">--> + <title>Receiving a Form</title> + </head><body>%s</body></html>''' + +error = ''' + + <h2>Removed all media mvp devices</h2>''' + +result = ''' + <h1>%s</h1> +''' +possible_parameters = ['activemvp', 'othermac','hiddenparam'] + +if __name__ == '__main__': + cgiprint(contentheader) # content header + cgiprint() # finish headers with blank line + + theform = cgi.FieldStorage() + #print theform + formdict = getform(theform, possible_parameters) + #print possible_parameters + #print formdict + oldurl = '/mvpmc.shtml' + if isblank(formdict): + body = error + all_active=[] + else: + all_active=[] + activemac_checkbox = formdict['activemvp'] + for i in range(len(activemac_checkbox)): + active_string=activemac_checkbox[i] + active_string=active_string.strip() + all_active.append(active_string) + body = result % ("MVP mac address") + + + + print mainpage % body + # mylogfile=update_mvp_list(all_active) + + + box=''' + <div style="border: 1px solid #aaa; width:600px; height:500px; overflow:auto; color:#FFF;text-align:left;"> + <code id="box" style="display: block; height: 500px; width: 600px; overflow: auto;"> + ''' + + endbox=''' + </code> + </div> + ''' + javascript=''' + <script type="text/javascript"> + var objDiv = document.getElementById("box"); + objDiv.scrollTop = objDiv.scrollHeight; + </script> + ''' + if all_active != []: + mylogfile=update_mvp_list(all_active) + command="sudo /sbin/sv stop dnsmasq" + os.system(command) + command="sudo /sbin/sv start dnsmasq" + os.system(command) + print box + print mylogfile + print endbox + print '<a href=', oldurl, ' > Back </a> ' + #print oldurl + print javascript + diff --git a/abs/core/supplemental-web/contents/mvp_select.py b/abs/core/supplemental-web/contents/mvp_select.py new file mode 100644 index 0000000..8283d68 --- /dev/null +++ b/abs/core/supplemental-web/contents/mvp_select.py @@ -0,0 +1,146 @@ +#!/usr/bin/python +# + +import urllib2 +import string +import sys +import time +import datetime +import socket + +def read_accepted(): + + global dhcp_accepted + dhcp_accepted = [] + try: + infile = open('/tmp/dhcp.leases', 'r') + except(IOError), e: + print "couldn't open accepted" + else: + filelist = infile.readlines() + infile.close() + for item in filelist: + item=item.strip() + macaddress=item.split(" ")[1] + if macaddress not in dhcp_accepted: + dhcp_accepted.append(macaddress) + #print macaddress + +def read_offered(): + global dhcp_offered + dhcp_offered = [] + try: + today = datetime.date.today() + + host = socket.gethostname() + filename='/var/log/' + filename+=str(today) + filename+='/' + filename+=host + filename+='/dnsmasq' + infile = open(filename, 'r') + except(IOError), e: + print "couldn't open offered" + else: + filelist = infile.readlines() + infile.close() + for item in filelist: + item=item.strip() + if item.find("DHCPOFFER") != -1 : + macaddress=item.rpartition(" ")[2] + if macaddress not in dhcp_offered: + dhcp_offered.append(macaddress) + #print macaddress + + + +def read_current(): + global dhcp_current + dhcp_current = [] + try: + infile = open('/etc/dnsmasq.mvpmc.conf', 'r') + except(IOError), e: + print "couldn't open current" + else: + filelist = infile.readlines() + infile.close() + for item in filelist: + item=item.strip() + if item.find("dhcp-host") != -1 : + macaddress=item.partition(",")[2] + + if macaddress not in dhcp_current : + dhcp_current.append(macaddress) + # print macaddress + + + + + + + +def make_html(): + global dhcp_accepted + global dhcp_offered + buttonform_top=''' + <div class="content" style="solid #aaa; width:500px; height:300px; overflow:auto; color:#FFF;text-align:left;"> + <form action="/mvp_process.py" method="get"> + ''' + + + buttonform_bottom=''' + Mac Address: + <input type="text" name="activemvp"> + + </br> + <input id="submitbutton" type="submit" /> + </form> + </div> + ''' + checkboxline = ''' + <input type="checkbox" name="activemvp" value="%s" %s /> %s <br /> + ''' + print '<br />' + da = set(dhcp_accepted) + dof = set(dhcp_offered) + dc = set(dhcp_current) + possible_mac= dof -dc + #possible_mac= dof -da - dc + + print buttonform_top + for mac in dhcp_current: + print checkboxline % (mac ,' checked="yes"' , mac) + for mac in possible_mac: + print checkboxline % (mac , " " ,mac) + print buttonform_bottom + + +#------------------- +global dhcp_accepted +global dhcp_offered +global dhcp_current + + + + +read_offered() +#print "--" +#print '</br>' +read_accepted() +#print "--" +#print '</br>' +read_current() +#print "--" +#print '</br>' + + + +#possible_mac= (dof - da) +#possible_mac = dof +#print "should be unchecked:" +#print possible_mac + + +make_html() + + diff --git a/abs/core/supplemental-web/contents/mvpmc.shtml b/abs/core/supplemental-web/contents/mvpmc.shtml new file mode 100644 index 0000000..edc27d4 --- /dev/null +++ b/abs/core/supplemental-web/contents/mvpmc.shtml @@ -0,0 +1,21 @@ +<html> +<head> +<style type="text/css">@import "/frame.css";</style> +</head> +<h1>Media MVP page</h1> +<body> +<div id="mainContainer"> +<!-- <div id="header"><p></p></div> + <div id="content"> + <p></p>--> + + <!--#exec cmd="/data/srv/httpd/htdocs/mvp_select.py" --> + + +</br> +</br> +<div id="footer"><p>Thank you for choosing MythVantage</p></div> + +</body> +</html> + diff --git a/abs/core/supplemental-web/contents/page_background.jpg b/abs/core/supplemental-web/contents/page_background.jpg Binary files differnew file mode 100644 index 0000000..4819c9a --- /dev/null +++ b/abs/core/supplemental-web/contents/page_background.jpg diff --git a/abs/core/supplemental-web/contents/process.py b/abs/core/supplemental-web/contents/process.py new file mode 100644 index 0000000..48e56d2 --- /dev/null +++ b/abs/core/supplemental-web/contents/process.py @@ -0,0 +1,309 @@ +#!/usr/bin/python +import sys +import cgi +import os +import socket +import time +try: + import cgitb + cgitb.enable() +except ImportError: + sys.stderr = sys.stdout +def cgiprint(inline=''): + sys.stdout.write(inline) + sys.stdout.write('\r\n') + sys.stdout.flush() +contentheader = 'Content-Type: text/html' + +thepage = '''<html><head> +<title>%s</title> +</head><body> +%s +</body></html> +''' +h1 = '<h1>%s</h1>' + +def getform(theform, valuelist, notpresent='', nolist=False): + """ + This function, given a CGI form as a + FieldStorage instance, extracts the + data from it, based on valuelist + passed in. Any non-present values are + set to '' - although this can be + changed. (e.g. to return None so you + can test for missing keywords - where + '' is a valid answer but to have the + field missing isn't.) It also takes a + keyword argument 'nolist'. If this is + True list values only return their + first value. + """ + data = {} + for field in valuelist: + if not theform.has_key(field): + # if the field is not present (or was empty) + data[field] = notpresent + else: + # the field is present + print type(theform[field]) + if type(theform[field]) != type([]): + # is it a list or a single item + print type(theform[field]) + data[field] = theform[field].value + else: + if not nolist: + # do we want a list ? + data[field] = theform.getlist(field) + else: + data[field] = theform.getfirst(field) + # just fetch the first item + return data + +def getall(theform, nolist=False): + """ + Passed a form (cgi.FieldStorage + instance) return *all* the values. + This doesn't take into account + multipart form data (file uploads). + It also takes a keyword argument + 'nolist'. If this is True list values + only return their first value. + """ + data = {} + for field in theform.keys(): + # we can't just iterate over it, but must use the keys() method + if type(theform[field]) == type([]): + if not nolist: + data[field] = theform.getlist(field) + else: + data[field] = theform.getfirst(field) + else: + data[field] = theform[field].value + return data + +def isblank(indict): + """ + Passed an indict of values it checks + if any of the values are set. Returns + True if the indict is empty, else + returns False. I use it on the a form + processed with getform to tell if my + CGI has been activated without any + form values. + """ + for key in indict.keys(): + if indict[key]: + return False + return True + +def go_backup(myhost): + myhostname = socket.gethostname() + results="Nothing happened" + if myhostname.strip() == myhost.strip(): + command= "sudo /usr/MythVantage/bin/backup_job" + command2="sleep 1; /data/srv/hobbit/server/ext/hbnotes.py" + results=os.popen(command,'r') + os.popen(command2,'r') + + return results + +def go_restore(restorefile,myhost): + myhostname = socket.gethostname() + if myhostname.strip() == myhost.strip(): + localcommand="sudo /usr/bin/restore_job.sh " + command= localcommand + restorefile + else: + sshcmd="ssh -o StrictHostKeyChecking=no -o ConnectTimeout=1 -i /data/srv/.nobody_ssh/id_dsa mythtv@" + sshcmd+=myhost.strip() + cmd=' "sudo /usr/bin/restore_job.sh " ' + command=sshcmd + cmd + restorefile + " 2>&1 " + + results=os.popen(command,'r') + return results + +def go_optimize(myhost): + myhostname = socket.gethostname() + if myhostname.strip() == myhost.strip(): + command="/usr/LH/bin/optimize_mythdb.py" + results=os.popen(command,'r') + else: + results='This host does not run a database' + return results + +def go_update(myhost,update_type): + myhostname = socket.gethostname() + if myhostname.strip() == myhost.strip(): + cmd="sudo /usr/bin/update_system " + command=cmd + update_type + + else: + 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 + + +def go_shutdown(myhost): + myhostname = socket.gethostname() + message="Shutdown from MBE" + command="/usr/bin/func \"" + myhost.strip() + "*\" call msg display \"%s\" " %message + results=os.popen(command,'r') + time.sleep(3) + command="/usr/bin/func \"" + myhost.strip() + "*\" call power poweroff " + results=os.popen(command,'r') + return results + +def go_shutdownall(): + import MySQLdb + #import mysql + #find all hosts(minus myself) + #loop through results shutdown as we go. + db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg") + # create a cursor + cursor = db.cursor() + # execute SQL statement + myhostname = socket.gethostname() + results=["Sent shutdown command to: \n "] + cursor.execute("SELECT distinct(hostname) from settings where not hostname = %s ; ",(myhostname)) + result = cursor.fetchall() + + for row in result: + go_shutdown(row[0]) + results.append(row[0]) + + #shutdown myself. + #go_shutdown(myhostname) + #results.append(myhostname) + return results + +def go_reboot(myhost): + myhostname = socket.gethostname() + message="Reboot from MBE" + command="/usr/bin/func \"" + myhost.strip() + "*\" call msg display \"%s\" " %message + results=os.popen(command,'r') + time.sleep(3) + + command="/usr/bin/func \"" + myhost.strip() + "*\" call power reboot " + results=os.popen(command,'r') + return results + +def go_wake(myhost): + command="/usr/MythVantage/bin/wakeonlan.sh " + myhost.strip() + results=os.popen(command,'r') + return results + +def go_kill(myhost,kill_type): + myhostname = socket.gethostname() + cmd=" call fe_restart " + cmd+=kill_type + command="/usr/bin/func \"" + myhost.strip() + "*\" " + cmd + + results=os.popen(command,'r') + return results + + +mainpage = ''' + <html><head> + <style type="text/css">@import "/frame.css";</style> + <!--<meta http-equiv="refresh" content="6">--> + <title>Receiving a Form</title> + </head><body>%s</body></html>''' + +error = ''' + <h1>Error</h1> + <h2>No Form Submission Was Received</h2>''' + +result = ''' + <h1>%s of %s</h1> +''' +possible_parameters = ['param1', 'param2', 'param3', 'param4','hiddenparam','param5','param6'] + +if __name__ == '__main__': + cgiprint(contentheader) # content header + cgiprint() # finish headers with blank line + + theform = cgi.FieldStorage() + #print theform + formdict = getform(theform, possible_parameters) + #print possible_parameters + + if isblank(formdict): + body = error + else: + name = formdict['param1'] + radio = formdict['param2'] # should be 'this' or 'that' + if radio != 'Restore' : + name = "" + update_type = formdict['param3'] + oldurl = formdict['param4'] + hidden = formdict['hiddenparam'] + all_update_type=formdict['param5'] + kill_type = formdict['param6'] + body = result % (radio, hidden) + + + + + print mainpage % body + selection=radio + myhost=hidden + + if selection == "Restore": + mylogfile=go_restore(name,myhost) + elif selection == "Backup": + mylogfile=go_backup(myhost) + elif selection == "Update": + mylogfile=go_update(myhost,update_type) + elif selection == "Shutdown": + mylogfile=go_shutdown(myhost) + elif selection == "Reboot": + mylogfile=go_reboot(myhost) + elif selection == "Optimize": + mylogfile=go_optimize(myhost) + elif selection == "WOL": + mylogfile=go_wake(myhost) + elif selection == "UpdateAll": + mylogfile=go_updateall(all_update_type) + elif selection == "ShutdownAll": + mylogfile=go_shutdownall() + elif selection == "Kill": + mylogfile=go_kill(myhost,kill_type) + + 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=''' + <script type="text/javascript"> + var objDiv = document.getElementById("box"); + objDiv.scrollTop = objDiv.scrollHeight; + </script> + ''' + + print box + for line in mylogfile: + print line + '</br> \r\n' + + print endbox + print '<a href=', oldurl, ' > Back </a> ' + #print oldurl + print javascript + |