From e0d26a15c326176e3a886da89bffda0722e8ea1b Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 09:42:54 +0100 Subject: ship build_info: s/git rev-parse/git describe/ --- ship/build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ship/build b/ship/build index bd26482d..95c14699 100755 --- a/ship/build +++ b/ship/build @@ -44,8 +44,8 @@ EOF build_info() { cat< Date: Thu, 14 Nov 2013 10:03:11 +0100 Subject: ship remaster_arch_iso: s/error;exit/die/ --- ship/src/remaster_arch_iso | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ship/src/remaster_arch_iso b/ship/src/remaster_arch_iso index 046b005b..d089f872 100755 --- a/ship/src/remaster_arch_iso +++ b/ship/src/remaster_arch_iso @@ -27,9 +27,7 @@ info "mounting isofile ($isofile)" if is_root;then mount -t iso9660 -o loop,ro $isofile $isomnt else - error "we are not root enough to mount the iso. Bailing Out" - exit 1 - + die 'we are not root enough to mount the iso. Bailing Out' fi defer "info 'unmounting $isomnt';umount $isomnt" -- cgit v1.2.3 From 9e12def06b7775dbfcae28b17ce3ba96ba08c0d1 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 10:10:04 +0100 Subject: ship lib/retiolum: s/error;exit/die/g --- ship/src/retiolum | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/ship/src/retiolum b/ship/src/retiolum index d6e0efdc..ede1fd6a 100755 --- a/ship/src/retiolum +++ b/ship/src/retiolum @@ -38,33 +38,28 @@ main(){ if [ $IP4 -eq 0 ]; then RAND4=1 elif ! check_ip_valid4 $IP4; then - echo 'ip4 is invalid' - exit 1 + die 'ip4 is invalid' fi if [ $IP6 -eq 0 ]; then RAND6=1 elif ! check_ip_valid6 $IP6; then - echo 'ip6 is invalid' - exit 1 + die 'ip6 is invalid' fi #check if everything is installed if ! exists awk ; then - echo "Please install awk" - exit 1 + die 'Please install awk' fi if ! http_head $SURL >/dev/null 2>/dev/null ;then - echo "Cannot find supernode package, check if your internet is working" - exit 1 + die 'Cannot find supernode package, check if your internet is working' fi #check if everything is installed if [ $OS = 'android' ]; then if ! test -e /data/data/org.poirsouille.tinc_gui/files/tincd; then - echo "Please install tinc-gui" - exit 1 + die 'Please install tinc-gui' else TINCBIN=/data/data/org.poirsouille.tinc_gui/files/tincd DEV="/dev/tun" @@ -75,8 +70,7 @@ main(){ fi elif [ $OS = 'osx' ]; then if ! exists tincd >/dev/null; then - echo "Please install tinc" - exit 1 + die 'Please install tinc' else TINCBIN=tincd DEV="/dev/net/tun" @@ -85,8 +79,7 @@ main(){ fi else if ! exists tincd >/dev/null; then - echo "Please install tinc" - exit 1 + die 'Please install tinc' else TINCBIN=tincd DEV="/dev/net/tun" @@ -99,8 +92,7 @@ main(){ #test if tinc directory already exists if test -e $TINCDIR/$NETNAME; then - echo "tinc config directory $TINCDIR/$NETNAME does already exist. (backup and) delete config directory and restart" - exit 1 + die "tinc config directory $TINCDIR/$NETNAME does already exist. (backup and) delete config directory and restart" fi #get tinc-hostfiles @@ -243,7 +235,7 @@ host2subnet() 2) FULLSUBNET=$SUBNET4.0.0 ;; 1) FULLSUBNET=$SUBNET4.0 ;; 0) FULLSUBNET=$SUBNET4 ;; - *) echo "cannot read subnet" && exit 1;; + *) die 'cannot read subnet';; esac } -- cgit v1.2.3 From b536f99e6f1790df174879cc82045d71db42a099 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 10:31:01 +0100 Subject: ship core: homogenize logging --- ship/lib/core | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ship/lib/core b/ship/lib/core index d1a7333e..5df146a1 100644 --- a/ship/lib/core +++ b/ship/lib/core @@ -1,8 +1,8 @@ # logging -msg() { printf "$@\n" >&2 ;} -info() { msg "** $@" ;} -error() { msg "!! $@" ;} -die() { error "$@" ;exit 1;} +msg() { echo "$*" >&2; } +info() { msg "** $*"; } +error() { msg "!! $*"; } +die() { error "$*"; exit 1; } exists(){ type "$1" >/dev/null 2>/dev/null; } is_root(){ test $(id -u) -eq 0 -- cgit v1.2.3 From 168f5927f4a7b69b23f7d90e5a2dd36c6fe78a01 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 10:40:32 +0100 Subject: ship: move all "bailing out" msgs to die --- ship/lib/core | 6 +++++- ship/lib/network | 3 +-- ship/lib/punani | 1 - ship/src/remaster_arch_iso | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ship/lib/core b/ship/lib/core index 5df146a1..7c5cbf46 100644 --- a/ship/lib/core +++ b/ship/lib/core @@ -2,7 +2,11 @@ msg() { echo "$*" >&2; } info() { msg "** $*"; } error() { msg "!! $*"; } -die() { error "$*"; exit 1; } +die() { + error "$*" + error 'Bailing out.' + exit 1 +} exists(){ type "$1" >/dev/null 2>/dev/null; } is_root(){ test $(id -u) -eq 0 diff --git a/ship/lib/network b/ship/lib/network index 74edcbac..e1a9a31e 100644 --- a/ship/lib/network +++ b/ship/lib/network @@ -57,8 +57,7 @@ which_telnet(){ elif exists busybox;then echo `command -v busybox` telnet else - error "Cannot find telnet binary, please install either telnet-client or busybox or netcat or provided TELNET environment.\nbailing out!" - return 1 + die 'Cannot find telnet binary, please install either telnet-client or busybox or netcat or provided TELNET environment.' fi } diff --git a/ship/lib/punani b/ship/lib/punani index c07763a4..84881dbf 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -2,7 +2,6 @@ #@include _punani_db _punani_resolve_package(){ - : ${PACKER?PACKER is not set,bailing out} pkg=${1?please provide package name to resolve} eval printf "%s" \"\${_punanidb_${PACKER}_${pkg}-}\" | grep . } diff --git a/ship/src/remaster_arch_iso b/ship/src/remaster_arch_iso index d089f872..66d5bc05 100755 --- a/ship/src/remaster_arch_iso +++ b/ship/src/remaster_arch_iso @@ -13,7 +13,7 @@ rootdir=$bdir/root outdir=$bdir/out auto_url=euer.krebsco.de/autoinstall info "bdir is at $bdir" -[ ! -e "$isofile" ] && die "$isofile does not exist,bailing out" +[ ! -e "$isofile" ] && die "$isofile does not exist." esudo "$@" @@ -27,7 +27,7 @@ info "mounting isofile ($isofile)" if is_root;then mount -t iso9660 -o loop,ro $isofile $isomnt else - die 'we are not root enough to mount the iso. Bailing Out' + die 'we are not root enough to mount the iso.' fi defer "info 'unmounting $isomnt';umount $isomnt" -- cgit v1.2.3 From ad6a4e849d071cff0a230e5510be5b6e5702451f Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 10:53:03 +0100 Subject: ship: simplify _punani_resolve_package --- ship/lib/punani | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ship/lib/punani b/ship/lib/punani index 84881dbf..ca2e3534 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -1,9 +1,9 @@ #@include core #@include _punani_db +## usage: _punani_resolve_package PKGNAME _punani_resolve_package(){ - pkg=${1?please provide package name to resolve} - eval printf "%s" \"\${_punanidb_${PACKER}_${pkg}-}\" | grep . + eval "echo \"\${_punanidb_${PACKER}_$1}\"" } _punani_aptget_install(){ apt-get -y install "$@" ;} _punani_aptget_remove(){ apt-get -y remove "$@" ;} -- cgit v1.2.3 From babcdd4b4d203c98e3e2c7a5e70b9f1273b60f7c Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 11:07:36 +0100 Subject: ship build: make sourceable --- ship/build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ship/build b/ship/build index 95c14699..5863e325 100755 --- a/ship/build +++ b/ship/build @@ -181,4 +181,6 @@ buildcache_add() { ### main invocation ### -build "$@" +if echo "$0" | grep -q '^\(.*/\)\?build$'; then + build "$@" +fi -- cgit v1.2.3 From 172580f2642426a4ee01ef039d9ba126482bb357 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 12:03:26 +0100 Subject: ship punani: simplify package manager selection --- ship/lib/punani | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/ship/lib/punani b/ship/lib/punani index ca2e3534..e07d77af 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -5,31 +5,30 @@ _punani_resolve_package(){ eval "echo \"\${_punanidb_${PACKER}_$1}\"" } + +KNOWN_PACKERS='pacman aptget yum brew' +_punani_pacman_install(){ pacman --noconfirm -S --needed "$@" ;} +_punani_pacman_remove(){ pacman -Rcs "$@" ;} +_punani_pacman_has(){ pacman -Q "$1" >/dev/null;} _punani_aptget_install(){ apt-get -y install "$@" ;} _punani_aptget_remove(){ apt-get -y remove "$@" ;} _punani_aptget_has() { dpkg -s "$1" | grep -q "Status: install";} _punani_yum_install(){ yum -y install "$@" ;} _punani_yum_remove(){ yum -y remove "$@" ;} _punani_yum_has() { rpm -qa --qf "%{NAME}\n"| egrep "^${1}\$" >/dev/null ;} -_punani_pacman_install(){ pacman --noconfirm -S --needed "$@" ;} -_punani_pacman_remove(){ pacman -Rcs "$@" ;} -_punani_pacman_has(){ pacman -Q "$1" >/dev/null;} _punani_brew_install(){ brew install "$@"; } _punani_brew_remove(){ brew remove "$@";} _punani_brew_has(){ error "not implemented"; return 1 ;} punani(){ + for PACKER in ${KNOWN_PACKERS:-null}; do + exists "$PACKER" && info "using $PACKER" && break + done || die 'Error 2: no package manager found; no punani for you!' + ACTION="$1"; shift PKGS="$*" - for p in apt-get pacman yum brew;do - exists "$p" && PACKER=`printf "%s" "$p" | sed 's/-//g'` && break - done - - [ -z "${PACKER:-}" ] && error "Error 2: no known package manager found; no punani for you!" && return 1 - info "using $PACKER for install" [ -z "$PKGS" ] && error "no PACKAGE specified." && ACTION="usage" - for PKG in $PKGS; do RES="`_punani_resolve_package $PKG`" test -z "$RES" && error "could not resolve '$PKG'; no punani for you!"&& return 23 -- cgit v1.2.3 From 5df9f3a8ff52a11445982a215d89672306f0bccb Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 12:18:41 +0100 Subject: ship punani: revert oversimplification slightly --- ship/lib/punani | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ship/lib/punani b/ship/lib/punani index e07d77af..2c48f883 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -6,7 +6,7 @@ _punani_resolve_package(){ eval "echo \"\${_punanidb_${PACKER}_$1}\"" } -KNOWN_PACKERS='pacman aptget yum brew' +KNOWN_PACKERS='pacman apt-get yum brew' _punani_pacman_install(){ pacman --noconfirm -S --needed "$@" ;} _punani_pacman_remove(){ pacman -Rcs "$@" ;} _punani_pacman_has(){ pacman -Q "$1" >/dev/null;} @@ -21,8 +21,8 @@ _punani_brew_remove(){ brew remove "$@";} _punani_brew_has(){ error "not implemented"; return 1 ;} punani(){ - for PACKER in ${KNOWN_PACKERS:-null}; do - exists "$PACKER" && info "using $PACKER" && break + for p in ${KNOWN_PACKERS:-null}; do + exists $p && info "using $p" && PACKER=`echo $p | tr -d -` && break done || die 'Error 2: no package manager found; no punani for you!' ACTION="$1"; shift -- cgit v1.2.3 From faf2e8e5386c29d3a3a39a3d21c6ebd3405adaed Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 12:36:46 +0100 Subject: ship punani: actually print usage when missing arg --- ship/lib/punani | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ship/lib/punani b/ship/lib/punani index 2c48f883..ab9d92a5 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -20,14 +20,20 @@ _punani_brew_install(){ brew install "$@"; } _punani_brew_remove(){ brew remove "$@";} _punani_brew_has(){ error "not implemented"; return 1 ;} +_punani_usage='punani {install,remove,has} PACKAGE...' punani(){ for p in ${KNOWN_PACKERS:-null}; do exists $p && info "using $p" && PACKER=`echo $p | tr -d -` && break done || die 'Error 2: no package manager found; no punani for you!' ACTION="$1"; shift + + if test $# = 0; then + error 'no PACKAGE specified.' + die "usage: $_punani_usage" + fi + PKGS="$*" - [ -z "$PKGS" ] && error "no PACKAGE specified." && ACTION="usage" for PKG in $PKGS; do RES="`_punani_resolve_package $PKG`" @@ -51,8 +57,8 @@ punani(){ fi ;; *) - error "usage: punani (install|remove|has) PACKAGE..." - return 23 + error "bad action: $ACTION" + die "usage: $_punani_usage" esac done } -- cgit v1.2.3 From 36d6c36f45ab0207191248351b24544fbcf40666 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 12:38:30 +0100 Subject: ship punani: use implicit $@ --- ship/lib/punani | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ship/lib/punani b/ship/lib/punani index ab9d92a5..af267ac8 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -33,9 +33,7 @@ punani(){ die "usage: $_punani_usage" fi - PKGS="$*" - - for PKG in $PKGS; do + for PKG; do RES="`_punani_resolve_package $PKG`" test -z "$RES" && error "could not resolve '$PKG'; no punani for you!"&& return 23 case "$ACTION" in -- cgit v1.2.3 From a2eb765dd873ea34fd491c6ab0a64ba9d77262e9 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 12:46:27 +0100 Subject: _punani_resolve_package: return !0 but be quiet --- ship/lib/punani | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ship/lib/punani b/ship/lib/punani index af267ac8..e8705c7d 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -3,7 +3,7 @@ ## usage: _punani_resolve_package PKGNAME _punani_resolve_package(){ - eval "echo \"\${_punanidb_${PACKER}_$1}\"" + eval "set -u; echo \"\${_punanidb_${PACKER}_$1}\"" 2>/dev/null } KNOWN_PACKERS='pacman apt-get yum brew' -- cgit v1.2.3 From c27074f54f30b5d2acc870479ef76d303e46d88e Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 12:48:55 +0100 Subject: ship core die: make reason optional --- ship/lib/core | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ship/lib/core b/ship/lib/core index 7c5cbf46..d6e01352 100644 --- a/ship/lib/core +++ b/ship/lib/core @@ -2,8 +2,9 @@ msg() { echo "$*" >&2; } info() { msg "** $*"; } error() { msg "!! $*"; } +## usage: die [REASON...] die() { - error "$*" + test $# -gt 0 && error "$*" error 'Bailing out.' exit 1 } -- cgit v1.2.3 From 552fad7605bb3befe1928a8f1fdb1a129acd5c4b Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 12:50:50 +0100 Subject: ship punani: simplify _resolve_package caller --- ship/lib/punani | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ship/lib/punani b/ship/lib/punani index e8705c7d..8eef474b 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -34,8 +34,9 @@ punani(){ fi for PKG; do - RES="`_punani_resolve_package $PKG`" - test -z "$RES" && error "could not resolve '$PKG'; no punani for you!"&& return 23 + RES="`_punani_resolve_package $PKG`" || + die "could not resolve '$PKG'; no punani for you!" + case "$ACTION" in install) eval _punani_${PACKER}_has $RES && info "$RES already installed, skipping" && continue -- cgit v1.2.3 From fb6e147d3ccc17a79cbb2bd91d154b6d9570228d Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 13:23:07 +0100 Subject: ship punani: abstract has/install/remove --- ship/lib/punani | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/ship/lib/punani b/ship/lib/punani index 8eef474b..8efa9e8d 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -20,6 +20,21 @@ _punani_brew_install(){ brew install "$@"; } _punani_brew_remove(){ brew remove "$@";} _punani_brew_has(){ error "not implemented"; return 1 ;} +## usage: _punani_has PACKAGE +_punani_has() { + eval "_punani_${PACKER}_has \"\$1\"" +} + +## usage: _punani_install PACKAGE +_punani_install() { + eval "_punani_${PACKER}_install \"\$1\"" +} + +## usage: _punani_remove PACKAGE +_punani_remove() { + eval "_punani_${PACKER}_remove \"\$1\"" +} + _punani_usage='punani {install,remove,has} PACKAGE...' punani(){ for p in ${KNOWN_PACKERS:-null}; do @@ -39,17 +54,21 @@ punani(){ case "$ACTION" in install) - eval _punani_${PACKER}_has $RES && info "$RES already installed, skipping" && continue - ! is_root && error "punani requires super-user rights for installing" && return 1 - eval _punani_${PACKER}_install $RES || error "cannot install $RES with $PACKER" + if _punani_has $RES; then + info "$RES already installed, skipping" + else + _punani_install $RES || error "cannot install $RES with $PACKER" + fi ;; remove) - ! eval _punani_${PACKER}_has $RES && info "$RES not installed, skipping" && continue - ! is_root && error "punani requires super-user rights for removing" && return 1 - eval _punani_${PACKER}_remove $RES || error "cannot install $RES with $PACKER" + if ! _punani_has $RES; then + info "$RES not installed, skipping" + else + _punani_remove $RES || error "cannot install $RES with $PACKER" + fi ;; has) - if eval _punani_${PACKER}_has $RES ;then + if _punani_has $RES; then info "$RES is installed" else info "$RES is not installed" -- cgit v1.2.3 From 0fbc23c61956c9e208217f32d6a8e233b6e0f96e Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 13:35:52 +0100 Subject: ship punani: move user interface to top of file --- gold/bitcoinwisdom/index.js | 84 -------------------------------- ship/lib/punani | 114 +++++++++++++++++++++++--------------------- 2 files changed, 59 insertions(+), 139 deletions(-) delete mode 100644 gold/bitcoinwisdom/index.js diff --git a/gold/bitcoinwisdom/index.js b/gold/bitcoinwisdom/index.js deleted file mode 100644 index 95861229..00000000 --- a/gold/bitcoinwisdom/index.js +++ /dev/null @@ -1,84 +0,0 @@ -var http = require('http'); -var beeper = require('./beep.js').create_beeper(); - -setInterval(get_ticker, 1000); - -function get_ticker () { - http.get('http://s1.bitcoinwisdom.com:8080/ticker', ticker_response_handler); -} - -function ticker_response_handler (res) { - var data = ''; - res.on('data', function (chunk) { - data += chunk; - }); - res.on('end', function () { - try { - data = JSON.parse(data); - } catch (err) { - return console.log('Error:', err); - } - ticker_data_handler(data); - }); -} - -var last_data = { - btceltcbtc: { - last: 0, // price - date: 0, - tid: 0, - }, -} - -function ticker_data_handler (data) { - //console.log(data) - - var ticker = data.btceltcbtc - var last_ticker = last_data.btceltcbtc - - if (ticker.date !== last_ticker.date) { - - var diff = ticker.last - last_ticker.last; - - var lag = data.now - ticker.date; - - freq = (2000 + 1000000 * diff) | 0; - - var out = [ - format_date(data.now) + '+' + pad_left(lag, 2, '0'), - 'btceltcbtc', - '[' + diff_color(diff) + 'm' + ticker.last + '', - lag, - freq, - ]; - - console.log(out.join(' ')); - - beeper.beep(freq, 10); - } - - last_data.btceltcbtc = data.btceltcbtc; -} - -function diff_color (diff) { - if (diff < 0) { - return '31;1'; - } else if (diff > 0) { - return '32;1'; - } else { - return '33;1'; - } -} - -function format_date (unix) { - return (new Date(unix * 1000)).toISOString() - .replace(/\.000Z$/, 'Z') -} - -function pad_left (obj, num, char) { - var str = obj.toString(); - while (str.length < num) { - str += char; - } - return str; -} diff --git a/ship/lib/punani b/ship/lib/punani index 8efa9e8d..dc55c256 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -1,45 +1,9 @@ #@include core #@include _punani_db -## usage: _punani_resolve_package PKGNAME -_punani_resolve_package(){ - eval "set -u; echo \"\${_punanidb_${PACKER}_$1}\"" 2>/dev/null -} - -KNOWN_PACKERS='pacman apt-get yum brew' -_punani_pacman_install(){ pacman --noconfirm -S --needed "$@" ;} -_punani_pacman_remove(){ pacman -Rcs "$@" ;} -_punani_pacman_has(){ pacman -Q "$1" >/dev/null;} -_punani_aptget_install(){ apt-get -y install "$@" ;} -_punani_aptget_remove(){ apt-get -y remove "$@" ;} -_punani_aptget_has() { dpkg -s "$1" | grep -q "Status: install";} -_punani_yum_install(){ yum -y install "$@" ;} -_punani_yum_remove(){ yum -y remove "$@" ;} -_punani_yum_has() { rpm -qa --qf "%{NAME}\n"| egrep "^${1}\$" >/dev/null ;} -_punani_brew_install(){ brew install "$@"; } -_punani_brew_remove(){ brew remove "$@";} -_punani_brew_has(){ error "not implemented"; return 1 ;} - -## usage: _punani_has PACKAGE -_punani_has() { - eval "_punani_${PACKER}_has \"\$1\"" -} - -## usage: _punani_install PACKAGE -_punani_install() { - eval "_punani_${PACKER}_install \"\$1\"" -} - -## usage: _punani_remove PACKAGE -_punani_remove() { - eval "_punani_${PACKER}_remove \"\$1\"" -} - _punani_usage='punani {install,remove,has} PACKAGE...' punani(){ - for p in ${KNOWN_PACKERS:-null}; do - exists $p && info "using $p" && PACKER=`echo $p | tr -d -` && break - done || die 'Error 2: no package manager found; no punani for you!' + __punani_select_packer || die 'no package manager found; no punani for you!' ACTION="$1"; shift @@ -54,29 +18,69 @@ punani(){ case "$ACTION" in install) - if _punani_has $RES; then - info "$RES already installed, skipping" - else - _punani_install $RES || error "cannot install $RES with $PACKER" - fi - ;; + if _punani_has $RES; then + info "$RES already installed, skipping" + else + _punani_install $RES || error "cannot install $RES with $PACKER" + fi + ;; remove) - if ! _punani_has $RES; then - info "$RES not installed, skipping" - else - _punani_remove $RES || error "cannot install $RES with $PACKER" - fi - ;; + if ! _punani_has $RES; then + info "$RES not installed, skipping" + else + _punani_remove $RES || error "cannot install $RES with $PACKER" + fi + ;; has) - if _punani_has $RES; then - info "$RES is installed" - else - info "$RES is not installed" - fi - ;; + if _punani_has $RES; then + info "$RES is installed" + else + info "$RES is not installed" + fi + ;; *) error "bad action: $ACTION" die "usage: $_punani_usage" esac done } + +## usage: _punani_has PACKAGE +_punani_has() { + eval "_punani_${PACKER}_has \"\$1\"" +} + +## usage: _punani_install PACKAGE +_punani_install() { + eval "_punani_${PACKER}_install \"\$1\"" +} + +## usage: _punani_remove PACKAGE +_punani_remove() { + eval "_punani_${PACKER}_remove \"\$1\"" +} + +## usage: _punani_resolve_package PKGNAME +_punani_resolve_package(){ + eval "set -u; echo \"\${_punanidb_${PACKER}_$1}\"" 2>/dev/null +} + +## usage: __punani_select_packer +__punani_select_packer() { + for p in ${__punani_known_packers:-null}; do + exists $p && info "using $p" && PACKER=`echo $p | tr -d -` && break + done +} +__punani_known_packers='pacman apt-get yum brew' +_punani_pacman_install(){ pacman --noconfirm -S --needed "$@" ;} +_punani_pacman_remove(){ pacman -Rcs "$@" ;} +_punani_pacman_has(){ pacman -Q "$1" >/dev/null;} +_punani_aptget_install(){ apt-get -y install "$@" ;} +_punani_aptget_remove(){ apt-get -y remove "$@" ;} +_punani_aptget_has() { dpkg -s "$1" | grep -q "Status: install";} +_punani_yum_install(){ yum -y install "$@" ;} +_punani_yum_remove(){ yum -y remove "$@" ;} +_punani_yum_has() { rpm -qa --qf "%{NAME}\n"| egrep "^${1}\$" >/dev/null ;} +_punani_brew_install(){ brew install "$@"; } +_punani_brew_remove(){ brew remove "$@";} +_punani_brew_has(){ error "not implemented"; return 1 ;} -- cgit v1.2.3 From 78fa9ac0fa2ee8af9787b5f9ea14f6fbb0df24d1 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 13:38:07 +0100 Subject: ship punani: teach _punani_brew_has to die --- ship/lib/punani | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ship/lib/punani b/ship/lib/punani index dc55c256..72be0351 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -83,4 +83,4 @@ _punani_yum_remove(){ yum -y remove "$@" ;} _punani_yum_has() { rpm -qa --qf "%{NAME}\n"| egrep "^${1}\$" >/dev/null ;} _punani_brew_install(){ brew install "$@"; } _punani_brew_remove(){ brew remove "$@";} -_punani_brew_has(){ error "not implemented"; return 1 ;} +_punani_brew_has() { die '_punani_brew_has not implemented'; } -- cgit v1.2.3 From fc4ac74b1e9cc40d27fd3e6bcfe67e0cb06469d2 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 13:54:03 +0100 Subject: ship punani: mv {,_}_punani_resolve_package --- ship/lib/punani | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ship/lib/punani b/ship/lib/punani index 72be0351..18a78b4d 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -13,7 +13,7 @@ punani(){ fi for PKG; do - RES="`_punani_resolve_package $PKG`" || + RES="`__punani_resolve_package $PKG`" || die "could not resolve '$PKG'; no punani for you!" case "$ACTION" in @@ -60,8 +60,8 @@ _punani_remove() { eval "_punani_${PACKER}_remove \"\$1\"" } -## usage: _punani_resolve_package PKGNAME -_punani_resolve_package(){ +## usage: __punani_resolve_package PKGNAME +__punani_resolve_package(){ eval "set -u; echo \"\${_punanidb_${PACKER}_$1}\"" 2>/dev/null } -- cgit v1.2.3 From 4be2166457e5b55101d55f4c23b9b2a0c6fe6fe3 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 13:55:32 +0100 Subject: ship punani: implicit "not implemented" messages --- ship/lib/punani | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ship/lib/punani b/ship/lib/punani index 18a78b4d..4a8105b6 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -83,4 +83,4 @@ _punani_yum_remove(){ yum -y remove "$@" ;} _punani_yum_has() { rpm -qa --qf "%{NAME}\n"| egrep "^${1}\$" >/dev/null ;} _punani_brew_install(){ brew install "$@"; } _punani_brew_remove(){ brew remove "$@";} -_punani_brew_has() { die '_punani_brew_has not implemented'; } +# TODO _punani_brew_has -- cgit v1.2.3 From 7a3fba63f0893565f97f1ff06ff60092e5426988 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 13:58:58 +0100 Subject: ship punani: lower hierarchy --- ship/lib/punani | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/ship/lib/punani b/ship/lib/punani index 4a8105b6..13413b54 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -3,7 +3,7 @@ _punani_usage='punani {install,remove,has} PACKAGE...' punani(){ - __punani_select_packer || die 'no package manager found; no punani for you!' + _punani_select_packer || die 'no package manager found; no punani for you!' ACTION="$1"; shift @@ -13,26 +13,26 @@ punani(){ fi for PKG; do - RES="`__punani_resolve_package $PKG`" || + RES="`_punani_resolve_package $PKG`" || die "could not resolve '$PKG'; no punani for you!" case "$ACTION" in install) - if _punani_has $RES; then + if punani_has $RES; then info "$RES already installed, skipping" else - _punani_install $RES || error "cannot install $RES with $PACKER" + punani_install $RES || error "cannot install $RES with $PACKER" fi ;; remove) - if ! _punani_has $RES; then + if ! punani_has $RES; then info "$RES not installed, skipping" else - _punani_remove $RES || error "cannot install $RES with $PACKER" + punani_remove $RES || error "cannot install $RES with $PACKER" fi ;; has) - if _punani_has $RES; then + if punani_has $RES; then info "$RES is installed" else info "$RES is not installed" @@ -45,33 +45,33 @@ punani(){ done } -## usage: _punani_has PACKAGE -_punani_has() { +## usage: punani_has PACKAGE +punani_has() { eval "_punani_${PACKER}_has \"\$1\"" } -## usage: _punani_install PACKAGE -_punani_install() { +## usage: punani_install PACKAGE +punani_install() { eval "_punani_${PACKER}_install \"\$1\"" } -## usage: _punani_remove PACKAGE -_punani_remove() { +## usage: punani_remove PACKAGE +punani_remove() { eval "_punani_${PACKER}_remove \"\$1\"" } -## usage: __punani_resolve_package PKGNAME -__punani_resolve_package(){ +## usage: _punani_resolve_package PKGNAME +_punani_resolve_package(){ eval "set -u; echo \"\${_punanidb_${PACKER}_$1}\"" 2>/dev/null } -## usage: __punani_select_packer -__punani_select_packer() { - for p in ${__punani_known_packers:-null}; do +## usage: _punani_select_packer +_punani_select_packer() { + for p in ${_punani_known_packers:-null}; do exists $p && info "using $p" && PACKER=`echo $p | tr -d -` && break done } -__punani_known_packers='pacman apt-get yum brew' +_punani_known_packers='pacman apt-get yum brew' _punani_pacman_install(){ pacman --noconfirm -S --needed "$@" ;} _punani_pacman_remove(){ pacman -Rcs "$@" ;} _punani_pacman_has(){ pacman -Q "$1" >/dev/null;} -- cgit v1.2.3 From 36a7b004e2d3bbc3858a6378b3ef19ea3e15f4a1 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 14:04:57 +0100 Subject: ship punani: mv user interface to src/ --- ship/lib/punani | 44 -------------------------------------------- ship/src/punani | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 44 deletions(-) diff --git a/ship/lib/punani b/ship/lib/punani index 13413b54..264d1daf 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -1,50 +1,6 @@ #@include core #@include _punani_db -_punani_usage='punani {install,remove,has} PACKAGE...' -punani(){ - _punani_select_packer || die 'no package manager found; no punani for you!' - - ACTION="$1"; shift - - if test $# = 0; then - error 'no PACKAGE specified.' - die "usage: $_punani_usage" - fi - - for PKG; do - RES="`_punani_resolve_package $PKG`" || - die "could not resolve '$PKG'; no punani for you!" - - case "$ACTION" in - install) - if punani_has $RES; then - info "$RES already installed, skipping" - else - punani_install $RES || error "cannot install $RES with $PACKER" - fi - ;; - remove) - if ! punani_has $RES; then - info "$RES not installed, skipping" - else - punani_remove $RES || error "cannot install $RES with $PACKER" - fi - ;; - has) - if punani_has $RES; then - info "$RES is installed" - else - info "$RES is not installed" - fi - ;; - *) - error "bad action: $ACTION" - die "usage: $_punani_usage" - esac - done -} - ## usage: punani_has PACKAGE punani_has() { eval "_punani_${PACKER}_has \"\$1\"" diff --git a/ship/src/punani b/ship/src/punani index ceabd667..61043bc0 100755 --- a/ship/src/punani +++ b/ship/src/punani @@ -1,4 +1,47 @@ #! /bin/sh #@info #@include punani +punani(){ + _punani_usage='punani {install,remove,has} PACKAGE...' + _punani_select_packer || die 'no package manager found; no punani for you!' + + ACTION="$1"; shift + + if test $# = 0; then + error 'no PACKAGE specified.' + die "usage: $_punani_usage" + fi + + for PKG; do + RES="`_punani_resolve_package $PKG`" || + die "could not resolve '$PKG'; no punani for you!" + + case "$ACTION" in + install) + if punani_has $RES; then + info "$RES already installed, skipping" + else + punani_install $RES || error "cannot install $RES with $PACKER" + fi + ;; + remove) + if ! punani_has $RES; then + info "$RES not installed, skipping" + else + punani_remove $RES || error "cannot install $RES with $PACKER" + fi + ;; + has) + if punani_has $RES; then + info "$RES is installed" + else + info "$RES is not installed" + fi + ;; + *) + error "bad action: $ACTION" + die "usage: $_punani_usage" + esac + done +} punani "$@" -- cgit v1.2.3 From fd3ddc6abe23f83f304c2043fe9cabe1ee8a622c Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 14 Nov 2013 14:13:35 +0100 Subject: ship punani: add experimental owner interface --- ship/lib/punani | 6 ++++++ ship/src/punani | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ship/lib/punani b/ship/lib/punani index 264d1daf..33a62444 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -6,6 +6,11 @@ punani_has() { eval "_punani_${PACKER}_has \"\$1\"" } +## usage: punani_owner PACKAGE +punani_owner() { + eval "_punani_${PACKER}_owner \"\$1\"" +} + ## usage: punani_install PACKAGE punani_install() { eval "_punani_${PACKER}_install \"\$1\"" @@ -31,6 +36,7 @@ _punani_known_packers='pacman apt-get yum brew' _punani_pacman_install(){ pacman --noconfirm -S --needed "$@" ;} _punani_pacman_remove(){ pacman -Rcs "$@" ;} _punani_pacman_has(){ pacman -Q "$1" >/dev/null;} +_punani_pacman_owner() { pacman -Qo "$1"; } _punani_aptget_install(){ apt-get -y install "$@" ;} _punani_aptget_remove(){ apt-get -y remove "$@" ;} _punani_aptget_has() { dpkg -s "$1" | grep -q "Status: install";} diff --git a/ship/src/punani b/ship/src/punani index 61043bc0..2c956f02 100755 --- a/ship/src/punani +++ b/ship/src/punani @@ -2,7 +2,7 @@ #@info #@include punani punani(){ - _punani_usage='punani {install,remove,has} PACKAGE...' + _punani_usage='punani {install,remove,has,owner} PACKAGE...' _punani_select_packer || die 'no package manager found; no punani for you!' ACTION="$1"; shift @@ -38,6 +38,9 @@ punani(){ info "$RES is not installed" fi ;; + owner) + punani_owner $RES + ;; *) error "bad action: $ACTION" die "usage: $_punani_usage" -- cgit v1.2.3 From 15030e13242fa464619c63c54294043d69a3ba0f Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 14 Nov 2013 14:59:22 +0100 Subject: add aptget and yum owner functionality --- ship/lib/punani | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ship/lib/punani b/ship/lib/punani index 33a62444..34307c42 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -40,9 +40,11 @@ _punani_pacman_owner() { pacman -Qo "$1"; } _punani_aptget_install(){ apt-get -y install "$@" ;} _punani_aptget_remove(){ apt-get -y remove "$@" ;} _punani_aptget_has() { dpkg -s "$1" | grep -q "Status: install";} +_punani_aptget_owner() { dpkg-query -S "$1" | cut -d: -f1;} _punani_yum_install(){ yum -y install "$@" ;} _punani_yum_remove(){ yum -y remove "$@" ;} _punani_yum_has() { rpm -qa --qf "%{NAME}\n"| egrep "^${1}\$" >/dev/null ;} +_punani_yum_owner(){ rpm -qf "$1" ;} _punani_brew_install(){ brew install "$@"; } _punani_brew_remove(){ brew remove "$@";} # TODO _punani_brew_has -- cgit v1.2.3 From 317ddcfd91dd351d4a957793bf7b7fc2da7a8969 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 15 Nov 2013 11:27:52 +0100 Subject: ledger balance: drop 0-accounts --- ledger/lib/balance | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ledger/lib/balance b/ledger/lib/balance index c9a1fd87..deb50d15 100755 --- a/ledger/lib/balance +++ b/ledger/lib/balance @@ -67,9 +67,12 @@ function display_accounts() { for (name in accounts) { for (u in accounts[name]) { + balance = accounts[name][u] + if (balance == 0) { + continue + } fmt = "NAME BALANCE UNIT\n" - balance = accounts[name][u] if (colorize) { sub("BALANCE", "[" (balance < 0 ? 31 : 32) "m&", fmt) -- cgit v1.2.3 From dfec00ff7b45e2c9c1ff73bc4bd2661c856326e9 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 15 Nov 2013 19:05:45 +0100 Subject: tinc-install: fixed os detection --- retiolum/scripts/tinc_setup/new_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 226e7c1b..1ebde38b 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -336,7 +336,7 @@ find_os() { if grep -qe 'Linux' /etc/*release 2>/dev/null || grep -qe 'Linux' /etc/issue 2>/dev/null; then OS='linux' - elif exists getprop ; then + elif test -e /etc/preferred-apps/google.xml; then OS='android' elif test -e /etc/openwrt_release; then OS='openwrt' -- cgit v1.2.3 From 8c897886b42f62786b925184b56bafc1a7e06a2f Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 17 Nov 2013 21:03:25 +0100 Subject: hosts: added rtjure_debian... --- retiolum/hosts/rtjure_debian_oder_so | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 retiolum/hosts/rtjure_debian_oder_so diff --git a/retiolum/hosts/rtjure_debian_oder_so b/retiolum/hosts/rtjure_debian_oder_so new file mode 100644 index 00000000..ecce382b --- /dev/null +++ b/retiolum/hosts/rtjure_debian_oder_so @@ -0,0 +1,11 @@ +Subnet = 10.243.124.21 +Subnet = 42:9d30:3845:c822:988b:96c5:39ab:90b7 + +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEA6J+B/2Wpr9MKu5fuWg9LSoabBKmWmXEWfN7Bs5KMyux9obSBaM8y +dUEx0ayGwUOvDxizuhma9YCbys4P9SDGmocxrhFz2yQeyinEj03EB9ZZiPNQSqbI +Jia39Q/fkxeCescUjr63wR0OY++a+NdefVG5OaSRhNwAmjENZzAxTE/1y5lR7mf4 +U0Pyik/BIARZIc7rnwoYn2TlGgUlu3HX7BxCXIndOFeIjtRzoSG6d+XKhcTXOvvH +WnBNl2D5i48l+V/mDDbLYcXS0al3lgFAOgqXxVXr9WufCBGtNdxlgWlM4zSTUQZw +UopJToHcnucM3ofb/NrDs3ygHdQPSRkhhQIDAQAB +-----END RSA PUBLIC KEY----- -- cgit v1.2.3 From e24e4ed994c7ebc2ee4ca1279b19ac91bbc21585 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 17 Nov 2013 21:17:03 +0100 Subject: hosts: fixed spaces --- retiolum/hosts/rtjure_debian_oder_so | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/retiolum/hosts/rtjure_debian_oder_so b/retiolum/hosts/rtjure_debian_oder_so index ecce382b..3000705b 100644 --- a/retiolum/hosts/rtjure_debian_oder_so +++ b/retiolum/hosts/rtjure_debian_oder_so @@ -1,11 +1,11 @@ -Subnet = 10.243.124.21 -Subnet = 42:9d30:3845:c822:988b:96c5:39ab:90b7 - ------BEGIN RSA PUBLIC KEY----- +Subnet = 10.243.124.21 +Subnet = 42:9d30:3845:c822:988b:96c5:39ab:90b7 + +-----BEGIN RSA PUBLIC KEY----- MIIBCgKCAQEA6J+B/2Wpr9MKu5fuWg9LSoabBKmWmXEWfN7Bs5KMyux9obSBaM8y dUEx0ayGwUOvDxizuhma9YCbys4P9SDGmocxrhFz2yQeyinEj03EB9ZZiPNQSqbI Jia39Q/fkxeCescUjr63wR0OY++a+NdefVG5OaSRhNwAmjENZzAxTE/1y5lR7mf4 U0Pyik/BIARZIc7rnwoYn2TlGgUlu3HX7BxCXIndOFeIjtRzoSG6d+XKhcTXOvvH WnBNl2D5i48l+V/mDDbLYcXS0al3lgFAOgqXxVXr9WufCBGtNdxlgWlM4zSTUQZw -UopJToHcnucM3ofb/NrDs3ygHdQPSRkhhQIDAQAB ------END RSA PUBLIC KEY----- +UopJToHcnucM3ofb/NrDs3ygHdQPSRkhhQIDAQAB +-----END RSA PUBLIC KEY----- -- cgit v1.2.3 From 642ea636c6d32904b8eb670f9ebc47cb5f4fad31 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 17 Nov 2013 23:05:16 +0100 Subject: hosts: removed dead rtjure --- retiolum/hosts/rtjure | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 retiolum/hosts/rtjure diff --git a/retiolum/hosts/rtjure b/retiolum/hosts/rtjure deleted file mode 100644 index f79b42a9..00000000 --- a/retiolum/hosts/rtjure +++ /dev/null @@ -1,10 +0,0 @@ -Subnet = 42:10ce:c102:97e9:f234:fc0d:3e91:1ac0/128 -Subnet = 42.122.79.178/32 ------BEGIN RSA PUBLIC KEY----- -MIIBCgKCAQEA1yyfTmYInif82KH/bz6Z2tzSp6loe6wJuBmjTbxIl9AFvGPgYNSI -QCyzZtqcK55+fbA1dQiF1aZLxADM/H42AvrDAKX5C0qi7K4OhciqckutLS6OxwQu -jnfCA6CST8LQ3cy6CIjjQfuBzQWcU79UwgCIJZuJknHYOIJ9j3BBHU8XVJqY2qxB -nE8yIyDstY/hVOLgsLTteWGCTq52C+U19LND1/3T70iWqiJgepsGjVCa/M1v/SLg -acboxH1jRyX+bVbjPCAG2OKQO+hTqJnjVX8LO2qlnxovUDx36igzGCjTGKFA/KVW -+FxMAVZdNRTTzLiB+LUenXb8E8/uqBj3bwIDAQAB ------END RSA PUBLIC KEY----- -- cgit v1.2.3 From 001b7332766fb80aa81e06f169254e9f9e115f53 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 18 Nov 2013 21:34:15 +0100 Subject: utils: new pigbin --- util/bin/pigbin | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 util/bin/pigbin diff --git a/util/bin/pigbin b/util/bin/pigbin new file mode 100755 index 00000000..9379f53c --- /dev/null +++ b/util/bin/pigbin @@ -0,0 +1,2 @@ +#!/bin/sh +curl -F "p=<-" pigstarter:5000 -- cgit v1.2.3 From 6f956cfe65ee00871bc9be19b2acadabb6638a69 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 18 Nov 2013 21:36:40 +0100 Subject: utils pigbin: usage --- util/bin/pigbin | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/bin/pigbin b/util/bin/pigbin index 9379f53c..a0b9521d 100755 --- a/util/bin/pigbin +++ b/util/bin/pigbin @@ -1,2 +1,5 @@ #!/bin/sh -curl -F "p=<-" pigstarter:5000 +#usage: +#echo aidsballs | pigbin + +curl -F 'p=<-' pigstarter:5000 -- cgit v1.2.3