܍~c| UdZddlZddlmZddlmZddlmZmZm Z ddl m Z ddl m Z ddlmZmZdd lmZeZd gZd d d edeedgedgdZeed<eeZdede de dededdf dZdS)z:Bootcmd: run arbitrary commands early in the boot process.N)Logger)dedent)subp temp_utilsutil)Cloud)Config) MetaSchema get_meta_doc) PER_ALWAYSall cc_bootcmdBootcmdz0Run arbitrary commands early in the boot processa This module runs arbitrary commands very early in the boot process, only slightly after a boothook would run. This is very similar to a boothook, but more user friendly. The environment variable ``INSTANCE_ID`` will be set to the current instance id for all run commands. Commands can be specified either as lists or strings. For invocation details, see ``runcmd``. .. note:: bootcmd should only be used for things that could not be done later in the boot process. .. note:: when writing files, do not use /tmp dir as it races with systemd-tmpfiles-clean LP: #1707222. Use /run/somedir instead. z bootcmd: - echo 192.168.1.130 us.archive.ubuntu.com > /etc/hosts - [ cloud-init-per, once, mymkfs, mkfs, /dev/vdb ] bootcmd)idnametitle descriptiondistrosexamples frequencyactivate_by_schema_keysmetarcfgcloudlogargsreturnc d|vr|d|dStjd5} tj|d}|tj||n6#t$r)}tj |dt|d}~wwxYw tj }|} | rt| |d<d|jg} t!j| |d n%#t$rtj |d |wxYw ddddS#1swxYwYdS) Nrz;Skipping module named %s, no 'bootcmd' key in configurationz.sh)suffixzFailed to shellify bootcmd: %s INSTANCE_IDz/bin/shF)envcapturezFailed to run bootcmd module %s)debugrExtendedTemporaryFilershellifywrite encode_textflush Exceptionlogexcstrosenvironcopyget_instance_idrr) rrrrrtmpfcontenter"iidcmds =/usr/lib/python3/dist-packages/cloudinit/config/cc_bootcmd.pyhandler7Bs I4      ) 7 7 74 mC N33G JJt'00 1 1 1 JJLLLL    K=s1vv F F F   *//##C''))C .%(XXM"di(C IcsE 2 2 2 2 2    K> E E E   3sNEAB  E B=$B88B==EA&D('E("E  EE"E)__doc__r-loggingrtextwrapr cloudinitrrrcloudinit.cloudrcloudinit.configr cloudinit.config.schemar r cloudinit.settingsr rrr__annotations__r,listr7r6rDs{A@@ ,,,,,,,,,,!!!!!!######<<<<<<<<))))))  '   ?6 &    ){E##j###J ,t   #(/5=A rC