Listing 1. lost.sh #!/bin/sh # A script to help you find your phone. # by Daniel Bartholomew, May 2010 # # This script is licensed under the terms of the # GNU General Public License, version 3 or later. # See for details. # Some variables you need to set: amilost="http://example.net/my-n900-is-lost.txt" # CHANGE THIS! username="username" # the username at your ssh host sshhost="hostname" backupnumber="3215551212" # backup phone that can receive SMS messages # A timestamp variable you can alter if you want to: timestamp=$(/bin/date +%Y-%m-%d-%H.%M.%S-%Z) # With the vars out of the way, we can begin: # The first step is to check for the file on the webserver. # If it exists, we collect data and send it, # if not, we print a message and exit. if wget --output-document=/tmp/${timestamp}.txt \ ${amilost} 2>/dev/null; then # If we're here, the file exists and the phone is lost. # Get the current IP address and send it using the # sendsms.py script: /sbin/ifconfig -a \ | awk '/inet addr/ { print $2 }' \ | awk -F: '{ print $2 }' \ > /tmp/${timestamp}.ip # sendsms.py from: # http://talk.maemo.org/showpost.php?p=558430&postcount=57 /home/user/sendsms.py ${backupnumber} \ "$(/bin/cat /tmp/${timestamp}.ip)" # take a picture with the front-facing camera /usr/bin/gst-launch v4l2src \ device=/dev/video1 \ num-buffers=1 ! \ ffmpegcolorspace ! \ jpegenc ! \ filesink location=/tmp/${timestamp}.jpg # get the location and send it # gps.py from: http://talk.maemo.org/showthread.php?t=47301 /usr/bin/python2.5 /home/user/gps.py 2>&1 > /tmp/${timestamp}.gps /home/user/sendsms.py ${backupnumber} \ "$(/bin/cat /tmp/${timestamp}.gps)" # More things can be done. # See http://wiki.maemo.org/Phone_control for # ideas. Experiment and have fun! # (But don't blame me if you accidentally brick your phone.) # We've gathered the data we want, now copy everything to the sshhost # server # (need to have ssh-keys set up for this to work). /usr/bin/scp -i /home/user/.ssh/id_rsa /tmp/${timestamp}.* \ ${username}@${sshhost}: # What if I want to run more commands than are listed above, # such as making the phone vibrate or having it call me? # The file I downloaded from the server can contain special # commands. If the file is empty, nothing will happen. # This probably is not the most secure thing to do, but if the # phone really has been stolen, this will allow you to pull # data off of it and/or brick the phone on purpose. Be careful! # Only uncomment the following line if you know what you are doing # and are comfortable with the consequences. I am not responsible # if you break your phone. #/bin/sh /tmp/${timestamp}.txt else # if the file on the server doesn't exist the phone is not lost: echo "I am not lost." fi # That's it! We're done. exit 0