grandfathermagic

How to find out which package manager my distrob use

May 29th, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.48 KB | None | 0 0
  1. #!/bin/bash
  2. # https://stackoverflow.com/questions/19477682/bash-script-determine-vendor-and-install-system-apt-get-yum-etc
  3. YUM_CMD=$(which yum)
  4. APT_GET_CMD=$(which apt-get)
  5. OTHER_CMD=$(which <other installer>)
  6.  
  7. if [[ ! -z $YUM_CMD ]]; then
  8.     yum install $YUM_PACKAGE_NAME
  9.  elif [[ ! -z $APT_GET_CMD ]]; then
  10.     apt-get $DEB_PACKAGE_NAME
  11.  elif [[ ! -z $OTHER_CMD ]]; then
  12.     $OTHER_CMD <proper arguments>
  13.  else
  14.     echo "error can't install package $PACKAGE"
  15.     exit 1;
  16.  fi
Advertisement
Add Comment
Please, Sign In to add comment