User Tools

Site Tools


project:brmdoor:scripts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

project:brmdoor:scripts [2011/02/02 12:32] – created stickproject:brmdoor:scripts [2018/04/19 16:22] (current) – delete outdate brmdoor scripts page abyssal
Line 1: Line 1:
-===== Brmdoor Scripts ===== 
  
-This is a super-scary collection of hackish pasky's scripts controlling the brmdoor monster. If you change/rewrite them, please keep this page up-to-date. :-) 
- 
-All scripts are being run from within a screen running on brmlab@sargon. 
- 
-==== USB-Network Interface on Asus ==== 
- 
-Lives in ''/jffs/brmdoor/''. Do not forget to manually insmod the correct usbserial, ftdi modules first. 
- 
-Some of the shell I/O is coded awkwardly - this is carefully tuned to reach combination of serial device opens/closes for things to actually work. 
- 
-brmdoor.rc: 
- 
-<code> 
-PORT=/dev/usb/tts/0 
-DELAY=10 
- 
-AUTHSERVER=192.168.1.28 
-AUTHPORT=2081 
- 
-# stty -F $PORT 38400 parodd -cstopb # not needed 
-</code> 
- 
-dooropener.sh - unlock door (for given number of seconds) from within the LAN: 
- 
-<code> 
-#!/bin/sh 
-. ./brmdoor.rc 
- 
-while true; do x="$(nc -l -p 2080)"; echo "$x" >$PORT; echo closed given $x; done 
-</code> 
- 
-dooropen.sh - utility script for opening the door from other Asus scripts: 
- 
-<code> 
-#!/bin/sh 
-. ./brmdoor.rc 
- 
-#!/bin/sh 
-. ./brmdoor.rc 
- 
-sleep 1 # give time for the arduino to potentially reset 
-echo opening for $DELAY 
-# echo "$DELAY" | nc localhost 2080 
-echo $DELAY >$PORT 
-</code> 
- 
-doorrfid.sh - listen for rfid serial numbers coming from Arduino, ask auth server whether they are legit, give command to unlock the door if they are: 
- 
-<code> 
-#!/bin/sh 
-. ./brmdoor.rc 
- 
-while true; do 
-        echo wait... 
-        read rfid 
-        reply=$(echo $rfid | nc $AUTHSERVER $AUTHPORT) 
-        echo $rfid $reply 
-        if [ "$reply" = 1 ]; then 
-                # By the time we send over serial, we MUST be reading 
-                # it again already too. Uhh, stupid 2.4 kernel ftdi?! 
-                ./dooropen.sh & 
-        fi 
-done <$PORT 
-</code> 
- 
-==== Auth Server ==== 
- 
-Simple script running on sargon, checking rfid serials against a user database: brmdoor.pl 
- 
-<code> 
-#!/usr/bin/perl 
- 
-use IO::Socket; 
-$|=1; 
- 
-our %ids; 
-open my $f, "brmdoor.users" or die "brmdoor.users: $!"; 
-while(<$f>) { 
-        chomp; split/\t/; 
-        # print "ID '$_[1]' is of $_[0]\n"; 
-        $ids{$_[1]} = $_[0]; 
-} 
-close $f; 
- 
-# $/="\r\n"; 
-my $sock = new IO::Socket::INET(Listen=>1,LocalPort=>2081,Reuse=>1) or die "$!"; 
-while (1) { 
-        my $s = $sock->accept(); 
-        while (<$s>) { 
-                chomp; my $u = $ids{$_}; 
-                if ($u) { print $s "1\n"; print "$u\n"; } 
-                else { print $s "0\n"; print "INVALID: '$_'\n"; } 
-        } 
-} 
-</code> 
- 
-I'm sorry for the mess, it was quick 10-minute hack. Feel free to rewrite it. :-) 
- 
-brmdoor.users: 
- 
-<code> 
-username<tab>serial 
-pasky<tab>0123456789 
-</code> 
- 
-==== Unlock Door over IRC ==== 
- 
-If nick ''brmlab_'' (sic) receives an open command over privmsg, it unlocks the door for few seconds (and reports the action on #brmlab). You can find the command in members-only section of the wiki. 
- 
-.irssi/scripts/brmdoor.pl takes care of it: 
- 
-<code> 
-use strict; 
-use warnings; 
- 
-use Irssi; 
-use Irssi::Irc; 
- 
-use vars qw($VERSION %IRSSI); 
- 
-$VERSION = '0.1'; 
-%IRSSI = ( 
-        authors => "Petr Baudis", 
-        contact => "brmlab\@brmlab.cz", 
-        name => "brmdoor", 
-        description => "brmdoor IRC interface", 
-); 
- 
-our ($lastt) = 0; 
- 
-sub on_private { 
-        my ($server, $message, $nick, $hostmask) = @_; 
-        my $cp = "!"; 
- 
-        return unless $message =~ /^${cp}seememberssectionforthecommand/; 
- 
-        my $delay = 20; 
-        system("echo $delay | nc 192.168.1.1 2080"); 
-        $server->send_message("#brmlab", "$nick asked for brmdoor open - unlocked for ${delay}s mark NOW", 0); 
-} 
- 
-Irssi::signal_add('message private', 'on_private'); 
-</code> 
project/brmdoor/scripts.1296649948.txt.gz · Last modified: 2011/02/02 12:32 by stick