project:brmdoor:scripts
Differences
This shows you the differences between two versions of the page.
project:brmdoor:scripts [2011/02/02 12:32] – created stick | project: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' | ||
- | |||
- | All scripts are being run from within a screen running on brmlab@sargon. | ||
- | |||
- | ==== USB-Network Interface on Asus ==== | ||
- | |||
- | Lives in ''/ | ||
- | |||
- | Some of the shell I/O is coded awkwardly - this is carefully tuned to reach combination of serial device opens/ | ||
- | |||
- | brmdoor.rc: | ||
- | |||
- | < | ||
- | PORT=/ | ||
- | DELAY=10 | ||
- | |||
- | AUTHSERVER=192.168.1.28 | ||
- | AUTHPORT=2081 | ||
- | |||
- | # stty -F $PORT 38400 parodd -cstopb # not needed | ||
- | </ | ||
- | |||
- | dooropener.sh - unlock door (for given number of seconds) from within the LAN: | ||
- | |||
- | < | ||
- | #!/bin/sh | ||
- | . ./ | ||
- | |||
- | while true; do x=" | ||
- | </ | ||
- | |||
- | dooropen.sh - utility script for opening the door from other Asus scripts: | ||
- | |||
- | < | ||
- | #!/bin/sh | ||
- | . ./ | ||
- | |||
- | #!/bin/sh | ||
- | . ./ | ||
- | |||
- | sleep 1 # give time for the arduino to potentially reset | ||
- | echo opening for $DELAY | ||
- | # echo " | ||
- | echo $DELAY >$PORT | ||
- | </ | ||
- | |||
- | 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: | ||
- | |||
- | < | ||
- | #!/bin/sh | ||
- | . ./ | ||
- | |||
- | while true; do | ||
- | echo wait... | ||
- | read rfid | ||
- | reply=$(echo $rfid | nc $AUTHSERVER $AUTHPORT) | ||
- | echo $rfid $reply | ||
- | if [ " | ||
- | # By the time we send over serial, we MUST be reading | ||
- | # it again already too. Uhh, stupid 2.4 kernel ftdi?! | ||
- | ./ | ||
- | fi | ||
- | done <$PORT | ||
- | </ | ||
- | |||
- | ==== Auth Server ==== | ||
- | |||
- | Simple script running on sargon, checking rfid serials against a user database: brmdoor.pl | ||
- | |||
- | < | ||
- | # | ||
- | |||
- | use IO::Socket; | ||
- | $|=1; | ||
- | |||
- | our %ids; | ||
- | open my $f, " | ||
- | while(< | ||
- | chomp; split/\t/; | ||
- | # print "ID ' | ||
- | $ids{$_[1]} = $_[0]; | ||
- | } | ||
- | close $f; | ||
- | |||
- | # $/ | ||
- | my $sock = new IO:: | ||
- | while (1) { | ||
- | my $s = $sock-> | ||
- | while (< | ||
- | chomp; my $u = $ids{$_}; | ||
- | if ($u) { print $s " | ||
- | else { print $s " | ||
- | } | ||
- | } | ||
- | </ | ||
- | |||
- | I'm sorry for the mess, it was quick 10-minute hack. Feel free to rewrite it. :-) | ||
- | |||
- | brmdoor.users: | ||
- | |||
- | < | ||
- | username< | ||
- | pasky< | ||
- | </ | ||
- | |||
- | ==== Unlock Door over IRC ==== | ||
- | |||
- | If nick '' | ||
- | |||
- | .irssi/ | ||
- | |||
- | < | ||
- | use strict; | ||
- | use warnings; | ||
- | |||
- | use Irssi; | ||
- | use Irssi::Irc; | ||
- | |||
- | use vars qw($VERSION %IRSSI); | ||
- | |||
- | $VERSION = ' | ||
- | %IRSSI = ( | ||
- | authors => "Petr Baudis", | ||
- | contact => " | ||
- | name => " | ||
- | description => " | ||
- | ); | ||
- | |||
- | our ($lastt) = 0; | ||
- | |||
- | sub on_private { | ||
- | my ($server, $message, $nick, $hostmask) = @_; | ||
- | my $cp = " | ||
- | |||
- | return unless $message =~ / | ||
- | |||
- | my $delay = 20; | ||
- | system(" | ||
- | $server-> | ||
- | } | ||
- | |||
- | Irssi:: | ||
- | </ |
project/brmdoor/scripts.1296649948.txt.gz · Last modified: 2011/02/02 12:32 by stick