summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xpunani/bin/punani61
1 files changed, 29 insertions, 32 deletions
diff --git a/punani/bin/punani b/punani/bin/punani
index 8caf669e..7be91db4 100755
--- a/punani/bin/punani
+++ b/punani/bin/punani
@@ -1,48 +1,45 @@
-#!/bin/bash
+#! /bin/sh
set -euf
+TIGHTNANI_HOST="${TIGHTNANI_HOST-http://euer.krebsco.de:9111}"
+
if [ $# -ne 2 ];then
echo "usage: `basename $0` (install|remove) PACKAGE"
exit 23
fi
-PACKERS="yum!-y install remove
-brew install remove
-pacman!--noconfirm -S!--needed -Rcs
-bauerbill!--noconfirm -S!--needed -Rcs
-yaourt!--noconfirm -S!--needed -Rcs
-packer!--noconfirm -S!--needed -Rcs
-apt-get!--yes install remove
-aptitude!--yes install remove"
-
-OIFS=$IFS
-PACKER=
-IFS='
-'
-
-TIGHTNANI_HOST="http://euer.krebsco.de:9111"
-# Find suitable packer
-for PACKER_LINE in $PACKERS; do
- TRY_PACKER_CMD="$(echo "$PACKER_LINE" | cut -d ' ' -f 1)"
- TRY_PACKER="$(echo "$TRY_PACKER_CMD" | cut -d '!' -f 1)"
- if which $TRY_PACKER &>/dev/null; then
- PACKER=$TRY_PACKER
- PACKER_CMD="$(echo "$TRY_PACKER_CMD" | tr "!" " ")"
- echo "you got $PACKER"
- INSTALL_PARAM="$(echo "$PACKER_LINE" | cut -d ' ' -f 2 | tr "!" " ")"
- REMOVE_PARAM="$(echo "$PACKER_LINE" | cut -d ' ' -f 3 | tr "!" " ")"
- fi
-done
-IFS=$OIFS
-if [ ! "$PACKER" ];then
- echo "Could not find a supported packer for you, bailing out!"
+## find package manager
+if ! :; then : # dummy, so the rest has a common format
+
+elif for PACKER_CMD in yum
+ do type $PACKER_CMD 2>/dev/null 1>&2 && break; done; then
+ INSTALL_PARAM='-y install'
+ REMOVE_PARAM='-y remove'
+
+elif for PACKER_CMD in brew
+ do type $PACKER_CMD 2>/dev/null 1>&2 && break; done; then
+ INSTALL_PARAM='install'
+ REMOVE_PARAM='remove'
+
+elif for PACKER_CMD in bauerbill packer yaourt pacman
+ do type $PACKER_CMD 2>/dev/null 1>&2 && break; done; then
+ INSTALL_PARAM='--noconfirm -S'
+ REMOVE_PARAM='--needed -Rcs'
+
+elif for PACKER_CMD in aptitude apt-get
+ do type $PACKER_CMD 2>/dev/null 1>&2 && break; done; then
+ INSTALL_PARAM='--yes install'
+ REMOVE_PARAM='--yes remove'
+
+else
+ echo "Error 2: no known package manager found; no punani for you!" >&2
exit 23
fi
# find the package name
PKG="$2"
-RESOLVED=`wget -O- $TIGHTNANI_HOST/$PACKER/$PKG 2>/dev/null`
+RESOLVED=`wget -O- $TIGHTNANI_HOST/$PACKER_CMD/$PKG 2>/dev/null`
if [ ! "$RESOLVED" ];then
echo "Could not resolve your requested package, bailing out!"
exit 23