ubuntu ec2-instance上的cloud-init per-boot脚本

时间:2012-04-14 19:32:43

标签: amazon-ec2 ubuntu-11.10 cloud-init

我正在尝试在ubuntu 11.10 ec2实例上使用cloud-init启动脚本。

我将脚本script.sh放在文件夹/var/lib/cloud/scripts/per-bootscript.sh的内容很简单:

#/!/bin/sh 
echo "test"

重启后,我收到以下错误:

run-parts: failed to exec /var/lib/cloud/scripts/per-boot/script.sh: Exec format error
run-parts: /var/lib/cloud/scripts/per-boot/script.sh exited with return code 1
2012-04-14 19:10:52,642 - cc_scripts_per_boot.py[WARNING]: failed to run-parts in /var/lib/cloud/scripts/per-boot
2012-04-14 19:10:52,648 - __init__.py[WARNING]: Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/__init__.py", line 108, in run_cc_modules
    cc.handle(name, run_args, freq=freq)
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/__init__.py", line 72, in handle
    [ name, self.cfg, self.cloud, cloudinit.log, args ])
  File "/usr/lib/python2.7/dist-packages/cloudinit/__init__.py", line 309, in sem_and_run
    func(*args)
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/cc_scripts_per_boot.py", line 27, in handle
    util.runparts(runparts_path)
  File "/usr/lib/python2.7/dist-packages/cloudinit/util.py", line 140, in runparts
    raise subprocess.CalledProcessError(sp.returncode,cmd)
CalledProcessError: Command '['run-parts', '--regex', '.*', '/var/lib/cloud/scripts/per-boot']' returned non-zero exit status 1

2012-04-14 19:10:52,648 - __init__.py[ERROR]: config handling of scripts-per-boot, None, [] failed

cloud-init boot finished at Sat, 14 Apr 2012 19:10:52 +0000. Up 3.70 seconds
2012-04-14 19:10:52,672 - cloud-init-cfg[ERROR]: errors running cloud_config [final]: ['scripts-per-boot']
errors running cloud_config [final]: ['scripts-per-boot']

任何想法如何解决?

1 个答案:

答案 0 :(得分:4)

我认为您的问题与#/!/bin/sh不是有效输入类型的事实有关。需要删除#后的/。

#!/bin/sh 
echo "test"

如果您在此之后仍然看到问题,请告诉我。