/[shmookey]/portconf/install.py


UCC Code Repository

Contents of /portconf/install.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 110 - (hide annotations) (download) (as text)
Wed May 28 07:18:09 2008 UTC (13 years, 6 months ago) by shmookey
File MIME type: text/x-python
File size: 7554 byte(s)
various cleaning up and refining

1 shmookey 63 #!/usr/bin/python
2    
3     import cgi, cgitb, sys, os
4 shmookey 110 import common
5 shmookey 63
6     cgitb.enable ()
7    
8    
9     def ShowDefaultPage ():
10 shmookey 110 pageText = """
11     <h1 id='ms_page_title'>Welcome to the Port Administration Configuration Tool (PACT)</h1>
12 shmookey 63 <p>Thanks for choosing PACT!<br>
13     Before we can get started, we'll need to collect some information for the basic configuration
14     of PACT. All of these questions are pretty vital, if you don't know the answers for them then
15     perhaps you shouldn't be installing network manager software at all! That said, you can change
16     these settings at any time should you feel the need to, we just need something to work with.
17     These fields have been filled in with sane defaults where possible, but you can change them
18     by clicking them.</p>
19     <div class='block'>
20     <h3>1.) Installation</h3>
21     Ease of use has always been a primary objective for PACT, but there are some circumstances where
22     for security reasons a drag-and-drop installation isn't suitable. If you choose to use a
23     fragmented install, you'll have to provide paths to the locations of the parts you want to
24     keep out of your public-html. We'll generate a script to move the relevant files to their
25     new home called finalise-install.sh if you choose this option; you should run it as root. If you
26     change these values, you can't finish the installation until you run this script.
27     <b>Please note that in most situations it is perfectly okay to leave the paths alone.</b><br>
28     <table border='0' cellpadding='2' cellspacing='0' class='rowset'>
29 shmookey 86 <tr><td><a style="cursor:pointer" class="var" id="pyciscopath">""" + os.path.abspath (os.path.dirname (sys.argv[0]) + "/pycisco/") + """</a></td><td>Path to PyCisco module, eg: <i>/usr/local/pycisco</i></td></tr>
30     <tr><td><a style="cursor:pointer" class="var" id="pyaaapath">""" + os.path.abspath (os.path.dirname (sys.argv[0]) + "/pyaaa/") + """</a></td><td>Path to PyAAA module, eg: <i>/usr/local/pyaaa</i></td></tr>
31 shmookey 63 </table>
32     </div>
33     <div class='block'>
34     <h3>2.) Database Configuration</h3>
35     PACT uses PostgreSQL as a database backend for storing configuration, access-control and session
36     data. It can be used for authentication, but it doesn't have to be. You can't complete the
37     installation until these are completed with valid values. Don't take it personally, we really
38     do need them to keep your workplace secure!
39     <table border='0' cellpadding='2' cellspacing='0' class='rowset'>
40     <tr><td><a style="cursor:pointer" class="var" id="dbhost">localhost</a></td><td>Hostname or IP address of PostgreSQL server.</td></tr>
41     <tr><td><a style="cursor:pointer" class="var" id="dbport">5432</a></td><td>Port to connect through.</td></tr>
42     <tr><td><a style="cursor:pointer" class="var" id="dbname">not set</a></td><td>Name of database for PACT to use (must already exist).</td></tr>
43     <tr><td><a style="cursor:pointer" class="var" id="dbpref">pact_</a></td><td>Prefix to use for PACT tables, eg: <i>pact_</i>Users</td></tr>
44     <tr><td><a style="cursor:pointer" class="var" id="dbuser">not set</a></td><td>User name to connect to the database with.</td></tr>
45 shmookey 101 <tr><td><a style="cursor:pointer" class="pw" id="dbpass">********</a></td><td>Password to connect to the database with.</td></tr>
46 shmookey 63 </table>
47     </div>
48     <div class='block'>
49     <h3>3.) You're done!</h3>
50 shmookey 81 That's it! Click the link below to start the installation.<br>
51     <div style="border-width:1px;border-style:solid;border-color:#cccccc;width:100%;text-align:center;padding:5px" id="status">
52     Waiting for installation to start.<br />
53     <a style="cursor:pointer;font-size:1.5em;font-weight:bold;text-align:center" class="testdetails">INSTALL</a>
54 shmookey 63 </div>
55 shmookey 81 </div>
56 shmookey 63 <input type='hidden' name='action' value='install' />
57     <script type='text/javascript'>
58     $(document).ready (function () {
59     textFieldClick = function () {
60 shmookey 80 fieldid = $(this).attr ("id");
61 shmookey 63 $(this).attr ("class", fieldid + "Input");
62     td = $(this).parents ("td");
63     td.html ("<input type='text' value='" + $(this).text() + "' />");
64     td.children ().focus ().blur (function () {
65     newval = $(this).attr ("value");
66     td = $(this).parents ("td");
67 shmookey 80 td.html ("<a style='cursor:pointer' class='var' id='" + fieldid + "'>Saving...</a>");
68 shmookey 63 td.children ().click (textFieldClick);
69     td.children ().load ("update-install.py?action=setvar&name=" + fieldid + "&value=" + newval);
70     });
71     };
72 shmookey 101 pwFieldClick = function () {
73     fieldid = $(this).attr ("id");
74     $(this).attr ("class", fieldid + "Input");
75     td = $(this).parents ("td");
76     td.html ("<input type='password' value='" + $(this).text() + "' />");
77     td.children ().focus ().blur (function () {
78     newval = $(this).attr ("value");
79     td = $(this).parents ("td");
80 shmookey 102 td.html ("<a style='cursor:pointer' class='pw' id='" + fieldid + "'>Saving...</a>");
81 shmookey 101 td.children ().click (textFieldClick);
82     td.children ().load ("update-install.py?action=setvar&name=" + fieldid + "&value=" + newval);
83     });
84     };
85 shmookey 80 function ClearHighlights () {
86     $("#dbhost").parents ("tr"). css ("color","black");
87     $("#dbport").parents ("tr"). css ("color","black");
88     $("#dbname").parents ("tr"). css ("color","black");
89     $("#dbpref").parents ("tr"). css ("color","black");
90     $("#dbuser").parents ("tr"). css ("color","black");
91     $("#dbpass").parents ("tr"). css ("color","black");
92     };
93 shmookey 81 function UpdateInstallStatus (errmess) {
94     $("#status"). html (errmess + "<br /><a style='cursor:pointer;font-size:1.5em;font-weight:bold;text-align:center' class='testdetails'>RETRY</a>");
95     $("a.testdetails").click (validateFieldClick);
96     };
97 shmookey 80 validateFieldClick = function () {
98     $.getScript ("update-install.py?action=validate", function () {
99     ClearHighlights ();
100     if (status == "NeedDBName") {
101     $("#dbname").parents ("tr"). css ("color","red");
102 shmookey 81 UpdateInstallStatus ("Please provide a database name.");
103 shmookey 80 } else if (status == "NeedDBUser") {
104     $("#dbuser").parents ("tr"). css ("color","red");
105 shmookey 81 UpdateInstallStatus ("Please provide a database username.");
106 shmookey 80 } else if (status == "NeedDBPass") {
107     $("#dbpass").parents ("tr"). css ("color","red");
108 shmookey 81 UpdateInstallStatus ("Please provide a database password.");
109 shmookey 80 } else if (status == "NeedDBPort") {
110     $("#dbport").parents ("tr"). css ("color","red");
111 shmookey 81 UpdateInstallStatus ("Please provide the correct database port.");
112     } else if (status == "InvalidDatabaseSettings") {
113     $("#dbuser").parents ("tr"). css ("color","red");
114     $("#dbpass").parents ("tr"). css ("color","red");
115     $("#dbname").parents ("tr"). css ("color","red");
116     UpdateInstallStatus ("There was a problem with your username, password, or database name. Please check these values and try again.");
117     } else if (status == "DatabaseError") {
118     UpdateInstallStatus ("There was an unknown problem with the database. Please check that there are no existing tables or relations with the <i>" + $("#dbpref").html () + "</i> prefix.");
119     } else if (status == "Success") {
120     UpdateInstallStatus ("Installation sucessful.");
121 shmookey 80 }
122     });
123     };
124 shmookey 63 $("a.var").click (textFieldClick);
125 shmookey 102 $("a.pw").click (pwFieldClick);
126 shmookey 80 $("a.testdetails").click (validateFieldClick);
127 shmookey 63 });
128     </script>
129     """
130 shmookey 110 return pageText
131 shmookey 63
132 shmookey 110 def GetSidebar ():
133     sideText = """
134     <dt><a href="index.html">Navigation</a></dt>
135     <dd><ul>
136     <li>Install</li>
137     <li><a href="update-install.py?action=uninstall">Uninstall</a></li>
138     </ul></dd>
139 shmookey 63 """
140 shmookey 110 return sideText
141 shmookey 63
142    
143 shmookey 110 pageBuffer = ""
144     pageBuffer += "Content-Type: text/html\n\n"
145     pageBuffer += common.GetHeader ("Install", GetSidebar ())
146     pageBuffer += ShowDefaultPage ()
147     pageBuffer += common.GetFooter ()
148 shmookey 63
149 shmookey 110 print pageBuffer

Properties

Name Value
svn:executable *

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26