Browse files

generate usage screen dynamically (services.txt), and display tklbam-…

…status

- if tklbam is installed, tklbam-status --short will be displayed
- services.txt
    - heading text is now replaced with informative title
    - footer is dynamically added (simpler services.txt template)
    - backwards compatible with usage.txt (will be used if available)
  • Loading branch information...
1 parent 79f14df commit adc68f672b8124eed8ef1838eed2f4ad5d9ff79a @alonswartz alonswartz committed Oct 17, 2010
Showing with 34 additions and 21 deletions.
  1. +5 −0 conf/services.txt
  2. +0 −15 conf/usage.txt
  3. +29 −6 confconsole.py
View
5 conf/services.txt
@@ -0,0 +1,5 @@
+Web: http://$ipaddr
+ https://$ipaddr
+Web shell: https://$ipaddr:12320
+Webmin: https://$ipaddr:12321
+SSH/SFTP: root@$ipaddr (port 22)
View
15 conf/usage.txt
@@ -1,15 +0,0 @@
-You may access this $hostname appliance over the
-network using the following methods:
-
-Web: http://$ipaddr
- https://$ipaddr
-Web shell: https://$ipaddr:12320
-Webmin: https://$ipaddr:12321
-SSH/SFTP: root@$ipaddr (port 22)
-
-
-
-
-
-For more information visit the TurnKey Linux Website
- http://www.turnkeylinux.org
View
35 confconsole.py
@@ -28,6 +28,7 @@ def __init__(self, title=None, width=60, height=20):
self.console.add_persistent_args(["--no-collapse"])
self.console.add_persistent_args(["--ok-label", "Select"])
self.console.add_persistent_args(["--cancel-label", "Back"])
+ self.console.add_persistent_args(["--colors"])
if title:
self.console.add_persistent_args(["--backtitle", title])
@@ -113,7 +114,7 @@ def __init__(self):
self.height = 20
self.console = Console(title, self.width, self.height)
- self.appname = "TurnKey Linux %s" % netinfo.get_hostname().capitalize()
+ self.appname = "TurnKey Linux %s" % netinfo.get_hostname().upper()
self.installer = Installer(path='/usr/bin/di-live')
@@ -226,13 +227,35 @@ def usage(self):
self.console.msgbox("Error", "Networking is not yet configured")
return "networking"
+ #tklbam integration
+ try:
+ tklbam_status = executil.getoutput("tklbam-status --short")
+ except executil.ExecError:
+ tklbam_status = ''
+
#display usage
- t = file(conf.path("usage.txt"), 'r').read()
- text = Template(t).substitute(hostname=netinfo.get_hostname().capitalize(),
- appname=self.appname,
- ipaddr=ifutil.get_ipconf(ifname)[0])
+ ipaddr = ifutil.get_ipconf(ifname)[0]
+ hostname = netinfo.get_hostname().upper()
+
+ try:
+ #backwards compatible - use usage.txt if it exists
+ t = file(conf.path("usage.txt"), 'r').read()
+ text = Template(t).substitute(hostname=hostname, ipaddr=ipaddr)
+
+ retcode = self.console.msgbox("Usage", text,
+ button_label="Advanced Menu")
+ except conf.Error:
+ t = file(conf.path("services.txt"), 'r').read().rstrip()
+ text = Template(t).substitute(ipaddr=ipaddr)
+
+ text += "\n\n%s\n\n" % tklbam_status
+ text += "\n" * (self.height - len(text.splitlines()) - 7)
+ text += " TurnKey Backups and Cloud Deployment\n"
+ text += " https://hub.turnkeylinux.org"
+
+ retcode = self.console.msgbox("%s appliance services" % hostname,
+ text, button_label="Advanced Menu")
- retcode = self.console.msgbox("Usage", text, button_label="Advanced Menu")
if retcode is not self.OK:
self.running = False

0 comments on commit adc68f6

Please sign in to comment.