
    f              
           U d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZmZ ddlmZ dd	lmZ d
Zdddeege ed      gdgdZeed<    ee      Z  ej*                  e      Zdede
dededdf
dZy)zERuncmd: run arbitrary commands at rc.local with output to the console    N)dedent)util)Cloud)Config)
MetaSchemaget_meta_doc)ALL_DISTROS)PER_INSTANCEa  Run arbitrary commands at a rc.local like time-frame with output to the
console. Each item can be either a list or a string. The item type affects
how it is executed:


* If the item is a string, it will be interpreted by ``sh``.
* If the item is a list, the items will be executed as if passed to execve(3)
  (with the first arg as the command).

Note that the ``runcmd`` module only writes the script to be run
later. The module that actually runs the script is ``scripts_user``
in the :ref:`Final<boot-Final>` boot stage.

.. note::

    all commands must be proper yaml, so you have to quote any characters
    yaml would eat (':' can be problematic)

.. note::

    when writing files, do not use /tmp dir as it races with
    systemd-tmpfiles-clean LP: #1707222. Use /run/somedir instead.
	cc_runcmdRuncmdzRun arbitrary commandsa          runcmd:
            - [ ls, -l, / ]
            - [ sh, -xc, "echo $(date) ': hello world!'" ]
            - [ sh, -c, echo "=========hello world'=========" ]
            - ls -l /root
            - [ wget, "http://example.org", -O, /tmp/index.html ]
    runcmd)idnametitledescriptiondistros	frequencyexamplesactivate_by_schema_keysmetar   cfgcloudargsreturnc                 `   d|vrt         j                  d|        y t        j                  j	                  |j                  d      d      }|d   }	 t        j                  |      }t        j                  ||d       y # t        $ r&} t        |      dj                  ||            d }~ww xY w)Nr   z:Skipping module named %s, no 'runcmd' key in configurationscriptsi  z"Failed to shellify {} into file {})LOGdebugospathjoin	get_ipathr   shellify
write_file	Exceptiontypeformat)r   r   r   r   out_fncmdcontentes           </usr/lib/python3/dist-packages/cloudinit/config/cc_runcmd.pyhandler-   Q   s    s		H$	
 	WW\\%//)4h?F
h-CP--$/ Pd1g:AA#vNOOPs   ,A> >	B-!B((B-)__doc__loggingr   textwrapr   	cloudinitr   cloudinit.cloudr   cloudinit.configr   cloudinit.config.schemar   r   cloudinit.distrosr	   cloudinit.settingsr
   MODULE_DESCRIPTIONr   __annotations__	getLogger__name__r   strlistr-        r,   <module>r?      s    L  	   ! # < ) + 4 %%}		
 !)z'j , t
g!P P6 P% Pt P Pr>   