From 814f3d48f67901a79b278bc49a9847cbf9e47ff1 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 12 May 2014 16:31:10 +0200 Subject: elchos is now a Reaktor submodule --- Reaktor/elchos/admin.lst | 0 Reaktor/elchos/auth.lst | 0 Reaktor/elchos/commands/ftpget | 58 ++++++++++++++++ Reaktor/elchos/commands/identify | 22 ++++++ Reaktor/elchos/commands/io | 25 +++++++ Reaktor/elchos/commands/ips | 2 + Reaktor/elchos/commands/list_downloads | 8 +++ Reaktor/elchos/commands/onion | 3 + Reaktor/elchos/commands/reboot | 3 + Reaktor/elchos/commands/refresh_shares | 4 ++ Reaktor/elchos/commands/shares | 2 + Reaktor/elchos/commands/update_search | 3 + Reaktor/elchos/config.py | 78 ++++++++++++++++++++++ elchos/INSTALL | 1 + elchos/root-image/krebs/bin/refresh-shares.ship | 2 +- elchos/root-image/krebs/bin/start-ncdc.ship | 7 +- elchos/root-image/krebs/config.sh | 2 + .../root-image/krebs/etc/Reaktor/elchos/admin.lst | 0 .../root-image/krebs/etc/Reaktor/elchos/auth.lst | 0 .../krebs/etc/Reaktor/elchos/commands/ftpget | 58 ---------------- .../krebs/etc/Reaktor/elchos/commands/identify | 22 ------ .../krebs/etc/Reaktor/elchos/commands/io | 25 ------- .../krebs/etc/Reaktor/elchos/commands/ips | 2 - .../etc/Reaktor/elchos/commands/list_downloads | 8 --- .../krebs/etc/Reaktor/elchos/commands/onion | 3 - .../krebs/etc/Reaktor/elchos/commands/reboot | 3 - .../etc/Reaktor/elchos/commands/refresh_shares | 4 -- .../krebs/etc/Reaktor/elchos/commands/shares | 2 - .../etc/Reaktor/elchos/commands/update_search | 3 - .../root-image/krebs/etc/Reaktor/elchos/config.py | 75 --------------------- elchos/root-image/krebs/lib/filehooker | 2 +- elchos/root-image/root/customize_root_image.sh | 9 +-- 32 files changed, 221 insertions(+), 215 deletions(-) create mode 100644 Reaktor/elchos/admin.lst create mode 100644 Reaktor/elchos/auth.lst create mode 100755 Reaktor/elchos/commands/ftpget create mode 100755 Reaktor/elchos/commands/identify create mode 100755 Reaktor/elchos/commands/io create mode 100755 Reaktor/elchos/commands/ips create mode 100755 Reaktor/elchos/commands/list_downloads create mode 100755 Reaktor/elchos/commands/onion create mode 100755 Reaktor/elchos/commands/reboot create mode 100755 Reaktor/elchos/commands/refresh_shares create mode 100755 Reaktor/elchos/commands/shares create mode 100755 Reaktor/elchos/commands/update_search create mode 100644 Reaktor/elchos/config.py create mode 100644 elchos/INSTALL delete mode 100644 elchos/root-image/krebs/etc/Reaktor/elchos/admin.lst delete mode 100644 elchos/root-image/krebs/etc/Reaktor/elchos/auth.lst delete mode 100755 elchos/root-image/krebs/etc/Reaktor/elchos/commands/ftpget delete mode 100755 elchos/root-image/krebs/etc/Reaktor/elchos/commands/identify delete mode 100755 elchos/root-image/krebs/etc/Reaktor/elchos/commands/io delete mode 100755 elchos/root-image/krebs/etc/Reaktor/elchos/commands/ips delete mode 100755 elchos/root-image/krebs/etc/Reaktor/elchos/commands/list_downloads delete mode 100755 elchos/root-image/krebs/etc/Reaktor/elchos/commands/onion delete mode 100755 elchos/root-image/krebs/etc/Reaktor/elchos/commands/reboot delete mode 100755 elchos/root-image/krebs/etc/Reaktor/elchos/commands/refresh_shares delete mode 100755 elchos/root-image/krebs/etc/Reaktor/elchos/commands/shares delete mode 100755 elchos/root-image/krebs/etc/Reaktor/elchos/commands/update_search delete mode 100644 elchos/root-image/krebs/etc/Reaktor/elchos/config.py diff --git a/Reaktor/elchos/admin.lst b/Reaktor/elchos/admin.lst new file mode 100644 index 00000000..e69de29b diff --git a/Reaktor/elchos/auth.lst b/Reaktor/elchos/auth.lst new file mode 100644 index 00000000..e69de29b diff --git a/Reaktor/elchos/commands/ftpget b/Reaktor/elchos/commands/ftpget new file mode 100755 index 00000000..74e76f8e --- /dev/null +++ b/Reaktor/elchos/commands/ftpget @@ -0,0 +1,58 @@ +#!/bin/sh +# usage: $0 [-d] uri sharename[/subdirs] +exec 2>&1 +set -euf +ncdc_user=hooker +usage(){ + cat < 0.8 directory is stored to /media/vag0/firefox_releases + + ftpget -d http://speedtest.qsc.de/10MB.qsc vag0/ + -> 10MB.qsc is stored to /media/vag0/10MB.qsc +EOF +} +if test "${1:--h}" == '-h' -o "${1:-}" == '--help';then + usage + examples + exit 0 +fi +if test ${1:-} == '-d' ;then + is_dir=true + shift +fi + +target="${1:-}" +if !( echo "$target" | egrep -q '^(ftps*://|https*://)' );then + exit 23 +fi + +share=$( printf "%s" "${2?provide share name}" |head -1 | sed 's#\.\./##') +sharepath=/media/${share%%/*} +realshare="/media/$share" +test ! -e "$sharepath" && echo "$sharepath does not exist!" && exit 23 + +sudo -u $ncdc_user /usr/bin/mkdir -p "$realshare" + +if test -z ${is_dir:-};then + cmd="lftpget \"$target\"" +else + cmd="lftp -e \"mirror;exit\" $target" +fi + + if ! sudo -u $ncdc_user /usr/bin/tmux has-session -t dl >/dev/null 2>&1 ;then + sudo -u $ncdc_user /usr/bin/tmux new-session -s dl -d -c "$realshare" "$cmd" + else + sudo -u $ncdc_user /usr/bin/tmux new-window -t dl -c "$realshare" "$cmd" + fi +#sudo -u $ncdc_user /usr/bin/tmux new-window -t dl +#cd "$realshare" ;sudo -u hooker /usr/bin/lftpget "$target" +echo "download started, check with 'list_downloads'" diff --git a/Reaktor/elchos/commands/identify b/Reaktor/elchos/commands/identify new file mode 100755 index 00000000..c2fb2c58 --- /dev/null +++ b/Reaktor/elchos/commands/identify @@ -0,0 +1,22 @@ +#!/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/Reaktor/elchos/commands/io b/Reaktor/elchos/commands/io new file mode 100755 index 00000000..eb04ae9b --- /dev/null +++ b/Reaktor/elchos/commands/io @@ -0,0 +1,25 @@ +#!/usr/bin/zsh +printf '%-10s %-7s %-7s %-7s %-7s\n' IFACE rxkB/s txkB/s rxTotal txTotal +sar -n DEV 1 3 | grep Average: | grep -v IFACE | grep -v ' lo ' | while read line;do + dev=$(echo $line | awk '{print $2}') + rxkb=$(echo $line | awk '{print $5}') + txkb=$(echo $line | awk '{print $6}') + total_bytes_r=$(cat /proc/net/dev | grep ${dev}: | awk '{print $2}') + total_bytes_t=$(cat /proc/net/dev | grep ${dev}: | awk '{print $10}') + + printf '%-10s %-7s %-7s %-7s %-7s\n' $dev $rxkb $txkb $((total_bytes_r / (1024*1024))) $((total_bytes_t / (1024*1024))) +done +printf "%-10s %-7s %-7s\n" "DSK" "rxkB/s" "txkB/s" +sar -p -d 1 3 | grep Average: | grep -v ' DEV ' |while read line; +do + dsk=$(echo $line | awk '{print $2}') + rd_sec=$(echo $line | awk '{print $4}') + wr_sec=$(echo $line | awk '{print $5}') + if echo $dsk | egrep -q '(sd|hd|vd)';then + # TODO for some reason 0.00 can only be interpreted correctly as arithmetic + # expession by zsh + # + # rd is counted in blocks (which is 512 bytes) + printf "%-10s %-7.2f %-7.2f\n" "/dev/$dsk" "$((rd_sec*2))" "$((wr_sec*2))" + fi +done diff --git a/Reaktor/elchos/commands/ips b/Reaktor/elchos/commands/ips new file mode 100755 index 00000000..17c39658 --- /dev/null +++ b/Reaktor/elchos/commands/ips @@ -0,0 +1,2 @@ +#!/bin/sh +ip addr | grep 'inet ' | awk '{print $2}' | grep -v 127.0.0.1 | grep . diff --git a/Reaktor/elchos/commands/list_downloads b/Reaktor/elchos/commands/list_downloads new file mode 100755 index 00000000..f53067d8 --- /dev/null +++ b/Reaktor/elchos/commands/list_downloads @@ -0,0 +1,8 @@ +#!/bin/sh +ncdc_user=hooker +count=$(sudo -u $ncdc_user /usr/bin/tmux list-windows -t dl 2>/dev/null| wc -l) + +test $count -eq 0 && echo "no downloads running" && exit 0 +for i in $(seq 0 $(($count-1)));do + sudo -u $ncdc_user /usr/bin/tmux capture-pane -t dl:$i -p | grep -v '^$' | tail -n 1 +done diff --git a/Reaktor/elchos/commands/onion b/Reaktor/elchos/commands/onion new file mode 100755 index 00000000..1a202991 --- /dev/null +++ b/Reaktor/elchos/commands/onion @@ -0,0 +1,3 @@ +#!/bin/sh + +sudo -u tor /krebs/bin/tor-get-hidden-service.sh || echo "no hidden service configured" diff --git a/Reaktor/elchos/commands/reboot b/Reaktor/elchos/commands/reboot new file mode 100755 index 00000000..a264831a --- /dev/null +++ b/Reaktor/elchos/commands/reboot @@ -0,0 +1,3 @@ +#!/bin/sh +echo "system is going down" +sudo /usr/bin/reboot diff --git a/Reaktor/elchos/commands/refresh_shares b/Reaktor/elchos/commands/refresh_shares new file mode 100755 index 00000000..1005998b --- /dev/null +++ b/Reaktor/elchos/commands/refresh_shares @@ -0,0 +1,4 @@ +#!/bin/sh +ncdc_user=hooker +sudo /krebs/bin/refresh-shares.ship 2>&1 +sudo -u $ncdc_user /krebs/bin/update-search.sh 2>&1 diff --git a/Reaktor/elchos/commands/shares b/Reaktor/elchos/commands/shares new file mode 100755 index 00000000..1601d584 --- /dev/null +++ b/Reaktor/elchos/commands/shares @@ -0,0 +1,2 @@ +#!/bin/sh +df -h | grep '/media/' diff --git a/Reaktor/elchos/commands/update_search b/Reaktor/elchos/commands/update_search new file mode 100755 index 00000000..1db1c1b2 --- /dev/null +++ b/Reaktor/elchos/commands/update_search @@ -0,0 +1,3 @@ +#!/bin/sh +ncdc_user=hooker +sudo -u $ncdc_user /krebs/bin/update-search.sh diff --git a/Reaktor/elchos/config.py b/Reaktor/elchos/config.py new file mode 100644 index 00000000..eeeacd83 --- /dev/null +++ b/Reaktor/elchos/config.py @@ -0,0 +1,78 @@ +import socket +name = socket.gethostname() +cfg_file = "/krebs/config.sh" + +# TODO: shell config file cannot contain variables or anything fancy +ret ={} + +import shlex +## load config file, lex split every line, split at = +with open(cfg_file) as f: + for line in f: + k,v = shlex.split(line)[0].split("=",1) + ret[k] = v + +#irc_server = 'irc.freenode.net' +irc_server = ret["IRC_SERVER"] + +debug = False + +state_dir='/krebs/painload/Reaktor' +irc_alarm_timeout = 300 +irc_hammer_interval = 10 +irc_kill_timeout = 360 +irc_nickname = name +irc_restart_timeout = 5 +irc_port = 6667 +irc_channels = [ + '#elchOS' +] + +admin_file='admin.lst' +auth_file='auth.lst' + +def default_command(cmd): + return { + 'capname': cmd, + 'pattern': '^(?:' + name + '|\\*):\\s*' + cmd + '\\s*(?:\\s+(?P.*))?$', + 'argv': [ 'commands/' + cmd ] } + +def elch_command(cmd): + return { + 'capname': cmd, + 'pattern': '^(?:' + name + '|\\*):\\s*' + cmd + '\\s*(?:\\s+(?P.*))?$', + 'argv': [ 'elchos/commands/' + cmd ] } + +public_commands = [ + default_command('caps'), + default_command('hello'), + default_command('uptime'), + default_command('badcommand'), + default_command('rev'), + elch_command('search'), + elch_command('list_downloads'), + elch_command('io'), + elch_command('ips'), + elch_command('shares'), + elch_command('onion'), + default_command('nocommand'), + # command not found + { 'pattern': '^(?:' + name + '|\\*):.*', + 'argv': [ 'commands/respond','You are made of stupid!'] }, + # "highlight" + { 'pattern': '.*\\b' + name + '\\b.*', + 'argv': [ 'commands/say', 'I\'m famous' ] }, + # identify via direct connect + { 'capname': 'identify', + 'pattern': 'identify' + '\\s*(?:\\s+(?P.*))?$', + 'argv' : [ 'commands/identify' ]} + +] + +commands = [ + default_command('reload'), + elch_command('update_search'), + elch_command('refresh_shares'), + elch_command('ftpget'), + elch_command('reboot') +] diff --git a/elchos/INSTALL b/elchos/INSTALL new file mode 100644 index 00000000..54eb35a5 --- /dev/null +++ b/elchos/INSTALL @@ -0,0 +1 @@ +pacman -S extra/archiso diff --git a/elchos/root-image/krebs/bin/refresh-shares.ship b/elchos/root-image/krebs/bin/refresh-shares.ship index 364d7758..46d15f46 100755 --- a/elchos/root-image/krebs/bin/refresh-shares.ship +++ b/elchos/root-image/krebs/bin/refresh-shares.ship @@ -4,7 +4,7 @@ set -euf #@include filehooker . /krebs/lib/filehooker -ncdc_user="hooker" +ncdc_user="elch" share_all_partitions systemctl restart hddtemp.service diff --git a/elchos/root-image/krebs/bin/start-ncdc.ship b/elchos/root-image/krebs/bin/start-ncdc.ship index 1d47bcfb..37d7cf45 100755 --- a/elchos/root-image/krebs/bin/start-ncdc.ship +++ b/elchos/root-image/krebs/bin/start-ncdc.ship @@ -3,7 +3,10 @@ set -euf #@include filehooker . /krebs/lib/filehooker #@include network -ncdc_user="hooker" + +# load elch-config +. /krebs/config.sh +ncdc_user="elch" useradd -m $ncdc_user ||: @@ -13,7 +16,7 @@ nick=$(cat /etc/hostname) echo "using nick $nick" ncdc_configure_nick "$nick" sleep 1 -dc_hub="adcs://elchhub.nsupdate.info:2781" +dc_hub="$DC_HUB" echo "connecting to $dc_hub" ncdc_configure_hub "$dc_hub" "elch" diff --git a/elchos/root-image/krebs/config.sh b/elchos/root-image/krebs/config.sh index a2b4d202..33bdaa2b 100644 --- a/elchos/root-image/krebs/config.sh +++ b/elchos/root-image/krebs/config.sh @@ -1 +1,3 @@ IRC_SERVER=irc.freenode.net +STATS_SERVER=elchstats.nsupdate.info +DC_HUB="adcs://elchhub.nsupdate.info:2781" diff --git a/elchos/root-image/krebs/etc/Reaktor/elchos/admin.lst b/elchos/root-image/krebs/etc/Reaktor/elchos/admin.lst deleted file mode 100644 index e69de29b..00000000 diff --git a/elchos/root-image/krebs/etc/Reaktor/elchos/auth.lst b/elchos/root-image/krebs/etc/Reaktor/elchos/auth.lst deleted file mode 100644 index e69de29b..00000000 diff --git a/elchos/root-image/krebs/etc/Reaktor/elchos/commands/ftpget b/elchos/root-image/krebs/etc/Reaktor/elchos/commands/ftpget deleted file mode 100755 index 74e76f8e..00000000 --- a/elchos/root-image/krebs/etc/Reaktor/elchos/commands/ftpget +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -# usage: $0 [-d] uri sharename[/subdirs] -exec 2>&1 -set -euf -ncdc_user=hooker -usage(){ - cat < 0.8 directory is stored to /media/vag0/firefox_releases - - ftpget -d http://speedtest.qsc.de/10MB.qsc vag0/ - -> 10MB.qsc is stored to /media/vag0/10MB.qsc -EOF -} -if test "${1:--h}" == '-h' -o "${1:-}" == '--help';then - usage - examples - exit 0 -fi -if test ${1:-} == '-d' ;then - is_dir=true - shift -fi - -target="${1:-}" -if !( echo "$target" | egrep -q '^(ftps*://|https*://)' );then - exit 23 -fi - -share=$( printf "%s" "${2?provide share name}" |head -1 | sed 's#\.\./##') -sharepath=/media/${share%%/*} -realshare="/media/$share" -test ! -e "$sharepath" && echo "$sharepath does not exist!" && exit 23 - -sudo -u $ncdc_user /usr/bin/mkdir -p "$realshare" - -if test -z ${is_dir:-};then - cmd="lftpget \"$target\"" -else - cmd="lftp -e \"mirror;exit\" $target" -fi - - if ! sudo -u $ncdc_user /usr/bin/tmux has-session -t dl >/dev/null 2>&1 ;then - sudo -u $ncdc_user /usr/bin/tmux new-session -s dl -d -c "$realshare" "$cmd" - else - sudo -u $ncdc_user /usr/bin/tmux new-window -t dl -c "$realshare" "$cmd" - fi -#sudo -u $ncdc_user /usr/bin/tmux new-window -t dl -#cd "$realshare" ;sudo -u hooker /usr/bin/lftpget "$target" -echo "download started, check with 'list_downloads'" diff --git a/elchos/root-image/krebs/etc/Reaktor/elchos/commands/identify b/elchos/root-image/krebs/etc/Reaktor/elchos/commands/identify deleted file mode 100755 index c2fb2c58..00000000 --- a/elchos/root-image/krebs/etc/Reaktor/elchos/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/elchos/root-image/krebs/etc/Reaktor/elchos/commands/io b/elchos/root-image/krebs/etc/Reaktor/elchos/commands/io deleted file mode 100755 index eb04ae9b..00000000 --- a/elchos/root-image/krebs/etc/Reaktor/elchos/commands/io +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/zsh -printf '%-10s %-7s %-7s %-7s %-7s\n' IFACE rxkB/s txkB/s rxTotal txTotal -sar -n DEV 1 3 | grep Average: | grep -v IFACE | grep -v ' lo ' | while read line;do - dev=$(echo $line | awk '{print $2}') - rxkb=$(echo $line | awk '{print $5}') - txkb=$(echo $line | awk '{print $6}') - total_bytes_r=$(cat /proc/net/dev | grep ${dev}: | awk '{print $2}') - total_bytes_t=$(cat /proc/net/dev | grep ${dev}: | awk '{print $10}') - - printf '%-10s %-7s %-7s %-7s %-7s\n' $dev $rxkb $txkb $((total_bytes_r / (1024*1024))) $((total_bytes_t / (1024*1024))) -done -printf "%-10s %-7s %-7s\n" "DSK" "rxkB/s" "txkB/s" -sar -p -d 1 3 | grep Average: | grep -v ' DEV ' |while read line; -do - dsk=$(echo $line | awk '{print $2}') - rd_sec=$(echo $line | awk '{print $4}') - wr_sec=$(echo $line | awk '{print $5}') - if echo $dsk | egrep -q '(sd|hd|vd)';then - # TODO for some reason 0.00 can only be interpreted correctly as arithmetic - # expession by zsh - # - # rd is counted in blocks (which is 512 bytes) - printf "%-10s %-7.2f %-7.2f\n" "/dev/$dsk" "$((rd_sec*2))" "$((wr_sec*2))" - fi -done diff --git a/elchos/root-image/krebs/etc/Reaktor/elchos/commands/ips b/elchos/root-image/krebs/etc/Reaktor/elchos/commands/ips deleted file mode 100755 index 17c39658..00000000 --- a/elchos/root-image/krebs/etc/Reaktor/elchos/commands/ips +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -ip addr | grep 'inet ' | awk '{print $2}' | grep -v 127.0.0.1 | grep . diff --git a/elchos/root-image/krebs/etc/Reaktor/elchos/commands/list_downloads b/elchos/root-image/krebs/etc/Reaktor/elchos/commands/list_downloads deleted file mode 100755 index f53067d8..00000000 --- a/elchos/root-image/krebs/etc/Reaktor/elchos/commands/list_downloads +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -ncdc_user=hooker -count=$(sudo -u $ncdc_user /usr/bin/tmux list-windows -t dl 2>/dev/null| wc -l) - -test $count -eq 0 && echo "no downloads running" && exit 0 -for i in $(seq 0 $(($count-1)));do - sudo -u $ncdc_user /usr/bin/tmux capture-pane -t dl:$i -p | grep -v '^$' | tail -n 1 -done diff --git a/elchos/root-image/krebs/etc/Reaktor/elchos/commands/onion b/elchos/root-image/krebs/etc/Reaktor/elchos/commands/onion deleted file mode 100755 index 1a202991..00000000 --- a/elchos/root-image/krebs/etc/Reaktor/elchos/commands/onion +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -sudo -u tor /krebs/bin/tor-get-hidden-service.sh || echo "no hidden service configured" diff --git a/elchos/root-image/krebs/etc/Reaktor/elchos/commands/reboot b/elchos/root-image/krebs/etc/Reaktor/elchos/commands/reboot deleted file mode 100755 index a264831a..00000000 --- a/elchos/root-image/krebs/etc/Reaktor/elchos/commands/reboot +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -echo "system is going down" -sudo /usr/bin/reboot diff --git a/elchos/root-image/krebs/etc/Reaktor/elchos/commands/refresh_shares b/elchos/root-image/krebs/etc/Reaktor/elchos/commands/refresh_shares deleted file mode 100755 index 1005998b..00000000 --- a/elchos/root-image/krebs/etc/Reaktor/elchos/commands/refresh_shares +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -ncdc_user=hooker -sudo /krebs/bin/refresh-shares.ship 2>&1 -sudo -u $ncdc_user /krebs/bin/update-search.sh 2>&1 diff --git a/elchos/root-image/krebs/etc/Reaktor/elchos/commands/shares b/elchos/root-image/krebs/etc/Reaktor/elchos/commands/shares deleted file mode 100755 index 1601d584..00000000 --- a/elchos/root-image/krebs/etc/Reaktor/elchos/commands/shares +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -df -h | grep '/media/' diff --git a/elchos/root-image/krebs/etc/Reaktor/elchos/commands/update_search b/elchos/root-image/krebs/etc/Reaktor/elchos/commands/update_search deleted file mode 100755 index 1db1c1b2..00000000 --- a/elchos/root-image/krebs/etc/Reaktor/elchos/commands/update_search +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -ncdc_user=hooker -sudo -u $ncdc_user /krebs/bin/update-search.sh diff --git a/elchos/root-image/krebs/etc/Reaktor/elchos/config.py b/elchos/root-image/krebs/etc/Reaktor/elchos/config.py deleted file mode 100644 index a850b7ae..00000000 --- a/elchos/root-image/krebs/etc/Reaktor/elchos/config.py +++ /dev/null @@ -1,75 +0,0 @@ -import socket -name = socket.gethostname() -source = "/krebs/config.sh" - -# TODO: shell config file cannot contain variables or anything fancy -ret ={} -with open(cfg_file) as f: - for line in f: - k,v = line.split("=") - ret[k] = v - -#irc_server = 'irc.freenode.net' -irc_server = ret["IRC_SERVER"] - -debug = False - -state_dir='/krebs/painload/Reaktor' -irc_alarm_timeout = 300 -irc_hammer_interval = 10 -irc_kill_timeout = 360 -irc_nickname = name -irc_restart_timeout = 5 -irc_port = 6667 -irc_channels = [ - '#elchOS' -] - -admin_file='admin.lst' -auth_file='auth.lst' - -def default_command(cmd): - return { - 'capname': cmd, - 'pattern': '^(?:' + name + '|\\*):\\s*' + cmd + '\\s*(?:\\s+(?P.*))?$', - 'argv': [ 'commands/' + cmd ] } - -def elch_command(cmd): - return { - 'capname': cmd, - 'pattern': '^(?:' + name + '|\\*):\\s*' + cmd + '\\s*(?:\\s+(?P.*))?$', - 'argv': [ 'elchos/commands/' + cmd ] } - -public_commands = [ - default_command('caps'), - default_command('hello'), - default_command('uptime'), - default_command('badcommand'), - default_command('rev'), - elch_command('search'), - elch_command('list_downloads'), - elch_command('io'), - elch_command('ips'), - elch_command('shares'), - elch_command('onion'), - default_command('nocommand'), - # command not found - { 'pattern': '^(?:' + name + '|\\*):.*', - 'argv': [ 'commands/respond','You are made of stupid!'] }, - # "highlight" - { 'pattern': '.*\\b' + name + '\\b.*', - 'argv': [ 'commands/say', 'I\'m famous' ] }, - # identify via direct connect - { 'capname': 'identify', - 'pattern': 'identify' + '\\s*(?:\\s+(?P.*))?$', - 'argv' : [ 'commands/identify' ]} - -] - -commands = [ - default_command('reload'), - elch_command('update_search'), - elch_command('refresh_shares'), - elch_command('ftpget'), - elch_command('reboot') -] diff --git a/elchos/root-image/krebs/lib/filehooker b/elchos/root-image/krebs/lib/filehooker index b3bef435..7589ef8a 100644 --- a/elchos/root-image/krebs/lib/filehooker +++ b/elchos/root-image/krebs/lib/filehooker @@ -2,7 +2,7 @@ . /krebs/lib/core #@include network . /krebs/lib/network -ncdc_user=${ncdc_user:-hooker} +ncdc_user=${ncdc_user:-elch} ncdc_bin=${ncdc_bin:-/usr/bin/ncdc} diff --git a/elchos/root-image/root/customize_root_image.sh b/elchos/root-image/root/customize_root_image.sh index 59166853..3233176c 100755 --- a/elchos/root-image/root/customize_root_image.sh +++ b/elchos/root-image/root/customize_root_image.sh @@ -2,7 +2,7 @@ set -e -u -f reaktor_user=reaktor -ncdc_user=hooker +ncdc_user=elch rootpw=$(dd if=/dev/urandom bs=1 count=100 2>/dev/null |md5sum | awk '{print $1}' | dd bs=1 count=9 2>/dev/null) sed -i 's/#\(en_US\.UTF-8\)/\1/' /etc/locale.gen locale-gen @@ -53,15 +53,12 @@ echo "$reaktor_user ALL=(root) NOPASSWD: /krebs/bin/refresh-shares.ship" >> /etc echo "$reaktor_user ALL=($ncdc_user) NOPASSWD: ALL" >> /etc/sudoers.d/reaktor echo "$reaktor_user ALL=(root) NOPASSWD: /usr/bin/reboot" >> /etc/sudoers.d/reaktor -# add bonus features for elch -cp -a /krebs/etc/Reaktor /krebs/painload - # emergency root passwd -printf "!!!!!!\nthe Root PW is '%s'\n!!!!!!\n" "$rootpw" +printf "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\nthe Root PW is '%s'\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" "$rootpw" (printf "%s\n%s\n" "$rootpw" "$rootpw" ) | passwd cd /krebs/painload/Reaktor/ touch auth.lst admin.lst -chown reaktor:reaktor auth.lst admin.lst +chown $reaktor_user:$reaktor_user auth.lst admin.lst for i in multi-user.target \ pacman-init.service \ choose-mirror.service \ -- cgit v1.2.3