Server IP : 104.21.38.3 / Your IP : 162.158.170.195 Web Server : Apache System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /snap/core20/current/usr/lib/python3/dist-packages/cloudinit/config/ |
Upload File : |
# Copyright (C) 2009-2010 Canonical Ltd. # Copyright (C) 2012 Hewlett-Packard Development Company, L.P. # # Author: Scott Moser <[email protected]> # Author: Juerg Haefliger <[email protected]> # # This file is part of cloud-init. See LICENSE file for license information. """Byobu: Enable/disable byobu system wide and for default user.""" import logging from cloudinit import subp, util from cloudinit.cloud import Cloud from cloudinit.config import Config from cloudinit.config.schema import MetaSchema from cloudinit.distros import ug_util from cloudinit.settings import PER_INSTANCE LOG = logging.getLogger(__name__) meta: MetaSchema = { "id": "cc_byobu", "distros": ["ubuntu", "debian"], "frequency": PER_INSTANCE, "activate_by_schema_keys": [], } def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None: if len(args) != 0: value = args[0] else: value = util.get_cfg_option_str(cfg, "byobu_by_default", "") if not value: LOG.debug("Skipping module named %s, no 'byobu' values found", name) return if not subp.which("byobu"): cloud.distro.install_packages(["byobu"]) if value == "user" or value == "system": value = "enable-%s" % value valid = ( "enable-user", "enable-system", "enable", "disable-user", "disable-system", "disable", ) if value not in valid: LOG.warning("Unknown value %s for byobu_by_default", 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: (users, _groups) = ug_util.normalize_users_groups(cfg, cloud.distro) (user, _user_config) = ug_util.extract_default(users) if not user: LOG.warning( "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)); " if len(shcmd): cmd = ["/bin/sh", "-c", "%s %s %s" % ("X=0;", shcmd, "exit $X")] LOG.debug("Setting byobu to %s", value) subp.subp(cmd, capture=False)