Skip to content

Instantly share code, notes, and snippets.

@jordanwesthoff
Last active August 29, 2015 14:10
Show Gist options
  • Save jordanwesthoff/057d9e53ad2d488f9c76 to your computer and use it in GitHub Desktop.
Save jordanwesthoff/057d9e53ad2d488f9c76 to your computer and use it in GitHub Desktop.
Intelligent sorter
YUM_CMD=$(which yum)
APT_GET_CMD=$(which apt-get)
OTHER_CMD=$(which <other installer>
if [[ ! -z $YUM_CMD ]]; then
yum install $YUM_PACKAGE_NAME
elif [[ ! -z $APT_GET_CMD ]]; then
apt-get $DEB_PACKAGE_NAME
elif [[ ! -z $OTHER_CMD ]]; then
$OTHER_CMD <proper arguments>
else
echo "error can't install package $PACKAGE"
exit 1;
fi
#!/bin/bash
# Find our package manager
if VERB="$( which apt-get )" 2> /dev/null; then
echo "Debian-based"
elif VERB="$( which yum )" 2> /dev/null; then
echo "Modern Red Hat-based"
elif VERB="$( which portage )" 2> /dev/null; then
echo "Gentoo-based"
elif VERB="$( which pacman )" 2> /dev/null; then
echo "Arch-based"
else
echo "I have no idea what I'm doing." >&2
exit 1
fi
if [[ 1 -ne $# ]]; then
echo "Syntax: $0 PACKAGE"
exit 1
fi
$VERB "$1"
exit $?
https://github.com/icy/pacapt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment