Permalink
Browse files

Create package_manager_name

Idea (and most of the code) stolen from https://github.com/cmer/shoestrap/blob/master/helpers/default.
  • Loading branch information...
1 parent b7c9172 commit f525962fa08233d47843e4a850591c706ee8d5d7 @booch booch committed Mar 7, 2013
Showing with 21 additions and 0 deletions.
  1. +21 −0 sbin/package_manager_name
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+# Prints out the name of the package management program used on this computer.
+# WARNING: Assumes that only 1 package manager is on the computer; only supports apt-get, yum, and brew.
+
+
+if [ "$PACKAGE_MANAGER" != "" ]; then
+ :
+elif command_exists apt-get; then
+ export PACKAGE_MANAGER='apt-get'
+elif command_exists yum; then
+ export PACKAGE_MANAGER='yum'
+elif command_exists brew; then
+ export PACKAGE_MANAGER='brew'
+else
+ echo 'Could not find a package manager.'
+ exit 1;
+fi
+
+echo "$PACKAGE_MANAGER"
+exit 0

0 comments on commit f525962

Please sign in to comment.