diff options
-rw-r--r-- | gold/bitcoinwisdom/index.js | 84 | ||||
-rwxr-xr-x | ledger/lib/balance | 5 | ||||
-rw-r--r-- | retiolum/hosts/rtjure | 10 | ||||
-rw-r--r-- | retiolum/hosts/rtjure_debian_oder_so | 11 | ||||
-rwxr-xr-x | retiolum/scripts/tinc_setup/new_install.sh | 2 | ||||
-rwxr-xr-x | ship/build | 8 | ||||
-rw-r--r-- | ship/lib/core | 13 | ||||
-rw-r--r-- | ship/lib/network | 3 | ||||
-rw-r--r-- | ship/lib/punani | 84 | ||||
-rwxr-xr-x | ship/src/punani | 46 | ||||
-rwxr-xr-x | ship/src/remaster_arch_iso | 6 | ||||
-rwxr-xr-x | ship/src/retiolum | 26 | ||||
-rwxr-xr-x | util/bin/pigbin | 5 |
13 files changed, 130 insertions, 173 deletions
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 + '[m', - 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/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&[m", fmt) 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----- diff --git a/retiolum/hosts/rtjure_debian_oder_so b/retiolum/hosts/rtjure_debian_oder_so new file mode 100644 index 00000000..3000705b --- /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----- 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' @@ -44,8 +44,8 @@ EOF build_info() { cat<<EOF $1a\\ # this file was generated by //ship/build\\ -# date: $(date -u --rfc-3339=s)\\ -# version: $(git rev-parse HEAD) +# build date: $(date -u --rfc-3339=s)\\ +# git describe: $(git describe --always --dirty --abbrev=0) EOF } @@ -181,4 +181,6 @@ buildcache_add() { ### main invocation ### -build "$@" +if echo "$0" | grep -q '^\(.*/\)\?build$'; then + build "$@" +fi diff --git a/ship/lib/core b/ship/lib/core index d1a7333e..d6e01352 100644 --- a/ship/lib/core +++ b/ship/lib/core @@ -1,8 +1,13 @@ # logging -msg() { printf "$@\n" >&2 ;} -info() { msg "** $@" ;} -error() { msg "!! $@" ;} -die() { error "$@" ;exit 1;} +msg() { echo "$*" >&2; } +info() { msg "** $*"; } +error() { msg "!! $*"; } +## usage: die [REASON...] +die() { + test $# -gt 0 && 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..34307c42 100644 --- a/ship/lib/punani +++ b/ship/lib/punani @@ -1,60 +1,50 @@ #@include core #@include _punani_db +## usage: punani_has PACKAGE +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\"" +} + +## usage: punani_remove PACKAGE +punani_remove() { + eval "_punani_${PACKER}_remove \"\$1\"" +} + +## usage: _punani_resolve_package PKGNAME _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 . + 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_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_pacman_install(){ pacman --noconfirm -S --needed "$@" ;} -_punani_pacman_remove(){ pacman -Rcs "$@" ;} -_punani_pacman_has(){ pacman -Q "$1" >/dev/null;} +_punani_yum_owner(){ rpm -qf "$1" ;} _punani_brew_install(){ brew install "$@"; } _punani_brew_remove(){ brew remove "$@";} -_punani_brew_has(){ error "not implemented"; return 1 ;} - -punani(){ - 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 - 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" - ;; - 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" - ;; - has) - if eval _punani_${PACKER}_has $RES ;then - info "$RES is installed" - else - info "$RES is not installed" - fi - ;; - *) - error "usage: punani (install|remove|has) PACKAGE..." - return 23 - esac - done -} +# TODO _punani_brew_has diff --git a/ship/src/punani b/ship/src/punani index ceabd667..2c956f02 100755 --- a/ship/src/punani +++ b/ship/src/punani @@ -1,4 +1,50 @@ #! /bin/sh #@info #@include punani +punani(){ + _punani_usage='punani {install,remove,has,owner} 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 + ;; + owner) + punani_owner $RES + ;; + *) + error "bad action: $ACTION" + die "usage: $_punani_usage" + esac + done +} punani "$@" diff --git a/ship/src/remaster_arch_iso b/ship/src/remaster_arch_iso index 046b005b..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,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.' fi defer "info 'unmounting $isomnt';umount $isomnt" 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 } diff --git a/util/bin/pigbin b/util/bin/pigbin new file mode 100755 index 00000000..a0b9521d --- /dev/null +++ b/util/bin/pigbin @@ -0,0 +1,5 @@ +#!/bin/sh +#usage: +#echo aidsballs | pigbin + +curl -F 'p=<-' pigstarter:5000 |