3 \�me� � @ s� U d Z ddlZddlmZmZ ddlmZ ddlmZ ddl m Z mZ ddlm Z ddlmZ d Zd dgZeje�Zdd deeeddgg d�Ze ee�Z eeeedd�dd�ZdS )z=Byobu: Enable/disable byobu system wide and for default user.� N)�subp�util)�Cloud)�Config)� MetaSchema�get_meta_doc)�ug_util)�PER_INSTANCEa� This 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)�id�name�title�description�distrosZ frequencyZexamplesZactivate_by_schema_keys)r �cfg�cloud�args�returnc C s^ t |�dkr|d }ntj|dd�}|s8tjd| � d S |dksH|dkrPd| }d#}||krhtjd|� |jd�}|jd�}|jd �r�d}d} d}n|d kr�d}d}d}d} d} |�r tj ||j �\}}tj|�\} }| s�tjd|� n| d| |f 7 } | d7 } |�r"| d| 7 } | d7 } | d7 } t | ��rZdddd| df g}tjd |� tj|d!d"� d S )$Nr Zbyobu_by_default� z1Skipping module named %s, no 'byobu' values found�user�systemz enable-%s�enable-user� enable-system�enable�disable-user�disable-system�disablez%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)r r r r r r ) �lenr Zget_cfg_option_str�LOG�debugZwarning�endswith� startswithr Znormalize_users_groupsZdistroZextract_defaultr )r r r r �valueZvalidZmod_userZmod_sysZbl_instZdc_valZshcmdZusersZ_groupsr Z_user_config�cmd� r# �/usr/lib/python3.6/cc_byobu.py�handle: sZ r% )�__doc__ZloggingZ cloudinitr r Zcloudinit.cloudr Zcloudinit.configr Zcloudinit.config.schemar r Zcloudinit.distrosr Zcloudinit.settingsr ZMODULE_DESCRIPTIONr Z getLogger�__name__r �meta�str�listr% r# r# r# r$ �<module> s*