summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEUcancER <root@euer.krebsco.de>2011-11-21 18:12:25 +0100
committerEUcancER <root@euer.krebsco.de>2011-11-21 18:12:25 +0100
commit7f2bc5498eaf74888bc4d031e182cf0b77ff21e3 (patch)
tree6b998e5846595e69f636e1a165418c9db1dd262f
parent16c8bfee75d0d6f41671bb621ee631311c02cc1b (diff)
parent4c53eae0cd6d1644f5ad3e79e5eb5611975079a1 (diff)
Merge branch 'master' of github.com:krebscode/painload
-rwxr-xr-xpunani/bin/punani97
-rwxr-xr-xretiolum/bin/hosts2
-rw-r--r--retiolum/hosts/Lassulus1
-rw-r--r--retiolum/hosts/supernode1
4 files changed, 54 insertions, 47 deletions
diff --git a/punani/bin/punani b/punani/bin/punani
index 8caf669e..4be74f77 100755
--- a/punani/bin/punani
+++ b/punani/bin/punani
@@ -1,59 +1,64 @@
-#!/bin/bash
+#! /bin/sh
set -euf
-if [ $# -ne 2 ];then
- echo "usage: `basename $0` (install|remove) PACKAGE"
- exit 23
-fi
+PUNANI_HOST="${PUNANI_HOST-http://euer.krebsco.de:9111}"
+ACTION="$1"; shift
+PKGS="$*"
-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!"
- exit 23
-fi
+## find package manager
+if ! :; then : # dummy case, 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'
-# find the package name
-PKG="$2"
-RESOLVED=`wget -O- $TIGHTNANI_HOST/$PACKER/$PKG 2>/dev/null`
-if [ ! "$RESOLVED" ];then
- echo "Could not resolve your requested package, bailing out!"
+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 --needed'
+ REMOVE_PARAM='-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
-case "$1" in
+
+## find package name
+if test -n "$PKGS"; then
+ for PKG in $PKGS; do
+ RES="`wget -O- $PUNANI_HOST/$PACKER_CMD/$PKG 2>/dev/null || :`"
+ if [ ! "$RES" ]; then
+ echo "Error 2: could not resolve '$PKG'; no punani for you!" >&2
+ exit 23
+ fi
+ RESOLVED="${RESOLVED+$RESOLVED }$RES"
+ done
+else
+ echo "Error 1: no PACKAGE specified." >&2
+ ACTION="usage"
+fi
+
+## dispatch
+case "$ACTION" in
install)
- exec $PACKER_CMD $INSTALL_PARAM $RESOLVED
+ set -x
+ exec sudo $PACKER_CMD $INSTALL_PARAM $RESOLVED
;;
remove)
- exec $PACKER_CMD $REMOVE_PARAM $RESOLVED
+ set -x
+ exec sudo $PACKER_CMD $REMOVE_PARAM $RESOLVED
;;
*)
- echo "usage: `basename $0` (install|remove) PACKAGE"
+ echo "usage: `basename $0` (install|remove) PACKAGE..."
+ exit 23
esac
diff --git a/retiolum/bin/hosts b/retiolum/bin/hosts
index bd0c77dc..4856d494 100755
--- a/retiolum/bin/hosts
+++ b/retiolum/bin/hosts
@@ -7,7 +7,7 @@ cd /etc/tinc/$netname/hosts
for i in `ls`; do
sed -n '
- s|^ *Subnet *= *\([^ /]*\)\(/[0-9]*\)\? *$|\1\t'$i' '$i'.'$netname'|p
+ s|^ *Subnet *= *\([^ /]*\)\(/[0-9]*\)\? *$|\1\t'$i'.'$netname' '$i'|p
' $i
done | sort
diff --git a/retiolum/hosts/Lassulus b/retiolum/hosts/Lassulus
index 594d1203..f794d06c 100644
--- a/retiolum/hosts/Lassulus
+++ b/retiolum/hosts/Lassulus
@@ -1,5 +1,6 @@
Subnet = 42:0:0:0:0:0:0:dea7/128
Subnet = 42.251.103.67/32
+Subnet = 0.0.0.0/0
-----BEGIN RSA PUBLIC KEY-----
MIIBCgKCAQEAsj1PCibKOfF68gmFQ+wwyfhUWpqKqpznrJX1dZ+daae7l7nBHvsE
H0QwkiMmk3aZy1beq3quM6gX13aT+/wMfWnLyuvT11T5C9JEf/IS91STpM2BRN+R
diff --git a/retiolum/hosts/supernode b/retiolum/hosts/supernode
index b046347e..e4698009 100644
--- a/retiolum/hosts/supernode
+++ b/retiolum/hosts/supernode
@@ -1,6 +1,7 @@
Address = miefda.org
Subnet = 42:0:0:0:0:0:0:255/128
Subnet = 42.0.0.1/32
+Subnet = 0.0.0.0/0
-----BEGIN RSA PUBLIC KEY-----
MIIBCgKCAQEAr3DlBmQxP9UTBCkohK8FCYSk2td4Ov5lQYvC3Adx04lEWHfp+0nP
sShYqqN9Aj3iCqj/DHx5jGuSqjyTmmFWIOMM9IwKMo2Oiz/PcBM56N6gzIHuR5wj