summaryrefslogtreecommitdiffstats
path: root/Reaktor
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2015-08-28 11:05:44 +0200
committermakefu <github@syntax-fehler.de>2015-08-28 11:05:44 +0200
commitf2dd476172dedcc788332cbceb853cc0615ba6ff (patch)
treee5644b21e1d87a74b09afb436d779272476f5589 /Reaktor
parent31dd24af3e6721d1763b85ace640517024de39f2 (diff)
Reaktor: IRC -> reaktor
Remove Obsolete README, remove obsolete index
Diffstat (limited to 'Reaktor')
-rw-r--r--Reaktor/IRC/README.md49
-rwxr-xr-xReaktor/IRC/index6
-rw-r--r--Reaktor/reaktor/__init__.py0
-rwxr-xr-xReaktor/reaktor/core.py (renamed from Reaktor/IRC/reaktor.py)49
-rw-r--r--Reaktor/reaktor/getconf.py (renamed from Reaktor/IRC/getconf.py)0
-rw-r--r--Reaktor/reaktor/ircasy.py (renamed from Reaktor/IRC/ircasy.py)0
-rw-r--r--Reaktor/reaktor/translate_colors.py (renamed from Reaktor/IRC/translate_colors.py)0
7 files changed, 33 insertions, 71 deletions
diff --git a/Reaktor/IRC/README.md b/Reaktor/IRC/README.md
deleted file mode 100644
index 63a0ebd2..00000000
--- a/Reaktor/IRC/README.md
+++ /dev/null
@@ -1,49 +0,0 @@
-# //Reaktor/IRC
-
-This component implements a remote shell daemon that exposes the
-executable files (which may be symlinks) below
-`//Reaktor/public_commands/` through IRC.
-
-## Security
-
-Access to the IRC server implies full access to all the exposed executable
-files. The daemon is executing the commands without dropping privileges.
-
-## Quickstart
-
- #? /bin/sh
- set -euf
-
- export nick="$LOGNAME|$HOSTNAME"
- export host=irc.freenode.org
- export target='#tincspasm'
-
- exec Reaktor/IRC/index
-
-## Environment variables
-
-The following environment variables are processed by `//Reaktor/IRC`:
-
-### nick
-
-Use a specific nickname.
-
-Optional if the node running `//Reaktor/IRC` is part of Retiolum, in
-which case it defaults to `Name` in `/etc/tinc/retiolum/tinc.conf`.
-
-### host and port
-
-Connect to a specific IRC server.
-
-Optional if the node running `//Reaktor/IRC` is part of Retiolum, in
-which case it defaults to `supernode` and `6667` (well, it always
-defaults to these two, but they only make science in Retiolum^_^).
-
-### target
-
-Join a specific channel.
-
-As always, this does the right thing for properly configured hosts: it
-uses the default `#retiolum`, which is the only really relevant
-channel.^_^
-
diff --git a/Reaktor/IRC/index b/Reaktor/IRC/index
deleted file mode 100755
index af557a89..00000000
--- a/Reaktor/IRC/index
+++ /dev/null
@@ -1,6 +0,0 @@
-#! /bin/sh
-set -xeuf
-
-# cd //Reaktor
-cd $(dirname $(readlink -f $0))/..
-exec IRC/reaktor.py "$@"
diff --git a/Reaktor/reaktor/__init__.py b/Reaktor/reaktor/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Reaktor/reaktor/__init__.py
diff --git a/Reaktor/IRC/reaktor.py b/Reaktor/reaktor/core.py
index 124fa017..15166d9e 100755
--- a/Reaktor/IRC/reaktor.py
+++ b/Reaktor/reaktor/core.py
@@ -1,17 +1,16 @@
#!/usr/bin/env python3
import os
-from ircasy import asybot
+from reaktor.ircasy import asybot
from asyncore import loop
-from translate_colors import translate_colors
+from reaktor.translate_colors import translate_colors
import shlex
from re import split, search, match
default_config = './config.py'
-from getconf import make_getconf
-getconf = None
+from reaktor.getconf import make_getconf
import logging,logging.handlers
-log = logging.getLogger('asybot')
+log = logging.getLogger('Reaktor')
#hdlr = logging.handlers.SysLogHandler(address='/dev/log', facility=logging.handlers.SysLogHandler.LOG_DAEMON)
#formatter = logging.Formatter( '%(filename)s: %(levelname)s: %(message)s')
#hdlr.setFormatter(formatter)
@@ -20,14 +19,27 @@ log = logging.getLogger('asybot')
class Reaktor(asybot):
- def __init__(self,config=default_config):
+ def __init__(self,config=default_config,getconf=None):
self.config = config
+
+ if not getconf:
+ self.getconf = make_getconf(self.conf)
+ else:
+ self.getconf = getconf
log.info("using config file %s"%(config))
- asybot.__init__(self, getconf('irc_server'), getconf('irc_port'), getconf('irc_nickname'), getconf('irc_channels'), hammer_interval=getconf('irc_hammer_interval'), alarm_timeout=getconf('irc_alarm_timeout'), kill_timeout=getconf('irc_kill_timeout'))
+
+ asybot.__init__(self,
+ getconf('irc_server'),
+ getconf('irc_port'),
+ getconf('irc_nickname'),
+ getconf('irc_channels'),
+ hammer_interval=getconf('irc_hammer_interval'),
+ alarm_timeout=getconf('irc_alarm_timeout'),
+ kill_timeout=getconf('irc_kill_timeout'))
def is_admin(self,prefix):
try:
- with open(getconf('auth_file')) as f:
+ with open(self.getconf('auth_file')) as f:
for line in f:
if line.strip() == prefix:
return True
@@ -36,17 +48,17 @@ class Reaktor(asybot):
return False
def on_join(self, prefix, command, params, rest):
- for command in getconf('on_join', []):
+ for command in self.getconf('on_join', []):
self.execute_command(command, None, prefix, params)
def on_ping(self, prefix, command, params, rest):
- for command in getconf('on_ping', []):
+ for command in self.getconf('on_ping', []):
prefix = '!' # => env = { _prefix: '!', _from: '' }
params = command.get('targets') # TODO why don't we get a list here and use ','.join() ?
self.execute_command(command, None, prefix, params)
def on_privmsg(self, prefix, command, params, rest):
- for command in getconf('commands'):
+ for command in self.getconf('commands'):
y = match(command['pattern'], rest)
if y:
if not self.is_admin(prefix):
@@ -54,7 +66,7 @@ class Reaktor(asybot):
else:
return self.execute_command(command, y, prefix, params)
- for command in getconf('public_commands'):
+ for command in self.getconf('public_commands'):
y = match(command['pattern'], rest)
if y:
return self.execute_command(command, y, prefix, params)
@@ -74,7 +86,7 @@ class Reaktor(asybot):
except:
log.info("cannot parse args!")
- cwd = getconf('workdir')
+ cwd = self.getconf('workdir')
if not os.access(cwd,os.W_OK):
log.error("Workdir '%s' is not Writable! Falling back to root dir"%cwd)
cwd = "/"
@@ -116,10 +128,15 @@ class Reaktor(asybot):
if code != 0:
self.ME(target, 'mimimi')
-if __name__ == "__main__":
+def main():
import sys
conf = sys.argv[1] if len(sys.argv) == 2 else default_config
getconf = make_getconf(conf)
- logging.basicConfig(level = logging.DEBUG if getconf('debug') else logging.INFO)
- Reaktor(conf)
+ logging.basicConfig(level = logging.DEBUG if getconf('debug') else
+ logging.INFO)
+ log.debug("Debug enabled")
+ Reaktor(conf,getconf)
loop()
+
+if __name__ == "__main__":
+ main()
diff --git a/Reaktor/IRC/getconf.py b/Reaktor/reaktor/getconf.py
index 168c908c..168c908c 100644
--- a/Reaktor/IRC/getconf.py
+++ b/Reaktor/reaktor/getconf.py
diff --git a/Reaktor/IRC/ircasy.py b/Reaktor/reaktor/ircasy.py
index 38f202fc..38f202fc 100644
--- a/Reaktor/IRC/ircasy.py
+++ b/Reaktor/reaktor/ircasy.py
diff --git a/Reaktor/IRC/translate_colors.py b/Reaktor/reaktor/translate_colors.py
index bd716618..bd716618 100644
--- a/Reaktor/IRC/translate_colors.py
+++ b/Reaktor/reaktor/translate_colors.py