summaryrefslogtreecommitdiff
path: root/cloudinit/CloudConfig/cc_byobu.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2011-06-14 16:23:46 -0400
committerScott Moser <smoser@ubuntu.com>2011-06-14 16:23:46 -0400
commit309c3eb1b7000f5b0d33c38f0eb56b30688cdbff (patch)
treeec602eb18d4626e71c8122f08b9b2bcc9c489f20 /cloudinit/CloudConfig/cc_byobu.py
parent5864b795eee242b1fd7c5910abce69a931bb8738 (diff)
downloadvyos-cloud-init-309c3eb1b7000f5b0d33c38f0eb56b30688cdbff.tar.gz
vyos-cloud-init-309c3eb1b7000f5b0d33c38f0eb56b30688cdbff.zip
Support disabling of byobu.
LP: #797336
Diffstat (limited to 'cloudinit/CloudConfig/cc_byobu.py')
-rw-r--r--cloudinit/CloudConfig/cc_byobu.py43
1 files changed, 32 insertions, 11 deletions
diff --git a/cloudinit/CloudConfig/cc_byobu.py b/cloudinit/CloudConfig/cc_byobu.py
index 1a4545af..406a1f67 100644
--- a/cloudinit/CloudConfig/cc_byobu.py
+++ b/cloudinit/CloudConfig/cc_byobu.py
@@ -27,19 +27,40 @@ def handle(name,cfg,cloud,log,args):
if not value: return
- if value == "user":
- user = util.get_cfg_option_str(cfg,"user","ubuntu")
- cmd = [ 'sudo', '-Hu', user, 'byobu-launcher-install' ]
- elif value == "system":
- shcmd="echo '%s' | debconf-set-selections && %s" % \
- ( "byobu byobu/launch-by-default boolean true",
- "dpkg-reconfigure byobu --frontend=noninteractive" )
- cmd = [ "/bin/sh", "-c", shcmd ]
- else:
+ if value == "user" or value == "system":
+ value = "enable-%s" % value
+
+ valid = ( "enable-user", "enable-system", "enable",
+ "disable-user", "disable-system", "disable" )
+ if not value in valid:
log.warn("Unknown value %s for byobu_by_default" % value)
- return
- log.debug("enabling byobu for %s" % value)
+ mod_user = value.endswith("-user")
+ mod_sys = value.endswith("-system")
+ if value.startswith("enable"):
+ bl_inst = "install"
+ dc_val = "byobu byobu/launch-by-default boolean true"
+ mod_sys = True
+ else:
+ if value == "disable":
+ mod_user = True
+ mod_sys = True
+ bl_inst = "uninstall"
+ dc_val = "byobu byobu/launch-by-default boolean false"
+
+ shcmd = ""
+ if mod_user:
+ user = util.get_cfg_option_str(cfg,"user","ubuntu")
+ shcmd += " sudo -Hu \"%s\" byobu-launcher-%s" % (user, bl_inst)
+ shcmd += " || X=$(($X+1)); "
+ if mod_sys:
+ shcmd += "echo \"%s\" | debconf-set-selections" % dc_val
+ shcmd += " && dpkg-reconfigure byobu --frontend=noninteractive"
+ shcmd += " || X=$(($X+1)); "
+
+ cmd = [ "/bin/sh", "-c", "%s %s %s" % ("X=0;", shcmd, "exit $X" ) ]
+
+ log.debug("setting byobu to %s" % value)
try:
subprocess.check_call(cmd)