Azure / azure-linux-extensions

Linux Virtual Machine Extensions for Azure
Apache License 2.0
304 stars 253 forks source link

commandToExecute not work as linux shell #274

Open wingfeng opened 7 years ago

wingfeng commented 7 years ago

I try to do a simple things with CustomScriptForLiunx. Step 1 :install squid Step 2 : start squid service so I use this command in CustomScriptForlinux $settings='{"commandToExecute":"yum install squid -y;service squid start"}' after I run the powershell command Set-AzureRmVMExtension -ResourceGroupName -VMName vmsquid -Publisher "Microsoft.OSTCExtensions" -TypeHandlerVersion "1.5" -ExtensionType "CustomScriptForLinux" -SettingString $settings -DisableAutoUpgradeMinorVersion -Name SSHExtension -Location "China North"

I didn't get an output a my expected:The squid installed and started. I got a message as below:

---stdout--- Loaded plugins: fastestmirror, security Setting up Install Process Loading mirror speeds from cached hostfile No package squid;service available. No package start available. Resolving Dependencies --> Running transaction check ---> Package squid.x86_64 7:3.1.23-16.el6_8.6 will be installed --> Finished Dependency Resolution Dependencies Resolved

It work like the second command "service squid start" became a part of the first command "yum" I also try to use command "yum install squid -y && service squid start" and yum install squid -y |service squid start" But I got the same problem. My VM is CentOS 6.6

boumenot commented 7 years ago

I would probably execute the command like this.

yum install squid -y && service squid start

Let me know if this works for you.

wingfeng commented 7 years ago

It is'nt work at my side as my posted at the end.

boumenot commented 7 years ago

I don't understand your reply.

The original post contains a different invocation of the command. I don't know why that would indicate a differently formatted command would fail.