summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitmodules3
-rw-r--r--Reaktor/IRC/ircasy.py10
l---------news/ircasy.py1
-rw-r--r--news/newsbot.py239
-rw-r--r--retiolum/hosts/paste2
-rw-r--r--sites/buildbot.krebsco.de/INSTALLATION.md17
-rw-r--r--sites/gold.krebsco.de/README.md18
-rw-r--r--sites/gold.krebsco.de/etc/nginx/sites-available/gold.krebsco.de12
-rw-r--r--sites/graph.krebsco.de/etc/nginx/sites-available/graph.conf (renamed from sites/graph.krebsco.de/nginx/sites-available/graph.conf)0
-rw-r--r--sites/graph.krebsco.de/etc/nginx/sites-available/graph.krebsco.de.conf (renamed from sites/graph.krebsco.de/nginx/sites-available/graph.krebsco.de.conf)0
-rw-r--r--sites/paste.retiolum/README.md31
m---------sites/paste.retiolum/bump0
-rw-r--r--sites/paste.retiolum/etc/nginx/sites-available/paste.conf14
-rw-r--r--sites/paste.retiolum/etc/supervisor.d/bump.supervisor.conf5
-rw-r--r--sites/tahoe.retiolum/README.md16
-rw-r--r--sites/tahoe.retiolum/conf/tahoe.cfg4
-rw-r--r--sites/tinc.krebsco.de/README.md11
-rw-r--r--sites/tinc.krebsco.de/etc/nginx/sites-available/tinc.krebsco.de.conf10
18 files changed, 388 insertions, 5 deletions
diff --git a/.gitmodules b/.gitmodules
index 3b316b96..b59b012a 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -31,3 +31,6 @@
[submodule "web"]
path = web
url = https://github.com/krebscode/krebscode.github.com
+[submodule "sites/paste.retiolum/bump"]
+ path = sites/paste.retiolum/bump
+ url = git@github.com:makefu/bump.git
diff --git a/Reaktor/IRC/ircasy.py b/Reaktor/IRC/ircasy.py
index ca607f2b..7821305f 100644
--- a/Reaktor/IRC/ircasy.py
+++ b/Reaktor/IRC/ircasy.py
@@ -21,7 +21,7 @@ class asybot(asychat):
def __init__(self, server, port, nickname, channels, realname=False, username=False, hostname=False, hammer_interval=10, alarm_timeout=300, kill_timeout=360, loglevel=logging.ERROR):
asychat.__init__(self)
#logger magic
- self.log = logging.getLogger('asybot')
+ self.log = logging.getLogger('asybot_' + nickname)
hdlr = logging.handlers.SysLogHandler(facility=logging.handlers.SysLogHandler.LOG_DAEMON)
formatter = logging.Formatter( '%(filename)s: %(levelname)s: %(message)s')
hdlr.setFormatter(formatter)
@@ -64,7 +64,10 @@ class asybot(asychat):
self.alarm_timeout = alarm_timeout
self.hammer_interval = hammer_interval
self.kill_timeout = kill_timeout
- signal(SIGALRM, lambda signum, frame: self.alarm_handler())
+ try:
+ signal(SIGALRM, lambda signum, frame: self.alarm_handler())
+ except Exception as e:
+ print('asybot: ' + str(e))
self.reset_alarm()
def reset_alarm(self):
@@ -128,7 +131,8 @@ class asybot(asychat):
self.close()
def reconnect(self):
- self.push('QUIT')
+ if self.connected:
+ self.push('QUIT')
self.close()
self.create_socket(AF_INET, SOCK_STREAM)
self.connect((self.server, self.port))
diff --git a/news/ircasy.py b/news/ircasy.py
new file mode 120000
index 00000000..68231591
--- /dev/null
+++ b/news/ircasy.py
@@ -0,0 +1 @@
+../Reaktor/IRC/ircasy.py \ No newline at end of file
diff --git a/news/newsbot.py b/news/newsbot.py
new file mode 100644
index 00000000..5850e4e9
--- /dev/null
+++ b/news/newsbot.py
@@ -0,0 +1,239 @@
+from ircasy import asybot
+import threading
+from asyncore import loop
+import logging
+import os
+import subprocess
+
+import feedparser
+import math
+import re
+import subprocess
+from datetime import datetime
+from time import sleep
+#testbot = NewsBot('ire', 6667, 'crabman23', ['#retiolum'], loglevel=logging.DEBUG)
+
+
+
+## Newsbot Controller Class
+class NewsBot(asybot):
+ def __init__(self, name, channels=['#test'], server='ire', port=6667, timeout=60, loglevel=logging.ERROR, url_shortener='http://wall'):
+ asybot.__init__(self, server, port, name, channels, loglevel=loglevel)
+ self.to = timeout
+ self.url_shortener = url_shortener
+ self.ctrl_chan = channels[0]
+
+ def send_msg(self, target, msg):
+ for line in msg.split('\n'):
+ self.PRIVMSG(target, line)
+
+ def on_privmsg(self, prefix, command, params, rest):
+ args_array = rest.split()
+ if params[0] == self.nickname:
+ answer = self.read_message(args_array)
+ self.send_msg(prefix.split('!')[0], answer)
+ elif args_array[0].strip(':') == self.nickname:
+ answer = self.read_message(args_array[1:])
+ self.send_msg([params[0]], answer)
+
+ def on_invite(self, prefix, command, params, rest):
+ for chan in rest.split():
+ self.push('JOIN ' + chan)
+
+ def read_message(self, args):
+ try:
+ if args[0] in [x for x in commands.__dict__.keys() if x.find('_')]:
+ func = getattr(commands, args[0])
+ return func(self, args)
+ else:
+ return 'command not found'
+ except Exception as e:
+ return 'mimimi: ' + str(e)
+
+#Commands of NewsBot
+class commands():
+ def add(self, args):
+ if args[1] not in bots and args[1] != self.nickname:
+ try:
+ bot = RssBot(args[2], args[1], [self.ctrl_chan], url_shortener=self.url_shortener)
+ except Exception as e:
+ return 'add_mimi: ' + str(e)
+ sleep
+ bots[args[1]] = bot
+ bot.start_rss()
+ return "bot " + args[1] + " added"
+ else:
+ return args[1] + ' does already exist'
+
+ def delete(self, args):
+ bots[args[1]].stop()
+ del bots[args[1]]
+ return "bot " + args[1] + " deleted"
+
+ def rename(self, args):
+ if args[1] in bots:
+ if args[2] in bots:
+ return args[2] + ' already taken'
+ else:
+ bots[args[1]].connection.nick(args[2])
+ bots[args[1]].name = args[2]
+ bots[args[2]] = bots[args[1]]
+ del bots[args[1]]
+ return 'renamed ' + args[1] + ' in ' + args[2]
+ else:
+ return args[1] + ' does not exist'
+
+ def save(self, args):
+ output_buffer = ''
+ for bot in bots:
+ if bots[bot].loop:
+ output_buffer += bot + '|' + bots[bot].url + '|' + ' '.join(bots[bot].channels) + '\n'
+
+ F = open(feedfile, "w")
+ F.writelines(output_buffer)
+ F.close()
+
+ return "bots saved to " + feedfile
+
+ def caps(self, args):
+ return ' '.join([x for x in commands.__dict__.keys() if x.find('_')])
+
+ def list(self, args):
+ output_buffer = ''
+ for bot in bots:
+ output_buffer += bot + ' url: ' + bots[bot].url + '\n'
+ return output_buffer
+
+ def info(self, args):
+ if args[1] in bots:
+ output_buffer = ''
+ for data in ['title', 'link', 'updated']:
+ if data in bots[args[1]].feed.feed:
+ output_buffer += data + ': ' + bots[args[1]].feed.feed[data] + '\n'
+ output_buffer += 'lastnew: ' + bots[args[1]].lastnew.isoformat() + '\n'
+ output_buffer += 'rssurl: ' + bots[args[1]].url
+ return output_buffer
+ else:
+ return 'bot not found'
+
+ def search(self, args):
+ output = subprocess.check_output(['./GfindFeeds4bot', args[1]]).decode()
+ return output
+
+ def uptime(self, args):
+ output = subprocess.check_output(['uptime']).decode()
+ return output
+
+
+##RssBot Class
+class RssBot(asybot):
+ def __init__(self, rss, name, chans=['#news'], url_shortener="http://localhost", server='ire', port=6667, timeout=60):
+ try:
+ asybot.__init__(self, server, port, name, chans)
+ except Exception as e:
+ print(e)
+ self.url = rss
+ self.to = timeout
+ self.oldnews = []
+ self.loop = True
+ self.lastnew = datetime.now()
+ self.url_shortener = url_shortener
+
+ def start_rss(self):
+ self.upd_loop = threading.Thread(target=self.updateloop)
+ self.upd_loop.start()
+
+ def stop(self):
+ self.disconnect()
+ self.loop = False
+
+ def updateloop(self):
+ failcount=0
+ while True:
+ try:
+ self.feed = feedparser.parse(self.url)
+ for entry in self.feed.entries:
+ self.oldnews.append(entry.link)
+ break
+ except:
+ print(self.nickname + ': rss timeout occured')
+ failcount+=1
+ if failcount>20:
+ print(self.nickname + ' is broken, going to die')
+ self.stop()
+ return
+ while self.loop:
+ try:
+ self.feed = feedparser.parse(self.url)
+ for entry in self.feed.entries:
+ if not entry.link in self.oldnews:
+ #try:
+ # self.send_msg(entry.title + " " + entry.link + " com: " + entry.comments)
+ #except AttributeError:
+ shorturl = self.shortenurl(entry.link)
+ self.sendall(entry.title + ' ' + shorturl)
+ self.oldnews.append(entry.link)
+ self.lastnew = datetime.now()
+ except:
+ print(self.nickname + ': rss timeout occured')
+ sleep(self.to)
+
+ def shortenurl(self, url):
+ while True:
+ try:
+ shorturl = subprocess.check_output(["curl", "-sS", "-F", "uri=" + url, self.url_shortener]).decode().strip('\n').strip('\r') + '#' + url.partition('://')[2].partition('/')[0]
+ return shorturl
+ except:
+ print('url shortener error')
+ sleep(1)
+
+ def last(self, target, num):
+ for feed in [x for x in self.feed.entries][:num]:
+ self.send_msg(target, feed.title + ' ' + self.shortenurl(feed.link))
+
+ def sendall(self, string):
+ self.send_msg(self.channels, string)
+
+ def send_msg(self, target, string):
+ if self.connected:
+ for line in string.split('\n'):
+ if len(line) < 450:
+ self.PRIVMSG(target, line)
+ else:
+ space = 0
+ for x in range(math.ceil(len(line)/400)):
+ oldspace = space
+ space = line.find(" ", (x+1)*400, (x+1)*400+50)
+ self.PRIVMSG(target, line[oldspace:space])
+ else:
+ self.reconnect()
+ while not self.connected:
+ sleep(3)
+ print('waiting for reconnect')
+ self.send_msg(string)
+
+ def on_invite(self, prefix, command, params, rest):
+ for chan in rest.split():
+ self.push('JOIN ' + chan)
+
+feedfile = 'new_feeds'
+url_shortener = 'http://wall'
+init_channels = ['#news']
+
+bots = {}
+knews = NewsBot('knews')
+
+#config file reading
+F = open(feedfile, "r")
+lines = F.readlines()
+F.close()
+
+for line in lines:
+ line = line.strip('\n')
+ linear = line.split('|')
+ bot = RssBot(linear[1], linear[0], init_channels + linear[2].split(), url_shortener=url_shortener)
+ bot.start_rss()
+ bots[linear[0]] = bot
+
+th = threading.Thread(target=loop)
+th.start()
diff --git a/retiolum/hosts/paste b/retiolum/hosts/paste
index b1c08801..99ee7d15 100644
--- a/retiolum/hosts/paste
+++ b/retiolum/hosts/paste
@@ -1,5 +1,3 @@
-Address = 192.40.56.122
-#Address = pigstarter.de
Subnet = 10.243.0.153
Subnet = 42:9143:b4c0:f981:6030:7aa2:8bc5:4110/128
-----BEGIN RSA PUBLIC KEY-----
diff --git a/sites/buildbot.krebsco.de/INSTALLATION.md b/sites/buildbot.krebsco.de/INSTALLATION.md
new file mode 100644
index 00000000..b31a3989
--- /dev/null
+++ b/sites/buildbot.krebsco.de/INSTALLATION.md
@@ -0,0 +1,17 @@
+#?/bin/sh
+# something like this
+
+useradd ci
+punani install python-virtualenv
+su ci
+virtualenv buildbot
+echo ". $HOME/buildbot/bin/activate" >~/.bashrc
+pip install buildbot-slave buildbot
+buildbot create-master master
+# tahoe cp krebs:master.conf master/master.conf
+buildbot reconf master
+# or reconfigure as many slaves as you wish
+buildslave create-slave slave localhost "ubuntu1204-local-slave" <PWD>
+buildbot start master
+buildslave start slave
+# now make sure that docker is up and working
diff --git a/sites/gold.krebsco.de/README.md b/sites/gold.krebsco.de/README.md
new file mode 100644
index 00000000..6839631a
--- /dev/null
+++ b/sites/gold.krebsco.de/README.md
@@ -0,0 +1,18 @@
+# gold
+gold.krebsco.de is a simple file share which provides plugins for
+firefox/chromium to rewrite referers.
+
+# Installation:
+copy the nginx config at etc/nginx/sites-available, edit before use
+
+# Plugins
+All krebsgold plugins are stored in /krebs/gold/affiliate/
+For installation follow the instruction at /krebs/gold/affiliate/README.md
+
+## Chromium
+uses userscripts, a modified version of the fsf amazon userscript
+
+## Affiliatefox
+Affiliatefox is a dodgy plugin by some weird german dudes at
+http://www.the-angelz.net . it may be removed in the future as the chromium
+userscript also works for firefox+greasemonkey
diff --git a/sites/gold.krebsco.de/etc/nginx/sites-available/gold.krebsco.de b/sites/gold.krebsco.de/etc/nginx/sites-available/gold.krebsco.de
new file mode 100644
index 00000000..1c565bbd
--- /dev/null
+++ b/sites/gold.krebsco.de/etc/nginx/sites-available/gold.krebsco.de
@@ -0,0 +1,12 @@
+server {
+ listen <external-ip>:80;
+ server_name gold.krebsco.de;
+ access_log /var/log/nginx/log/gold.krebsco.log main;
+ default_type text/plain;
+ autoindex on;
+ location / {
+ # path to //gold/affiliate/ ,may be a symlink or something
+ root /var/www/gold.krebsco.de;
+ }
+}
+
diff --git a/sites/graph.krebsco.de/nginx/sites-available/graph.conf b/sites/graph.krebsco.de/etc/nginx/sites-available/graph.conf
index 1b74f53a..1b74f53a 100644
--- a/sites/graph.krebsco.de/nginx/sites-available/graph.conf
+++ b/sites/graph.krebsco.de/etc/nginx/sites-available/graph.conf
diff --git a/sites/graph.krebsco.de/nginx/sites-available/graph.krebsco.de.conf b/sites/graph.krebsco.de/etc/nginx/sites-available/graph.krebsco.de.conf
index 0619908e..0619908e 100644
--- a/sites/graph.krebsco.de/nginx/sites-available/graph.krebsco.de.conf
+++ b/sites/graph.krebsco.de/etc/nginx/sites-available/graph.krebsco.de.conf
diff --git a/sites/paste.retiolum/README.md b/sites/paste.retiolum/README.md
new file mode 100644
index 00000000..3c634f95
--- /dev/null
+++ b/sites/paste.retiolum/README.md
@@ -0,0 +1,31 @@
+# paste.retiolum
+
+paste is a minimalistic pastebin with sprunge.us in mind.
+This paste may be a supplement to all the 'open' pastebins as the punching
+lemma applies to this installation.
+The installation always runs on a higher port (4000), to get a really short
+hostname, the host which provides this service should have a short name as well
+and have an nginx or apache which translates all request to hostname:80 to
+localhost:4000. see Nginx Configuration.
+
+# Sources
+
+- https://github.com/makefu/bump
+
+# Installation
+
+## Environment
+
+ git clone https://github.com/makefu/bump
+ useradd -a bump -m -d /opt/bump
+ cd /opt/paste
+ virtualenv .
+ pip install -r deps.txt
+
+## Nginx
+
+see etc/nginx/
+
+## Supervisor
+
+see etc/supervisor.d/
diff --git a/sites/paste.retiolum/bump b/sites/paste.retiolum/bump
new file mode 160000
+Subproject 119d2723b510be392ca03d5bca7e1573e533f84
diff --git a/sites/paste.retiolum/etc/nginx/sites-available/paste.conf b/sites/paste.retiolum/etc/nginx/sites-available/paste.conf
new file mode 100644
index 00000000..b83abf95
--- /dev/null
+++ b/sites/paste.retiolum/etc/nginx/sites-available/paste.conf
@@ -0,0 +1,14 @@
+server {
+ listen <internal-ip>:80;
+ server_name paste paste.retiolum;
+ access_log /var/log/nginx/log/paste.log main;
+ error_log /var/log/nginx/log/paste_error.log;
+ default_type text/plain;
+ location / {
+ proxy_pass http://127.0.0.1:4000/;
+ proxy_redirect off;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ }
+}
diff --git a/sites/paste.retiolum/etc/supervisor.d/bump.supervisor.conf b/sites/paste.retiolum/etc/supervisor.d/bump.supervisor.conf
new file mode 100644
index 00000000..6b83d5f2
--- /dev/null
+++ b/sites/paste.retiolum/etc/supervisor.d/bump.supervisor.conf
@@ -0,0 +1,5 @@
+[program:bump]
+command=sh run.sh
+user=bump
+directory=/opt/bump
+autorestart=true
diff --git a/sites/tahoe.retiolum/README.md b/sites/tahoe.retiolum/README.md
new file mode 100644
index 00000000..01e8ed03
--- /dev/null
+++ b/sites/tahoe.retiolum/README.md
@@ -0,0 +1,16 @@
+# Tahoe in Retiolum
+For all the secret stuff, krebsco is using a tahoe installation with 1
+introducer and a number of tahoe bricks.
+
+# Adding new bricks & clients
+see //cholerab/tahoe/{brick,client}\_installation
+
+# Replacing the introducer
+if the introducer may die off, all crypto material is saved in
+krebs:tahoe/introducer. There will be a backup somewhere, but bootstrapping
+always sucks.
+
+Follow the generic brick installation,
+use the configuration file at conf/tahoe.cfg and copy the crypto material in
+the private folder of the installation.
+autostart that shit
diff --git a/sites/tahoe.retiolum/conf/tahoe.cfg b/sites/tahoe.retiolum/conf/tahoe.cfg
new file mode 100644
index 00000000..f70a94da
--- /dev/null
+++ b/sites/tahoe.retiolum/conf/tahoe.cfg
@@ -0,0 +1,4 @@
+[node]
+nickname = intro
+web.port =
+web.static = public_html
diff --git a/sites/tinc.krebsco.de/README.md b/sites/tinc.krebsco.de/README.md
new file mode 100644
index 00000000..3d3d2faa
--- /dev/null
+++ b/sites/tinc.krebsco.de/README.md
@@ -0,0 +1,11 @@
+# tinc.krebsco.de
+tinc.krebsco.de is a curl | sh tinc bootstrapper. For more information see
+//retiolum/scripts/tinc_setup/README.
+
+The nginx is pointed to the folder //boot in painload.
+
+In order to avoid adding an addition file name a special nginx configuration
+based on the try_files directive.
+
+# Installation
+See etc/nginx/sites-available/tinc.krebsco.de.conf
diff --git a/sites/tinc.krebsco.de/etc/nginx/sites-available/tinc.krebsco.de.conf b/sites/tinc.krebsco.de/etc/nginx/sites-available/tinc.krebsco.de.conf
new file mode 100644
index 00000000..15749985
--- /dev/null
+++ b/sites/tinc.krebsco.de/etc/nginx/sites-available/tinc.krebsco.de.conf
@@ -0,0 +1,10 @@
+server {
+ listen <external-ip>:80;
+ server_name tinc.krebsco.de;
+ access_log /var/log/nginx/log/boot.krebsco.log main;
+ default_type text/plain;
+ # this path should be //boot
+ root /var/www/boot.krebsco.de;
+ try_files $uri $uri/retiolum.sh ;
+}
+