title: Shell Script and yum, what to do when package is not available. Centos
body: <p>I’d like to install a series of packages using script shell.</p>
  
  <p><strong>Question is</strong> : what to do when package is not available?
  Script idea is:
  if the package is installed go to the next one
  if the package is available to be installed, install it,
  if the package is not available exit the script, or to alert me about that package. Press a key to continue or so.
  Thanks!</p>
  
  <p><strong>More Info:</strong>
  While ago Monk posted this sentence</p>
  
  <p><strong><em>yum list installed vnc-server >/dev/null &amp;&amp; echo "vnc-server installed." || yum -y install vnc-server</em></strong></p>
  
  <p>** it will return vnc-server installed or it will install it.**</p>
  
  <p>I tried to install mariadb but – mariadb is not available in Centos 6.6 I should install other repository or something I don’t know yet, <strong>the point is script’s behavior.</strong></p>
  
  <p><strong><em>pkg=mariadb || yum list installed $pkg >/dev/null &amp;&amp; echo "--> $pkg installed." || yum install $pkg</em></strong></p>
  
  <p>this line as it is will return - - > mariadb installed.</p>
  
  <p>( this return is wrong because MariaDB is not available)</p>
  
  <p>In the command line typing</p>
  
  <p><strong><em>yum install mariadb</em></strong></p>
  
  <p>it will return</p>
  
  <p>Loaded plugins: fastestmirror</p>
  
  <p>Setting up Install Process</p>
  
  <p>Loading mirror speeds from cached hostfile</p>
  
  <p>base: mirrors.tripadvisor.com</p>
  
  <p>extras: mirrors.seas.harvard.edu</p>
  
  <p>updates: mirrors.lga7.us.voxel.net</p>
  
  <p><strong>No package mariadb available.</strong></p>
  
  <p>Error: Nothing to do</p>
  
  <p><em>Thanks!</em> </p>