问题
I am trying to execute multiple shell scripts by separating each command using '&&' using Azure Custom Extension script for Linux.
ARM templates is the deployment model.
Example Snippet:
"settings": {
"fileUris": "[script1,script2, script3]",
"commandToExecute": "sh script1.sh && sh scrip2.sh && sh script3.sh"
}
But only the first script executes and the other two scripts doesn't execute.
Note : There are no errors in Script logs path too. I see all the scripts downloaded in waagent folder path too.
Any help will be be really great.
Operating System: Linux
回答1:
ARM template Snippet
cmdToExecute = script1.sh param1 param2 && script2.sh param1 param2 && script3.sh is passed as a string to a wrapper script like
"commandToExecute" : "[concat('sh script_executor.sh \"', parameters('cmdToExecute') '\"')]"
script_executor.sh -- takes all commands as parameters and executes each command
回答2:
If you have multiple scripts, you can author an entry point script that calls the dependent scripts, then upload the entry point script, dependent scripts and any other dependent binaries to the script location(Azure storage blob or GitHub). You can use following format to ensure multiple files are uploaded: “fileUris” : [“ScriptFileUri1”, “ScriptFileUri2”, "ScriptFileUri3"]
More information please refer to this link.
If you want to set script1.sh as the entry point script, you could edit you script such as below:
##script in scrpit1.sh
echo "hello world"
##call script2.sh
./script2.sh
##call script3.sh
./script3.sh
来源:https://stackoverflow.com/questions/42206705/azure-extension-script-for-linux