summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ext/ovh/README (renamed from ovh/README)0
-rw-r--r--ext/ovh/soapi/Makefile (renamed from ovh/soapi/Makefile)0
-rw-r--r--ext/ovh/soapi/README (renamed from ovh/soapi/README)0
-rwxr-xr-xext/ovh/soapi/domainCapabilities (renamed from ovh/soapi/domainCapabilities)0
-rwxr-xr-xext/ovh/soapi/domainInfo (renamed from ovh/soapi/domainInfo)0
-rwxr-xr-xext/ovh/soapi/domainList (renamed from ovh/soapi/domainList)0
-rw-r--r--ext/ovh/soapi/soapi-re-1.24.wsdl (renamed from ovh/soapi/soapi-re-1.24.wsdl)0
-rwxr-xr-xext/ovh/soapi/zoneEntryAdd (renamed from ovh/soapi/zoneEntryAdd)0
-rwxr-xr-xext/ovh/soapi/zoneEntryDel (renamed from ovh/soapi/zoneEntryDel)0
-rwxr-xr-xext/ovh/soapi/zoneEntryList (renamed from ovh/soapi/zoneEntryList)0
-rwxr-xr-xext/ovh/soapi/zoneExport (renamed from ovh/soapi/zoneExport)0
-rwxr-xr-xext/ovh/soapi/zoneImport (renamed from ovh/soapi/zoneImport)0
-rwxr-xr-xext/solus/bin/client28
-rwxr-xr-xext/solus/lib/parse-return-data20
-rwxr-xr-xgold/mtgox/mtgox.ticker53
-rwxr-xr-x[-rw-r--r--]minikrebs/profiles/init_overlay20
l---------minikrebs/profiles/instakrebs/customfiles/etc/rc.d/tinc1
-rwxr-xr-xminikrebs/profiles/nfc-login/customfiles/usr/bin/login-manager14
-rwxr-xr-xminikrebs/profiles/nfc-login/customfiles/usr/bin/mrled4
-rw-r--r--retiolum/hosts/ire12
-rw-r--r--retiolum/hosts/rage12
-rw-r--r--services/Makefile3
-rw-r--r--services/README.md25
-rwxr-xr-xservices/bin/services11
-rw-r--r--services/etc/conf.d/krebs-services-test-server3
-rw-r--r--services/etc/services/bootstrap9
-rw-r--r--services/etc/systemd/system/krebs-services-test-server.service14
-rw-r--r--services/services.txt9
-rwxr-xr-x[-rw-r--r--]services/test-server.py (renamed from services/test.py)10
-rw-r--r--util/README.markdown27
-rwxr-xr-xutil/bin/with6
31 files changed, 259 insertions, 22 deletions
diff --git a/ovh/README b/ext/ovh/README
index 90b34108..90b34108 100644
--- a/ovh/README
+++ b/ext/ovh/README
diff --git a/ovh/soapi/Makefile b/ext/ovh/soapi/Makefile
index 15ef8f3f..15ef8f3f 100644
--- a/ovh/soapi/Makefile
+++ b/ext/ovh/soapi/Makefile
diff --git a/ovh/soapi/README b/ext/ovh/soapi/README
index 42ad5ebf..42ad5ebf 100644
--- a/ovh/soapi/README
+++ b/ext/ovh/soapi/README
diff --git a/ovh/soapi/domainCapabilities b/ext/ovh/soapi/domainCapabilities
index a438e0b8..a438e0b8 100755
--- a/ovh/soapi/domainCapabilities
+++ b/ext/ovh/soapi/domainCapabilities
diff --git a/ovh/soapi/domainInfo b/ext/ovh/soapi/domainInfo
index 35459d06..35459d06 100755
--- a/ovh/soapi/domainInfo
+++ b/ext/ovh/soapi/domainInfo
diff --git a/ovh/soapi/domainList b/ext/ovh/soapi/domainList
index 342eec72..342eec72 100755
--- a/ovh/soapi/domainList
+++ b/ext/ovh/soapi/domainList
diff --git a/ovh/soapi/soapi-re-1.24.wsdl b/ext/ovh/soapi/soapi-re-1.24.wsdl
index c628c564..c628c564 100644
--- a/ovh/soapi/soapi-re-1.24.wsdl
+++ b/ext/ovh/soapi/soapi-re-1.24.wsdl
diff --git a/ovh/soapi/zoneEntryAdd b/ext/ovh/soapi/zoneEntryAdd
index 20ecd1fd..20ecd1fd 100755
--- a/ovh/soapi/zoneEntryAdd
+++ b/ext/ovh/soapi/zoneEntryAdd
diff --git a/ovh/soapi/zoneEntryDel b/ext/ovh/soapi/zoneEntryDel
index c8137fc1..c8137fc1 100755
--- a/ovh/soapi/zoneEntryDel
+++ b/ext/ovh/soapi/zoneEntryDel
diff --git a/ovh/soapi/zoneEntryList b/ext/ovh/soapi/zoneEntryList
index 63d0f1c6..63d0f1c6 100755
--- a/ovh/soapi/zoneEntryList
+++ b/ext/ovh/soapi/zoneEntryList
diff --git a/ovh/soapi/zoneExport b/ext/ovh/soapi/zoneExport
index 7747ded4..7747ded4 100755
--- a/ovh/soapi/zoneExport
+++ b/ext/ovh/soapi/zoneExport
diff --git a/ovh/soapi/zoneImport b/ext/ovh/soapi/zoneImport
index 42d46caf..42d46caf 100755
--- a/ovh/soapi/zoneImport
+++ b/ext/ovh/soapi/zoneImport
diff --git a/ext/solus/bin/client b/ext/solus/bin/client
new file mode 100755
index 00000000..60b720d6
--- /dev/null
+++ b/ext/solus/bin/client
@@ -0,0 +1,28 @@
+#! /bin/sh
+# usage: client ACTION
+# ACTION: boot, info, reboot, shutdown, or status
+# environment:
+# api_url URL to the client API like https://<MASTER IP>:5656/api/client
+# api_key
+# api_hash
+set -euf
+
+url="$api_url/command.php"
+key="$api_key"
+hash="$api_hash"
+
+action="${1-$ACTION}"
+
+case "$action" in
+ (info)
+ # get all the information
+ action="$action&ipaddr=true&hdd=true&mem=true&bw=true";;
+esac
+
+abspath="`readlink -f "$0"`"
+bindir="`dirname "$abspath"`"
+libdir="`dirname "$bindir"`/lib"
+export PATH="$libdir:$PATH"
+
+curl -sS -d key="$key" -d hash="$hash" -d action="$action" "$url" |
+ parse-return-data
diff --git a/ext/solus/lib/parse-return-data b/ext/solus/lib/parse-return-data
new file mode 100755
index 00000000..85219727
--- /dev/null
+++ b/ext/solus/lib/parse-return-data
@@ -0,0 +1,20 @@
+#! /bin/sh
+set -euf
+sed '
+ # transform "XML" into lines {key}<tab>{value}-lines
+ s|</[^>]*>|\n|g
+ s|<\([^>]*\)>|\1\t|g
+' |
+sed '
+ # transform ipaddr list into multiple ipaddr_[46]<tab>{ipaddr}-lines
+ /^ipaddr\t/{
+ s|,|\nipaddr\t|g
+ s/\t\([0-9]*[.]\)/_4&/g
+ s/\t\([0-9]*[:]\)/_6&/g
+ }
+ # parse CSVs into multiple lines with proper labels
+ s:^\(hdd\|mem\|bw\)\t\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\)$:\1_total\t\2\
+\1_used\t\3\
+\1_free\t\4\
+\1_percentused\t\5:
+'
diff --git a/gold/mtgox/mtgox.ticker b/gold/mtgox/mtgox.ticker
index b24dfb35..32ee53bf 100755
--- a/gold/mtgox/mtgox.ticker
+++ b/gold/mtgox/mtgox.ticker
@@ -1,4 +1,53 @@
#! /bin/sh
-# get mtgox ticker data
+# 2012-06-07 ~tv@iiso:bin/mtgox.ticker
set -euf
-curl -ksS https://mtgox.com/code/data/ticker.php
+
+Currency=${Currency-EUR}
+
+# continuous ticker
+## usage: mtgox.ticker -f [time] [json-path...]
+if test $# -ge 1 && test "$1" = -f; then
+ shift
+ time=`echo "$1" | grep '^[1-9][0-9]*[h]\?$'` && shift || time=60
+ echo -n "# sleep time: $time"
+ while echo -n "
+`date --rfc-3339=s` `"$0" "$@"`"; do
+ sleep $time
+ done
+ exit
+fi
+
+# 2012-11-17 tv /krebs/gold/mtgox/mtgox.ticker
+ticker() {
+ curl -ksS https://mtgox.com/code/data/ticker.php?Currency=$Currency
+}
+# 2012-11-17 tv ~mw*@iiso:Espresso-phonegap/package/bin/json-print
+print() {
+ node -e "
+// 2012-11-17 tv
+//filename = process.argv[2]
+filename = process.argv[1]
+jsonpath = []
+value = JSON.parse(require('fs').readFileSync(filename))
+// 2012-11-17 tv
+//process.argv.slice(3).forEach(function (key) {
+process.argv.slice(2).forEach(function (key) {
+ value = value[key]
+ jsonpath.push(key)
+ if (typeof value === 'undefined') {
+ console.error(filename + ':', jsonpath.join('.'), 'is', value)
+ process.exit(23)
+ }
+})
+
+console.log(JSON.stringify(value, null, 2))
+" "$@"
+}
+
+# ticker
+## usage: mtgox.ticker [json-path...] -> json
+# 2012-11-17 tv
+#/krebs/gold/mtgox/mtgox.ticker |
+# ~mw*@iiso:Espresso-phonegap/package/bin/json-print /dev/stdin ticker "$@"
+ticker |
+ print /dev/stdin ticker "$@"
diff --git a/minikrebs/profiles/init_overlay b/minikrebs/profiles/init_overlay
index 3b714c39..e71cd151 100644..100755
--- a/minikrebs/profiles/init_overlay
+++ b/minikrebs/profiles/init_overlay
@@ -1,10 +1,22 @@
-#!/bin/sh
+#!/bin/bash
+cd $(dirname $(readlink -f $0))
[ ! -e overlay/ ] && echo "profile data for external overlay does not exist, bailing out"
-[ ! -e doc/overlay ] && echo "Profile demands the following partitioning of the overlay usb stick:" && cat doc/overlay
+[ -e doc/overlay ] && echo "Profile demands the following partitioning of the overlay usb stick:" && cat doc/OVERLAY
if grep -q $PWD/mnt/overlay /etc/mtab;then
-
+ echo "overlay mounted"
+ echo "copying overlay data:"
+ find overlay/ -mindepth 1 -maxdepth 1 | while read data; do
+ echo " $data -> mnt/overlay/$(basename $data)"
+ rm -rf mnt/overlay/$(basename $data)
+ cp -r $data mnt/overlay
+ done
+ echo
+ echo "unmounting overlay"
+ umount mnt/overlay/
else
- echo "please mount your overlay to $PWD/overlay"
+ mkdir -p $PWD/mnt/overlay
+ echo "please mount your overlay to $PWD/mnt/overlay"
fi
+
diff --git a/minikrebs/profiles/instakrebs/customfiles/etc/rc.d/tinc b/minikrebs/profiles/instakrebs/customfiles/etc/rc.d/tinc
deleted file mode 120000
index f08fe11d..00000000
--- a/minikrebs/profiles/instakrebs/customfiles/etc/rc.d/tinc
+++ /dev/null
@@ -1 +0,0 @@
-../init.d/tinc \ No newline at end of file
diff --git a/minikrebs/profiles/nfc-login/customfiles/usr/bin/login-manager b/minikrebs/profiles/nfc-login/customfiles/usr/bin/login-manager
index 63f35c74..f22a209e 100755
--- a/minikrebs/profiles/nfc-login/customfiles/usr/bin/login-manager
+++ b/minikrebs/profiles/nfc-login/customfiles/usr/bin/login-manager
@@ -1,18 +1,18 @@
#!/bin/sh
-#!/bin/sh
#LOGIN_HOST=heidi.shack
#LOGIN_HOST=heidi:5000
LOGIN_HOST=10.42.10.38:5000
all_led(){
- for i in 3g wlan lan wps;do
- led $i $1
- done
+ for i in 3g wlan lan wps;do
+ led $i $1
+
+ done
}
led(){
- LED="$1"
- ACTION="$2"
- echo $ACTION > /sys/class/leds/tp-link:green:$LED/trigger
+ /usr/bin/mrled $1 $2
}
+
+# fix for mr3020 weirdness
while sleep 1; do
uid=$(nfc-list | grep UID | cut -d: -f 2 | sed 's/ //g')
if ! [ x"$uid" = x ];then
diff --git a/minikrebs/profiles/nfc-login/customfiles/usr/bin/mrled b/minikrebs/profiles/nfc-login/customfiles/usr/bin/mrled
new file mode 100755
index 00000000..7059edd1
--- /dev/null
+++ b/minikrebs/profiles/nfc-login/customfiles/usr/bin/mrled
@@ -0,0 +1,4 @@
+#!/bin/sh
+LED="$1"
+ACTION="$2"
+echo $ACTION > /sys/class/leds/tp-link:green:$LED/trigger
diff --git a/retiolum/hosts/ire b/retiolum/hosts/ire
new file mode 100644
index 00000000..724158cb
--- /dev/null
+++ b/retiolum/hosts/ire
@@ -0,0 +1,12 @@
+Address = 198.147.23.143
+Subnet = 10.243.231.66
+Subnet = 42:b912:0f42:a82d:0d27:8610:e89b:490c
+
+-----BEGIN RSA PUBLIC KEY-----
+MIIBCgKCAQEAwofjmP/XBf5pwsJlWklkSzI+Bo0I0B9ONc7/j+zpbmMRkwbWk4X7
+rVLt1cWvTY15ujg2u8l0o6OgEbIkc6rslkD603fv1sEAd0KOv7iKLgRpE9qfSvAt
+6YpiSv+mxEMTpH0g36OmBfOJ10uT+iHDB/FfxmgGJx//jdJADzLjjWC6ID+iGkGU
+1Sf+yHXF7HRmQ29Yak8LYVCJpGC5bQfWIMSL5lujLq4NchY2d+NZDkuvh42Ayr0K
+LPflnPBQ3XnKHKtSsnFR2vaP6q+d3Opsq/kzBnAkjL26jEuFK1v7P/HhNhJoPzwu
+nKKWj/W/k448ce374k5ycjvKm0c6baAC/wIDAQAB
+-----END RSA PUBLIC KEY-----
diff --git a/retiolum/hosts/rage b/retiolum/hosts/rage
new file mode 100644
index 00000000..35da19f6
--- /dev/null
+++ b/retiolum/hosts/rage
@@ -0,0 +1,12 @@
+Address = 192.40.56.122
+Subnet = 10.243.211.81
+Subnet = 42:73d5:8402:f8f1:0250:0bc3:e2ec:850d
+
+-----BEGIN RSA PUBLIC KEY-----
+MIIBCgKCAQEA6dOSRjCwkdx/nOSQwiiCw889YBSlf0ZAymBSaWJ+XdLnktqqZIvQ
++1RMdfpTTsIaHoLDwvBI6gW9dhV5MEeP3AlWfKPZAMCWg8l3PkTERZILWGSLiizs
+zCyJgLpsb2MP7rT3RlLlHyTNdx9QXxDX2K1Y/fJsjXuTTgwg3JPlPM2huGTZtWgM
+GDFsRpfe37hIuIheYBgnP99OvEgx3rLyCDvd16kIMd2Pjx4SouVQqaBmvEmg+UEH
+zD79GaO7c2xkqq6JggJw1q/xZnH+5CF8280kh/niXVqy8R/hP75FU1rvjHnMJvfo
+nyPGC8ir2m6iy4CR07YBIYo1PRTXGDC1vwIDAQAB
+-----END RSA PUBLIC KEY-----
diff --git a/services/Makefile b/services/Makefile
index 3ef670a3..37931f47 100644
--- a/services/Makefile
+++ b/services/Makefile
@@ -1,5 +1,6 @@
help:;@cat Makefile
export authorized_keys_file := authorized_keys
+export debug_log := true
export services_file := services.txt
export host_key_file := test.key
export services_home := /opt/services
@@ -32,7 +33,7 @@ test-client:
ssh localhost -p 1337 2>/dev/null
test-server:
- python test.py
+ ./test-server.py
$(host_key_file):
ssh-keygen -t rsa -P '' -f $@
diff --git a/services/README.md b/services/README.md
new file mode 100644
index 00000000..e0769bce
--- /dev/null
+++ b/services/README.md
@@ -0,0 +1,25 @@
+# //services
+
+## install and run test-server.py as systemd service
+
+### install dependencies
+
+ pacman -S python2-pyasn1 twisted
+
+### install systemd service and configuration
+
+ cp /krebs/services/etc/systemd/system/krebs-services-test-server.service \
+ /etc/systemd/system/
+ cp /krebs/services/etc/conf.d/krebs-services-test-server \
+ /etc/conf.d/
+
+### create services user and populate it's home
+
+ useradd -m -r -l -f -1 -d /opt/services -k /var/empty services
+ sudo -u services ssh-keygen -t rsa -P '' -f /opt/services/test.key
+ $EDITOR /opt/services/services.txt
+
+### run now and every reboot
+
+ systemctl start krebs-services-test-server
+ systemctl enable krebs-services-test-server
diff --git a/services/bin/services b/services/bin/services
index c142a363..e854cbcb 100755
--- a/services/bin/services
+++ b/services/bin/services
@@ -8,6 +8,8 @@ user=services
hostname=${1-localhost}
port=1337
+options="${options+$options }-o ControlMaster=no"
+
if test -n "${services_identity_file-}"; then
options="${options+$options }-i $services_identity_file"
fi
@@ -21,4 +23,11 @@ if echo $hostname | grep -q :; then
hostname=`echo $hostname | cut -d: -f1`
fi
-ssh $options $user@$hostname -p $port
+exec 3>&1
+{
+ ssh $options $user@$hostname -p $port
+} 2>&1 1>&3 | sed '
+ /^Connection to '$hostname' closed/d
+ /^Shared connection to '$hostname' closed/d
+'
+exec 3>&-
diff --git a/services/etc/conf.d/krebs-services-test-server b/services/etc/conf.d/krebs-services-test-server
new file mode 100644
index 00000000..243054f4
--- /dev/null
+++ b/services/etc/conf.d/krebs-services-test-server
@@ -0,0 +1,3 @@
+authorized_keys_file=/krebs/services/authorized_keys
+services_file=/opt/services/services.txt
+host_key_file=/opt/services/test.key
diff --git a/services/etc/services/bootstrap b/services/etc/services/bootstrap
new file mode 100644
index 00000000..8c848146
--- /dev/null
+++ b/services/etc/services/bootstrap
@@ -0,0 +1,9 @@
+services://destroy
+services://ire
+services://darth_serious:22
+services://pigstarter:22
+services://incept:22
+services://rage:22
+services://devstar:22
+services://heidi:22
+services://geisha:22
diff --git a/services/etc/systemd/system/krebs-services-test-server.service b/services/etc/systemd/system/krebs-services-test-server.service
new file mode 100644
index 00000000..99578cce
--- /dev/null
+++ b/services/etc/systemd/system/krebs-services-test-server.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=services: provider
+After=network.target
+
+[Service]
+EnvironmentFile=/etc/conf.d/krebs-services-test-server
+ExecStart=/krebs/services/test-server.py
+KillMode=process
+User=services
+Group=services
+Restart=no
+
+[Install]
+WantedBy=multi-user.target
diff --git a/services/services.txt b/services/services.txt
index a2b97670..265e6d1c 100644
--- a/services/services.txt
+++ b/services/services.txt
@@ -1,2 +1,7 @@
-# this is a comment
-TODO declare proper services format
+owner:
+type:
+mail:
+expires:
+location:
+services://{{hostname}}:22
+tinc://{{hostname}}
diff --git a/services/test.py b/services/test-server.py
index 06340a54..7838e0af 100644..100755
--- a/services/test.py
+++ b/services/test-server.py
@@ -1,8 +1,9 @@
-#! /usr/bin/env python
+#! /usr/bin/env python2
from os import environ as env
authorized_keys_file = env.get('authorized_keys_file', '/dev/null')
+debug_log = env.get('debug_log', 'false')
services_file = env.get('services_file', '/dev/null')
host_key_file = env.get('host_key_file', '/dev/null')
host_key_pub_file = host_key_file + '.pub'
@@ -22,9 +23,10 @@ from twisted.internet.reactor import listenTCP, run
from twisted.python.components import registerAdapter
from zope.interface import implements
-from twisted.python.log import startLogging
-from sys import stderr
-startLogging(stderr)
+if debug_log == 'true':
+ from twisted.python.log import startLogging
+ from sys import stderr
+ startLogging(stderr)
class MyRealm:
diff --git a/util/README.markdown b/util/README.markdown
new file mode 100644
index 00000000..78b9b81a
--- /dev/null
+++ b/util/README.markdown
@@ -0,0 +1,27 @@
+# various utils
+
+## //util/bin/with
+
+ execute a command with an extended/modified environment
+
+### usage
+
+ with ENV COMMAND
+
+ where `ENV` is the name of the environment and
+ `COMMAND` your to-be-executed command (-line).
+
+### environment
+
+ `env_dir` defines the directory where environment files are searched
+ (default: `$HOME/.env.d`).
+
+### example
+
+ cat > ~/.env.d/frh-ire <<EOF
+ export api_url=...
+ export api_key=...
+ export api_hash=...
+ EOF
+
+ with frh-ire //ext/solus/bin/client info
diff --git a/util/bin/with b/util/bin/with
new file mode 100755
index 00000000..97893faf
--- /dev/null
+++ b/util/bin/with
@@ -0,0 +1,6 @@
+#! /bin/sh
+set -euf
+ENV="${env_dir-$HOME/.env.d}/$1"
+shift
+. "$ENV"
+exec "$@"