1

I have a bash script with multiple commands :

code <<-EOH
  yum -y install httpd && yum -y install mod_ssl
  cd /tmp
  git clone https://github.xxx
  cd /tmp/docker-oidc-rp
  cp modules/centos/x86_64/apache22/mod_wsja.cl2.so /etc/httpd/modules
  cp int/ce-conf/*.* /etc/httpd/conf/mod_mon-ce
  echo "Include /etc/httpd/conf/mod_mon-ce/wsjacl2.conf" >> /etc/httpd/conf/httpd.conf
  echo "modmon recipe executed successfully"
  EOH

now I have multiple commands which I want to run in order and if they fail then I want to exit the bash with a failure message/error but even if a command fails , it moves to other commands and then gives a success message for bash.

Whats the most concise method to make all commands wait for preceding commands to succeed and exit out of bash if anything fails with error.

Scooby
  • 3,371
  • 8
  • 44
  • 84
  • What's with the pseudo-heredoc around the actual code? Anyway, souds like you are looking for `set -e`. – tripleee Mar 16 '16 at 19:42
  • You should learn how to use chef's resources for installing packages, cloning git repos etc. – StephenKing Mar 16 '16 at 19:44
  • @StephenKing - already know, this was just an example of commands chained together. – Scooby Mar 16 '16 at 20:08
  • @tripleee - pseudo-herodoc as it is from chef script but that should really be concerned with the answer. Also hence the tag - chef – Scooby Mar 16 '16 at 20:09

0 Answers0