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.
This commit is contained in:
Joshua Harlow 2012-09-28 14:17:42 -07:00
parent e2959f8155
commit f633cd19a3

View File

@ -62,16 +62,19 @@ def handle(name, cfg, cloud, log, args):
shcmd = "" shcmd = ""
if mod_user: if mod_user:
(users, _groups) = ds.normalize_users_groups(cfg, cloud.distro) (users, _groups) = ds.normalize_users_groups(cfg, cloud.distro)
(user, _user_config) = ds.extract_default(users, 'ubuntu') (user, _user_config) = ds.extract_default(users)
shcmd += " sudo -Hu \"%s\" byobu-launcher-%s" % (user, bl_inst) if not user:
shcmd += " || X=$(($X+1)); " 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: if mod_sys:
shcmd += "echo \"%s\" | debconf-set-selections" % dc_val shcmd += "echo \"%s\" | debconf-set-selections" % dc_val
shcmd += " && dpkg-reconfigure byobu --frontend=noninteractive" shcmd += " && dpkg-reconfigure byobu --frontend=noninteractive"
shcmd += " || X=$(($X+1)); " shcmd += " || X=$(($X+1)); "
cmd = ["/bin/sh", "-c", "%s %s %s" % ("X=0;", shcmd, "exit $X")] if len(shcmd):
cmd = ["/bin/sh", "-c", "%s %s %s" % ("X=0;", shcmd, "exit $X")]
log.debug("Setting byobu to %s", value) log.debug("Setting byobu to %s", value)
util.subp(cmd, capture=False)
util.subp(cmd, capture=False)