SyntaxHighlighter

Monday 19 August 2013

Day 45: Ssh vs read-only, finished maclog.py, back to AR

The final touches: safe shut down

So there were two possible solutions, either use ssh or make the SD read-only. You can ssh into the Pi via python using Paramiko (http://jessenoller.com/2009/02/05/ssh-programming-with-paramiko-completely-different/) and then call "sudo halt" to shut it down, but instead I chose to go the other way and modify the Raspbian distribution on the Pi, forcing it to mount as read only. I had to make changes to a variety of files, as described here: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=22596

Testing

I tested it in a variety of situations to hopefully ensure my script is robust enough to withstand all manner of unexpected abuse. Added lots of text printing to walk the user through every single step, error catching to deal with annoying issues. Added a keyboardinterrupt catch so that it would catch a Ctrl-C to exit the program, and then closes the log file and manually shuts down properly.

I created master and slave SD card images (with the Unix dd command) as the most foolproof backup I could think of. Each image is just under 500MB

All finished version 1 description:

There is a Master Pi with the script and log file on it. Connect it to a screen and keyboard and run the script. Follow onscreen instructions to work out how to use the script, very self explanatory
Year is passed as command line argument
It looks for log file at startup, and asks to create one if not found.
If it is found it starts the sequence at the correct number for this year.

Any new mac address discovered that is not already in the log file (regardless of year) will be added to the end of the file on a new line, along with its sequence number as such:
b8:27:eb:6a:ca:84,13/0002
(MAC,yy/nnnn)
This will also be printed to the screen so the user can write the sequence on the Pi as required.

If the new mac has already been previously logged (regardless of year) then error message will print existing sequence, and script will continue (waiting for next mac) without relogging.

It takes a pretty long time after a new Pi has been connected for it to be recognized by the script. In all situations meaningful messages walk the user through what is happening.

There is a specially set up SD Card with IP address 192.268.0.2 and which will mount its OS as read-only. This SD card will be put into all of the ‘Pi’s to be labelled’ one by one as they are connected to the Master Pi with a direct ethernet connection.

When connecting new slave Pi, always connect it’s power cable last. For obvious reasons. When disconnecting can do any order (a socket error occurs if you disconnect the network cable before the power cable for some reason, but my awesome script catches that, deals with it safely and continues)

Pi labs

Also read through the bunch of other labs at Grahams request, just to ensure everything is up to scratch. They are all located here: http://studentnet.cs.manchester.ac.uk/ugt/2013/COMP10120/labscripts/

AR

And back to AR! Donald no longer connects to the internet ever since I started messing about with a bridge connection on the Ubuntu VM that I installed - or it could be some other reason I'm not sure. In any case the ethernet connection no longer works and I don't know which drivers will make his wifi card work... it doesn't even have a brand on it! I'd better figure this out or the next event when Toby tries to use Donald in some random location there will be an unpleasant surprise in store as he discovers the WiFi doesn't exist...

Next Monday I believe the Pi's will be passed to Georgiana who will go through the actual labelling process and running the script etc

No comments:

Post a Comment

Note: only a member of this blog may post a comment.