File: //usr/lib/python3.6/site-packages/cloudinit/config/__pycache__/cc_runcmd.cpython-36.pyc
3
\�me� � @ s� U d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZm
Z
ddlmZ dd lmZ d
Zddd
eegeed�gdgd�Zee
e�Z eje�Zee
eedd�dd�ZdS )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.
Z cc_runcmdZRuncmdzRun 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�descriptionZdistrosZ frequencyZexamplesZactivate_by_schema_keys)r �cfg�cloud�args�returnc C s� d|krt jd| � d S tjj|jd�d�}|d }ytj|�}tj||d� W n6 t k
r� } zt
|�dj||���W Y d d }~X nX d S )Nr
z:Skipping module named %s, no 'runcmd' key in configuration�scriptsi� z"Failed to shellify {} into file {})�LOG�debug�os�path�joinZ get_ipathr ZshellifyZ
write_file� Exception�type�format)r r r r Zout_fn�cmdZcontent�e� r �/usr/lib/python3.6/cc_runcmd.py�handleQ s
r )�__doc__Zloggingr �textwrapr Z cloudinitr Zcloudinit.cloudr Zcloudinit.configr Zcloudinit.config.schemar r Zcloudinit.distrosr Zcloudinit.settingsr ZMODULE_DESCRIPTION�metaZ getLogger�__name__r �str�listr r r r r �<module> s,