Home · Latest · Trends  /  general
0

yum package update/info with input

rated 0 times [  0] [ 0]  / comments: 0 / hits: 303  / 10 months ago, mon, mar 13, 2017, 14:32:36
Messing around to update a package, get info back, etc..
#!/bin/bash

if [ $# -ne 1 ]
then
  echo -e "nUsage: $0 <package name>n"
  echo -e "Example: $0 opensslnn"
  exit 1
fi

package=$1

if yum list installed "$package" >/dev/null 2>&1
then
  echo "$package is installed"
  yum check-update "$package" >/dev/null 2>&1
  RET=$?
  if [ $RET -eq 100 ]
  then
    echo "... and a new version is available."
    echo "Updating $package"
    yum -y update "$package" >/dev/null 2>&1
    ver=$(rpm -q "$package")
    echo "Version installed now: $ver"
  else
    echo "... and it is up to date!"
  fi
else
  echo "$package is not installed"
fi
More From » general
 

Comments

There are no comments for this Snippet yet
Only authorized users can post. Please sign in first, or register a free account
 
Share
Sponsor
Posted
rob

rob

Member since Feb 22, 2017
Total Code Snippets: 98
Total Comments: 1
Location: n/a
Following
User not following anyone yet.
rob snippets
10 months ago, wed, feb 22, 2017
10 months ago, wed, feb 22, 2017
10 months ago, wed, feb 22, 2017
10 months ago, wed, feb 22, 2017
10 months ago, wed, feb 22, 2017
10 months ago, wed, feb 22, 2017
10 months ago, wed, feb 22, 2017
10 months ago, wed, feb 22, 2017