o
    x[h  ã                
   @   s    U d Z ddlZddlmZmZmZmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ e e¡ZeZdd	ged
gdœZeed< dede
dededdf
dd„ZdS )z:Bootcmd: run arbitrary commands early in the boot process.é    N)Úsignal_handlerÚsubpÚ
temp_utilsÚutil)ÚCloud)ÚConfig)Ú
MetaSchema)Ú
PER_ALWAYSÚ
cc_bootcmdÚallÚbootcmd)ÚidÚdistrosÚ	frequencyÚactivate_by_schema_keysÚmetaÚnameÚcfgÚcloudÚargsÚreturnc           	      C   s   d|vrt  d| ¡ d S tjdd��t}zt |d ¡}| t |¡¡ | ¡  W n t	y> } z
t 
t dt|ƒ¡ ‚ d }~ww z/| ¡ }|rLdt|ƒini }t ¡ � tjd|jg|dd	� W d   ƒ n1 shw   Y  W n t	y}   t 
t d
| ¡ ‚ w W d   ƒ d S 1 s‰w   Y  d S )Nr   z;Skipping module named %s, no 'bootcmd' key in configurationz.sh)ÚsuffixzFailed to shellify bootcmd: %sÚINSTANCE_IDz/bin/shF)Ú
update_envÚcapturezFailed to run bootcmd module %s)ÚLOGÚdebugr   ÚExtendedTemporaryFiler   ÚshellifyÚwriteÚencode_textÚflushÚ	ExceptionÚlogexcÚstrÚget_instance_idr   Úsuspend_crashr   r   )	r   r   r   r   ÚtmpfÚcontentÚeÚiidÚenv© r,   ú=/usr/lib/python3/dist-packages/cloudinit/config/cc_bootcmd.pyÚhandle!   s<   ÿ€þ
ÿÿ€þ€"ðr.   )Ú__doc__ÚloggingÚ	cloudinitr   r   r   r   Úcloudinit.cloudr   Úcloudinit.configr   Úcloudinit.config.schemar   Úcloudinit.settingsr	   Ú	getLoggerÚ__name__r   r   r   Ú__annotations__r$   Úlistr.   r,   r,   r,   r-   Ú<module>   s   	
ü"