summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-09-28 14:17:42 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-09-28 14:17:42 -0700
commit5233b6edb70702476463b47c06cb02b3c7f74c51 (patch)
tree5bc025d2158e5c987af5ad17a67643b6954b4a50
parent7ab25c779433a614a6e4101ddfe852fc25f39c01 (diff)
downloadvyos-cloud-init-5233b6edb70702476463b47c06cb02b3c7f74c51.tar.gz
vyos-cloud-init-5233b6edb70702476463b47c06cb02b3c7f74c51.zip
Make byobu more tolerant of the user not being
located and warn when it is not found + only run the shell command when actual contents exist to run.
-rw-r--r--cloudinit/config/cc_byobu.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/cloudinit/config/cc_byobu.py b/cloudinit/config/cc_byobu.py
index e38fccdd..92d428b7 100644
--- a/cloudinit/config/cc_byobu.py
+++ b/cloudinit/config/cc_byobu.py
@@ -62,16 +62,19 @@ def handle(name, cfg, cloud, log, args):
shcmd = ""
if mod_user:
(users, _groups) = ds.normalize_users_groups(cfg, cloud.distro)
- (user, _user_config) = ds.extract_default(users, 'ubuntu')
- shcmd += " sudo -Hu \"%s\" byobu-launcher-%s" % (user, bl_inst)
- shcmd += " || X=$(($X+1)); "
+ (user, _user_config) = ds.extract_default(users)
+ if not user:
+ log.warn(("No default byobu user provided, "
+ "can not launch %s for the default user"), bl_inst)
+ else:
+ 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)
-
- util.subp(cmd, capture=False)
+ if len(shcmd):
+ cmd = ["/bin/sh", "-c", "%s %s %s" % ("X=0;", shcmd, "exit $X")]
+ log.debug("Setting byobu to %s", value)
+ util.subp(cmd, capture=False)