summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--cloudinit/CloudConfig/cc_byobu.py43
-rw-r--r--doc/examples/cloud-config.txt11
3 files changed, 41 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 76ee976d..19019c95 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,7 @@
to renamed devices in newer (natty) kernels (/dev/sda1 -> /dev/xvda1)
- make metadata urls configurable, to support eucalyptus in
STATIC or SYSTEM modes (LP: #761847)
+ - support disabling byobu in cloud-config
0.6.1:
- fix bug in fixing permission on /var/log/cloud-init.log (LP: #704509)
- improve comment strings in rsyslog file tools/21-cloudinit.conf
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)
diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt
index c1d0b278..e1ccf9f5 100644
--- a/doc/examples/cloud-config.txt
+++ b/doc/examples/cloud-config.txt
@@ -255,9 +255,14 @@ debconf_selections: | # Need to perserve newlines
debconf debconf/frontend seen false
# manage byobu defaults
-# byobu_by_default: ('user'|'system')
-# 'user' will set byobu 'launch-by-default' for the default user
-# 'system' will enable launch-by-default for for all users
+# byobu_by_default:
+# 'user' or 'enable-user': set byobu 'launch-by-default' for the default user
+# 'system' or 'enable-system' or 'enable':
+# enable 'launch-by-default' for all users, do not modify default user
+# 'disable': disable both default user and system
+# 'disable-system': disable system
+# 'disable-user': disable for default user
+# not-set: no changes made
byobu_by_default: system
# disable ssh access as root.