我怎么能检索一个bash变量值,如果我有变量名字符串?Var1 ="this is real value" var1 =”” 通过变量a得到变量1的值。
背景:
I have some AMI's (Amazon Machine Image) and I want to fire up a few instances of each AMI. As soon as they finish booting, I want to setup each instance according to its AMI type. I don't want to bake lots of scripts or secret keys inside any AMI so I prepared a generalized startup script and I put it on S3 with a publicly accessible link. In rc.local I put small piece of code which fetches the startup script and executes it. This is all I have in the AMIs. Then each AMI accesses a common configuration script which is applicable to all AMIs and special setup scripts for each. These scripts are private and require a signed URL to access them.
所以现在,当我触发一个AMI的实例(my_private_ami_1)时,我为S3上呈现的另一个文件传递了一个签名URL,该文件包含了所有私有脚本的签名URL,以键/值对表示。config_url="http://s3.amazo.../config? "签名” my_private_ami_1 = " http://s3.amazo.../ami_1?签名” ... 当启动脚本运行时,它会下载上面的文件和源代码。然后它检查AMI类型并为自己选择正确的安装脚本。
ami\_type=GET AMI TYPE #ex: sets ami\_type to my\_private\_ami\_1
setup\_url=GET THE SETUP FILE URL BASED ON AMI\_TYPE # this is where this problem arises
所以现在我可以有一个泛型代码,它可以触发实例,而不管它们的AMI类型和实例可以照顾自己。