vendredi 10 août 2018

Bash - IF Statement requiring 3 true conditions

I have a script written to place the yum.repo files based on the appropriate host.

I need help with this statement below. We are running 3 versions of the same system, with varying architectures. So based on the version selected earlier in the script it will wget the repo file based on the version and store it to the temporary location. Then in a while loop it reads a file of hosts in the systems composition. Based on the list it uses SSHPASS to execute a reverse scp and pull the appropriate .repo file. But to identify the repo file it has to match all 3 criteria.

if [[ $version = '1' && $\ver == 'el5' && $\type == 'x86' ]]; then
  copy c5_x86.repo
elif [[ $version = '1' && $\ver == 'el6' && $\type == 'i686' ]]; then
  copy c6_i686.repo
elif [[ $version = '1' && $\ver == 'el5' && $\type == 'x86' ]]; then
  copy this c6_x86.repo
elif ...... 

and so on for version 2 and version 3 of the systems possible composition.

Any help is appreciated.

Aucun commentaire:

Enregistrer un commentaire