3 \me @sUdZddlZddlmZmZddlmZddlmZddl m Z m Z ddl m Z ddlmZd Zd d gZejeZd d deeeddggdZe e eZeeeeddddZdS)z=Byobu: Enable/disable byobu system wide and for default user.N)subputil)Cloud)Config) MetaSchema get_meta_doc)ug_util) PER_INSTANCEaThis module controls whether byobu is enabled or disabled system wide and for the default system user. If byobu is to be enabled, this module will ensure it is installed. Likewise, if it is to be disabled, it will be removed if installed. Valid configuration options for this module are: - ``enable-system``: enable byobu system wide - ``enable-user``: enable byobu for the default user - ``disable-system``: disable byobu system wide - ``disable-user``: disable byobu for the default user - ``enable``: enable byobu both system wide and for default user - ``disable``: disable byobu for all users - ``user``: alias for ``enable-user`` - ``system``: alias for ``enable-system`` ZubuntuZdebianZcc_byobuZByobuz5Enable/disable byobu system wide and for default userzbyobu_by_default: enable-userz byobu_by_default: disable-system)idnametitle descriptiondistrosZ frequencyZexamplesZactivate_by_schema_keys)r cfgcloudargsreturncCs^t|dkr|d}ntj|dd}|s8tjd|dS|dksH|dkrPd|}d#}||krhtjd||jd}|jd}|jd rd}d} d}n|d krd}d}d}d} d} |rtj ||j \} } tj | \} }| stjd|n| d| |f7} | d7} |r"| d| 7} | d7} | d7} t| rZdddd| dfg}tjd |t j |d!d"dS)$NrZbyobu_by_defaultz1Skipping module named %s, no 'byobu' values foundusersystemz enable-%s enable-user enable-systemenable disable-userdisable-systemdisablez%Unknown value %s for byobu_by_defaultz-userz-systemZinstallz*byobu byobu/launch-by-default boolean trueTZ uninstallz+byobu byobu/launch-by-default boolean falsezFNo default byobu user provided, can not launch %s for the default userz sudo -Hu "%s" byobu-launcher-%sz || X=$(($X+1)); z"echo "%s" | debconf-set-selectionsz4 && dpkg-reconfigure byobu --frontend=noninteractivez/bin/shz-cz%s %s %szX=0;zexit $XzSetting byobu to %sF)Zcapture)rrrrrr) lenrZget_cfg_option_strLOGdebugZwarningendswith startswithrZnormalize_users_groupsZdistroZextract_defaultr)r rrrvalueZvalidZmod_userZmod_sysZbl_instZdc_valZshcmdZusersZ_groupsrZ _user_configcmdr#/usr/lib/python3.6/cc_byobu.pyhandle:sZ          r%)__doc__ZloggingZ cloudinitrrZcloudinit.cloudrZcloudinit.configrZcloudinit.config.schemarrZcloudinit.distrosrZcloudinit.settingsr ZMODULE_DESCRIPTIONrZ getLogger__name__rmetastrlistr%r#r#r#r$ s*