Urban75 Home About Offline BrixtonBuzz Contact

A moron asks: How do I create this script on linux?

kropotkin

libcom
I have a raspberry pi, which is brilliant. It runs raspbmc and does all sorts of things for me as it is permanently connected to my network and runs 24/7 as a torrent server etc.
I recently discovered Bittorrent Sync, which I now have running to sync my photography archive on my laptop to the 2TB external drive on the pi. Unfortunately the pi keeps the external drive from spinning down properly as this btsync program keeps the drive active even if there are no seeds connected to it.

My laptop is rarely on, but when it is I want this process to be run. When the laptop drops off the network I want the process to be stopped.

How do I create a script that does that? I suspect a cron job that runs every 10 minutes or so, checks whether the laptop is visible (don't know how to do this), and then starts the btsync service, stopping it when the laptop stops being online.

Any advice on how to do this would be appreciated! I don't really know where to start
 
When I used rasbmc and btsync I didn't have this issue, the drive would spin down as expected, I haven't used it in a while though so the newer version may do things differently.

If the laptop has a fixed ip you might be able to ping it every so often and if it gets a reply it starts the process running, no reply and it kills it. Not sure how you would code this though, it could be something as simple as outputting the ping response to a text file and depending on how many lines in the file determines if the laptop is there.
 
That bit is easy enough:
Code:
ping -c 1 <laptop ip address>

if [ $? -eq 0 ]; then
	#laptop is up
else
	#laptop is down
fi

Ha re other thread. This is what I need to try again. I got that far but wrapping the code into a couple of functions to achieve 3g failover and back.
 
Thanks everyone- the script works fine. The cronjob isn't running, but that is a different matter and easily fixed.

thanks.
 
Back
Top Bottom