Share Internet connection between two Linux machines using RS-232 serial port null modem cable

This is a method for sharing Internet connection between two Linux powered machines using RS-232 serial port null modem cable and Point-to-Point Protocol daemon (PPPD).

Command on the host box:

pppd -detach debug dump crtscts lock proxyarp 192.168.1.201:192.168.1.200 /dev/ttyS0 38400

You need also to enable ip_forwarding:

echo 1 > /proc/sys/net/ipv4/ip_forward

Command on the client box:

pppd -detach debug dump crtscts lock defaultroute 192.168.1.200:192.168.1.201 /dev/ttyS0 38400

The described solution assumes that your /etc/ppp/options file is empty or absent as all the options are given in the command line. The pppd will terminate every time the client disconnects. If you don’t want to start it manually every time, you can use this script:

#!/bin/sh
until pppd -detach debug dump crtscts lock noauth proxyarp 192.168.1.201:192.168.1.200 /dev/ttyS0 38400; do
    echo "Respawning.." >&2
    sleep 1
done

It will wait until pppd terminates and start it again automatically. You need root permissions for all the above commands.

ST2205u keychain photo-frame as a weather station with random Flickr backgrounds

I’ve made a simple bash script to show the current weather using your hacked ST2205u based keychain photo-frame. The script uses AccuWeather service to check the temperature and downloads a random photo from Flickr for background. Then it gets combined using Imagemagick and the result image is being sent to the picframe. It sleeps for 3 minutes and goes again.

You can easily modify the script to include other info – for example, I’ve added a line showing current date/time to know if it’s still working as when it crashes or stops, the last sent photo remains on the screen.

The script requires: setpic, Curl, Perl, Imagemagick. Tweak DEV=… SETPIC=… and location code first.

This is how it looks like:

#!/bin/bash
#AccuWeather (r) RSS weather tool for conky source: https://bbs.archlinux.org/viewtopic.php?id=37381
#Flickr (r) script source: http://picframe.spritesserver.nl/wiki/index.php/Blipfoto.sh
BASEURL="flickr.com/photos/"
DEV=/dev/sdc
SETPIC=./setpic/setpic
OLDURL=""
while true; do
wget $BASEURL -O index.html 2>/dev/zero
URL=`grep 'span class="photo_container pc_t">' index.html |grep jpg|xargs -n1|grep static|cut -d"'" -f6|xargs -n1 echo $BASEURL/|sed s/\ thu/thu/|head -n1|tail -c63|sed s/_t.jpg/_m.jpg/`
if [ "$OLDURL" != "$URL" ]
then
wget $URL -O - 2>/dev/zero >pict.jpg
convert -gravity Center -resize x128 -resize '128x<' -crop 128x128+0+0 +repage pict.jpg pict.png
fi
rm index.html
`curl -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC=1}\&locCode\="EUR|PL|PL|Cracow" | 
perl -ne 'if (/Currently/) {chomp;/\<title\>Currently: (.*)?\<\/title\>/; print "$1"; }' > ./weather.txt 2>/dev/zero`
TMP=`cat ./weather.txt | grep -o -P '.{0,0}:.{0,4}' | tr -d ["C: "]`
DATE=`date | sed 's/.\{8\}$//'`
convert -pointsize 40 -style Normal -size 100x100 xc:none -gravity center \
-stroke black -strokewidth 2 -annotate 0 "$TMP"°C \
-background none -shadow 100x3+0+0 +repage \
-stroke none -fill white     -annotate 0 "$TMP"°C \
-pointsize 10 -gravity South -stroke black -strokewidth 2 -annotate 0 "$DATE" \
-pointsize 10 -gravity South -stroke none -fill white     -annotate 0 "$DATE" \
pict.png  +swap -gravity center -geometry +0+0 \
-composite  pict.png
rm weather.txt
$SETPIC $DEV pict.png >/dev/zero
sleep 180
done

3… 2… 1… GO!

Lets see what do we have here…


Howdy!

Linux related stuff and more. Yay!

del.icio.us


Follow

Get every new post delivered to your Inbox.