From 7eba4293714b9dce86c07ccf2fdaddaa11a4c3c7 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 28 Aug 2015 23:39:37 +0200 Subject: Reaktor: add nix support, packaging --- commands/badcommand | 1 - commands/caps | 13 --------- commands/hello | 2 -- commands/identify | 22 ---------------- commands/licht_resolver | 37 -------------------------- commands/nag | 68 ------------------------------------------------ commands/reload | 2 -- commands/respond | 2 -- commands/rev | 2 -- commands/revip | 1 - commands/say | 2 -- commands/subdomains | 1 - commands/taken | 28 -------------------- commands/tell-on_join | 19 -------------- commands/tell-on_privmsg | 17 ------------ commands/uptime | 8 ------ commands/visit-page | 1 - commands/whatweb | 17 ------------ commands/whois | 4 --- 19 files changed, 247 deletions(-) delete mode 100755 commands/badcommand delete mode 100755 commands/caps delete mode 100755 commands/hello delete mode 100755 commands/identify delete mode 100755 commands/licht_resolver delete mode 100755 commands/nag delete mode 100755 commands/reload delete mode 100755 commands/respond delete mode 100755 commands/rev delete mode 120000 commands/revip delete mode 100755 commands/say delete mode 120000 commands/subdomains delete mode 100755 commands/taken delete mode 100755 commands/tell-on_join delete mode 100755 commands/tell-on_privmsg delete mode 100755 commands/uptime delete mode 120000 commands/visit-page delete mode 100755 commands/whatweb delete mode 100755 commands/whois (limited to 'commands') diff --git a/commands/badcommand b/commands/badcommand deleted file mode 100755 index c59b4d1..0000000 --- a/commands/badcommand +++ /dev/null @@ -1 +0,0 @@ -#? //retard diff --git a/commands/caps b/commands/caps deleted file mode 100755 index ac8cc66..0000000 --- a/commands/caps +++ /dev/null @@ -1,13 +0,0 @@ -#! /usr/bin/env python3 -import imp -import os - -def load_config(filename): - dirname = os.path.dirname(filename) - modname, ext = os.path.splitext(os.path.basename(filename)) - file, pathname, description = imp.find_module(modname, [ dirname ]) - return imp.load_module(modname, file, pathname, description) - -config = load_config(os.environ['config_filename']) -print('Private: '+' '.join(filter(None,[ x.get('capname',None) for x in config.commands]))) -print('Public: '+' '.join(filter(None,[ x.get('capname',None) for x in config.public_commands]))) diff --git a/commands/hello b/commands/hello deleted file mode 100755 index 05ed79b..0000000 --- a/commands/hello +++ /dev/null @@ -1,2 +0,0 @@ -#! /bin/sh -echo "Hello${*+, $*}!" diff --git a/commands/identify b/commands/identify deleted file mode 100755 index c2fb2c5..0000000 --- a/commands/identify +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python -import imp -import os,sys - -def load_config(filename): - dirname = os.path.dirname(filename) - modname, ext = os.path.splitext(os.path.basename(filename)) - file, pathname, description = imp.find_module(modname, [ dirname ]) - return imp.load_module(modname, file, pathname, description) - -config = load_config(os.environ['config_filename']) - -with open(config.admin_file) as f: - for line in f: - nick,secret = line.split() - if sys.argv[1] == secret: - print("identified you as %s!"%nick) - with open(config.auth_file,'a+') as g: - g.write(os.environ['_prefix'] +"\n") - sys.exit(0) - -print("unable to identify you, sorry") diff --git a/commands/licht_resolver b/commands/licht_resolver deleted file mode 100755 index 5bdb651..0000000 --- a/commands/licht_resolver +++ /dev/null @@ -1,37 +0,0 @@ -#! /usr/bin/python -# -*- coding: utf-8 -*- - -map = { - 'shackspace': { - 'device': { - 0: 'Licht0, Zickenzone; Fenster', - 1: 'Licht1, Sofaecke; Fenster', - 2: 'Licht2, Zickenzone; Ghetto', - 3: 'Licht3, Sofaecke; Ghetto', - 4: 'Licht4, Richtung Getränkelager', - 5: 'Licht5, Porschekonsole', - 6: 'Licht6, Tomatenecke', - 7: 'Licht7, Ghetto', - 10: 'Hauptschalter' - }, - 'state': { - 0: 'aus', - 1: 'an', - 2: 'aus in T-10s' - }, - '->': 'ist' - } -} - -from struct import unpack -import json -from os import environ as env - -location = "shackspace" - -map = map[location] -print (env["payload"]+"") -did, sid= unpack('BB', json.loads(env['payload'])) -device,state = map['device'][did], map['state'][sid] -arrow = map['->'] -print ' '.join([device, arrow, state]) diff --git a/commands/nag b/commands/nag deleted file mode 100755 index f214139..0000000 --- a/commands/nag +++ /dev/null @@ -1,68 +0,0 @@ -#! /bin/sh -set -euf -if test -e nag.hosts.ls; then - echo "nag seems to run already... if not, then delete $workdir/nag.*, please" - exit 23 -fi - -trap 'rm -f nag.hosts.ls nag.services.ls nag.patch' EXIT INT QUIT - - -# usage: git_pull_output_filter REPO_NAME -git_pull_output_filter() { - sed -n 's/^ [0-9]\+ file change/'"$1"': &/p' -} - - -if ! test -d nag.hosts; then - git clone "$hosts_repo" nag.hosts -else - (cd nag.hosts && git pull) | git_pull_output_filter hosts -fi - -if ! test -d nag.services; then - git clone "$services_repo" nag.services -else - (cd nag.services && git pull) | git_pull_output_filter services -fi - - -(cd nag.hosts && ls | sort) > nag.hosts.ls -(cd nag.services && ls | sort) > nag.services.ls - -diff -u nag.hosts.ls nag.services.ls > nag.patch || : - -missing_services=$(sed -n '1d;2d;s/^-\(.*\)/\1/p' nag.patch | tr '\n' ' ') -obsolete_services=$(sed -n '1d;2d;s/^+\(.*\)/\1/p' nag.patch | tr '\n' ' ') - -if test "${inspect_services-false}" = true; then - missing_owners=$(set +f; cd nag.services && grep '^owner:$' * | cut -d: -f1) - missing_mailtos=$(set +f; cd nag.services && grep '^mailto:$' * | cut -d: -f1) -fi - -nag_missing_services='missing services' -nag_obsolete_services='obsolete services' -nag_missing_owners='services with missing owner entry' -nag_missing_mailtos='services with missing mailto entry' - -# -# output -# -did_nag=false -for i in \ - missing_services \ - obsolete_services \ - missing_owners \ - missing_mailtos -do - eval "offenders=\${$i-}; nag_msg=\$nag_$i" - if test -n "$offenders"; then - echo $nag_msg: $offenders - did_nag=true - fi -done - -# if asked directly, answer if there is nothing to nag about -if test $did_nag = false -a -n "${_from:-}";then - echo "nothing to nag about" -fi diff --git a/commands/reload b/commands/reload deleted file mode 100755 index bfa1f04..0000000 --- a/commands/reload +++ /dev/null @@ -1,2 +0,0 @@ -#! /bin/sh -exec pkill -U reaktor diff --git a/commands/respond b/commands/respond deleted file mode 100755 index e23dc3e..0000000 --- a/commands/respond +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -printf '%s\n' "${_from}: $*" diff --git a/commands/rev b/commands/rev deleted file mode 100755 index a8681ab..0000000 --- a/commands/rev +++ /dev/null @@ -1,2 +0,0 @@ -#! /bin/sh -git log -1 --format="%h by %an, %ar" diff --git a/commands/revip b/commands/revip deleted file mode 120000 index e2c3b7a..0000000 --- a/commands/revip +++ /dev/null @@ -1 +0,0 @@ -../repos/revip/revip \ No newline at end of file diff --git a/commands/say b/commands/say deleted file mode 100755 index 8b83c05..0000000 --- a/commands/say +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -printf '%s\n' "$*" diff --git a/commands/subdomains b/commands/subdomains deleted file mode 120000 index 0489555..0000000 --- a/commands/subdomains +++ /dev/null @@ -1 +0,0 @@ -../repos/consolidate_dns/index \ No newline at end of file diff --git a/commands/taken b/commands/taken deleted file mode 100755 index b8beba6..0000000 --- a/commands/taken +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -#!/bin/bash - -# domainavailable -# Fast, domain name checker to use from the shell -# Use globs for real fun: -# domainavailable blah{1..3}.{com,net,org,co.uk} -# Inspired by foca / giles: -# http://gilesbowkett.blogspot.com/2009/02/simple-bash-domain-availability.html - -for d in $@; -do -if host "$d" | grep "NXDOMAIN" >&/dev/null; then - w=$(whois "$d") - if ! test "$?" -eq 0 ;then - echo "$d - whois not available" - elif echo "$w" | grep -Ei "(No match|NOT FOUND|Status: free)" >&/dev/null; then - echo "$d available"; - elif echo "$w"| grep -Ei "(Status: invalid)" >&/dev/null ;then - echo "$d invalid" - else - echo "$d taken"; - fi -else - echo "$d taken"; -fi -done -exit 0 diff --git a/commands/tell-on_join b/commands/tell-on_join deleted file mode 100755 index 2dbff41..0000000 --- a/commands/tell-on_join +++ /dev/null @@ -1,19 +0,0 @@ -#! /bin/sh -set -euf - -# require flock from util-linux -if test "${FLOCK-}" != "$state_file"; then - exec env FLOCK="$state_file" flock "$state_file" "$0" "$@" -fi - -to="$_from" - -# print messages -sed -n '/^'"$to"' /{ - s/^\([^ ]\+\) \([^ ]\+\) <\([^>]\+\)> \(.*\)/\1: \4 2-- \2, \3/p -}' "$state_file" - -# delete messages -sed -i '/^'"$to"' /{ - d -}' "$state_file" diff --git a/commands/tell-on_privmsg b/commands/tell-on_privmsg deleted file mode 100755 index 5d0aff4..0000000 --- a/commands/tell-on_privmsg +++ /dev/null @@ -1,17 +0,0 @@ -#! /bin/sh -set -euf - -# require flock from util-linux -if test "${FLOCK-}" != "$state_file"; then - exec env FLOCK="$state_file" flock "$state_file" "$0" "$@" -fi - -from="$_prefix" -to="$1"; shift -msg="$*" -date=$(date) - -# TODO tell now, if already joined -printf '%s %s <%s> %s\n' "$to" "$from" "$date" "$msg" >> "$state_file" - -echo 'Consider it noted.' # that's what lambdabot says... diff --git a/commands/uptime b/commands/uptime deleted file mode 100755 index 7ff6416..0000000 --- a/commands/uptime +++ /dev/null @@ -1,8 +0,0 @@ -#! /bin/sh -# -# //Reactor/commands/uptime - IRC-optimized uptime output -# -uptime | sed ' - s/^\(.*\) up \(.*\) days\?, *\(.*\), *\(.*\) users\?, *load average: \(.*\)$/\1; \2d \3; \4u; \5/;t - s/^\(.*\) up *\(.*\), *\(.*\) users\?, *load average: \(.*\)$/\1; 0d \2; \3u; \4/;t -' diff --git a/commands/visit-page b/commands/visit-page deleted file mode 120000 index 8723336..0000000 --- a/commands/visit-page +++ /dev/null @@ -1 +0,0 @@ -../repos/view-website/runner.sh \ No newline at end of file diff --git a/commands/whatweb b/commands/whatweb deleted file mode 100755 index 36711ef..0000000 --- a/commands/whatweb +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -#wrapper for WhatWeb -set -eu - -# whatweb is in path? -whatweb=whatweb -if ! type -p whatweb >/dev/null 2>&1 ;then - here=$(dirname `readlink -f $0`) - whatweb="$here/../repos/whatweb/whatweb" - if ! test -e "$whatweb" then - echo "!! cannot find usable whatweb installation in path or basedir ($whatweb)" - exit 1 - fi -fi - -[ -z "${1:-}" ] && echo "!! no host given" && exit 1 -exec $whatweb_bin --user-agent="Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0" -a 3 "$1" 2>&1 diff --git a/commands/whois b/commands/whois deleted file mode 100755 index b073389..0000000 --- a/commands/whois +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -(! type whois >/dev/null 2>/dev/null) && echo "whois does not exist" && exit 0 - -whois "${1?usage: $0 domain}" | sed -e '/^$/d' -e '/^%/d' -e '/^Nserver/d' -e 's/^\[.*/---/' -e '/^Changed/d' -e '/^Status/d' -e '/^Type/d' -e '/^PostalCode/d' -e '/^Phone/d' -e '/^Fax/d' -e '/Last update of WHOIS database/Q' -e '/ID:/d' -- cgit v1.2.3