Thursday, April 25, 2013

Clone Raspberry Pi Console to iPad

This post falls in the category of "why do you want to do that"?  Especially since I am sure there is a much easier way of accomplishing the same goal?

In any case, what I wanted to do was to use a tablet as the console display for my RPi allowing me to use the keyboard that is attached to the RPi rather than the iPad touch screen (yes, I know, one way of doing this would be to  buy an external keyboard for the iPad).   This post provides the recipe and below is how I put this to use.

First, install screen (sudo apt-get install screen) and then change some rights to allow read-write access from the clone:

sudo chmod +s /usr/bin/screen
sudo chmod 755 /var/run/screen

I wanted my RPi to boot with this capability enabled so my approach will not be as clean as that described by the above referenced post.   In any case, the first thing that I want to happen is for screen to be loaded on login...AND...for login to be automatic on boot. 


First to automate login on boot:

Modify /etc/inittab per the below:
1:2345:respawn:/sbin/getty --noclear 38400 tty1
 -- to -- 
1:2345:respawn:/sbin/getty --noclear 38400 tty1 --autologin pi 

Now make sure that screen starts when the above pi user logs on from the console (but only once or the console will be trapped in a login loop!).   Do this by adding the following at the bottom of .bashrc:

# Start screen (if not already running)  to allow us to clone the consolepgrep screen > /dev/null
if [ $? -ne 0 ]
then
   screen -S shared-session -c screen.in
fi

I also adjusted the size of the console display to better fit the iPad display by adding the following:

stty rows 55
stty cols 160

The I added a used called piclone.   The commands for doing this can be found elsewhere in this blog.

sudo useradd -m -g users -G audio,lp,video,games -s /bin/bash piclone
sudo passwd pi

Now to clone the console to your iPad (or Android table).   You need an SSH app like ServerAuditor.  Create a connection to the RPi using the piclone user and execute the following commands:

ssh pi@rpi1
screen -x pi/shared-session

...
and Bob is your Uncle.

No comments:

Post a Comment