├── .gitignore ├── README.md ├── bin ├── camera ├── people-add ├── people-scan └── slackify ├── init.d └── eponine.sh └── server.go /.gitignore: -------------------------------------------------------------------------------- 1 | /eponine 2 | data/ 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Eponine](https://cloud.githubusercontent.com/assets/2723/13193697/d0f48a56-d731-11e5-854a-d4743254a446.jpg) 2 | 3 | # Eponine 4 | 5 | Eponine is a [very tiny][server] web server in Go that accepts requests and responds with the output of shell scripts. 6 | 7 | This was originally designed to be run on a Raspberry Pi and accessed via Slack, which is why there's a very Pi bent to the scripts. You can run it in other circumstances, though, if that's what you're into. 8 | 9 | Starter scripts include a "who's here?" (a simple scan of MAC addresses on the local network and maps it against a known list of people in the room), and remote photo capture with the Pi's camera module. 10 | 11 | Please note that this is super gnarly right now and will likely change quite a bit in the coming weeks. 12 | 13 | ## Install 14 | 15 | Drop the latest binary to a directory on your machine and start the server with `./eponine`. 16 | 17 | ## Usage 18 | 19 | Eponine can be accessed on port `24601` (haha). 20 | 21 | The path of requests coming in get translated into shell script execution. So, a request coming in on `localhost:24601/people-scan` will execute `./bin/people-scan` on your machine. Needless to say, be careful of what you put in there. 22 | 23 | Eponine will return whatever output the script outputs. If you want special formatting for Slack, for example, do it in the script. 24 | 25 | ## Scripts 26 | 27 | Eponine will run anything in your local `bin` directory. Clone the repo if you want the whole batch, otherwise just add them one-by-one and you'll be good. 28 | 29 | [server]: https://github.com/holman/eponine/blob/master/server.go 30 | [release]: https://github.com/holman/eponine/releases 31 | 32 | ## Contributing 33 | 34 | Things are really raw right now; they'll maybe settle down eventually (or they won't and this will bitrot here forever). 35 | 36 | Slug through the source if you'd like; contributions sorta welcome. 37 | -------------------------------------------------------------------------------- /bin/camera: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Takes a photo. Adds it to an archive. 4 | 5 | mkdir -p data/images 6 | file=$(date +"%Y-%m-%d-%T").jpg 7 | path=data/images/$file 8 | url="http://$(cat data/hostname)" 9 | 10 | raspistill -t 100 -o $path 11 | 12 | output="$url/images/$file" 13 | 14 | echo $(./bin/slackify "$output") 15 | -------------------------------------------------------------------------------- /bin/people-add: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Adds people for `people-scan`. 4 | # 5 | # Usage: 6 | # people-add 7 | 8 | printf '%s\t%s\n' "$1" "$2" >> data/mac-addresses 9 | -------------------------------------------------------------------------------- /bin/people-scan: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Returns a list of people who are at the current location. 4 | # 5 | # This is handled by using `people-add` to add a username and MAC address 6 | # pairing into `data/mac-addresses`. 7 | # 8 | # This depends on `arp-scan`; install with `sudo apt-get install arp-scan`. You 9 | # might want to `sudo chmod u+s /usr/bin/arp-scan` so you don't need to run it 10 | # with sudo. 11 | 12 | present_people=$(arp-scan --localnet | cut -f2 | tail -n +3 | head -n -2) 13 | found_people=() 14 | 15 | while read member; do 16 | mac=$(echo "$member" | cut -f1) 17 | name=$(echo "$member" | cut -f2) 18 | 19 | while read -r present_person; do 20 | if [ "$mac" == "$present_person" ] 21 | then 22 | found_people+=("$name") 23 | fi 24 | done <<< "$present_people" 25 | done