Results 1 to 2 of 2
Discuss [Question] [Solved] Automatically send .torrent files back to server at the Free Toolchain Software (Cydia App's) - Hackint0sh.org; Hi all, I have a jailbroken 2.1 iPhone and am trying to work out how ...
  1. #1
    Newbie Array

    Join Date
    Oct 2008
    Posts
    2
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default [Question] [Solved] Automatically send .torrent files back to server

    Hi all,

    I have a jailbroken 2.1 iPhone and am trying to work out how to have it automatically send .torrent files that I download, home to my server to begin leeching.

    I am currently exploring two possibilities:

    1) (Easiest?) Set up some kind of crontab entry, which checks in my Safari downloads directory every 5 minutes for .torrent files, scp's them home to my server, and then moves them into some kind of "Old Torrents" folder.

    2) Somehow hook in to the iPhone file system, in order to watch for new files in a given directory. When a .torrent file is added, copy home and move as above.

    I have set up similar things on several other machines, and am an experienced unix developer, so I'm not afraid to get my hands dirty, but I have a few questions:

    - Are there any file system watching apps available for iPhone? I've looked and haven't found any, but I haven't checked in all of the repositories.

    - What's the preferred way of scheduling processes on the iPhone? It looks like cron is no longer included with iPhone OS 2, but I've read about two apps, "Launchd" and "Schedule", which sound like the do a similar thing.

    Any help would be much appreciated.

    Jon
    Last edited by bram2000; 10-26-2008 at 11:29 PM. Reason: Solved



  2. #2
    Newbie Array

    Join Date
    Oct 2008
    Posts
    2
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default Solved!

    Solved my own problem! :hack: here is what I came up with.

    1) Install the Safari downloader hack, which allows download of files to /var/mobile/Library/Downloads.

    2) Set up a launchd plist file at /Library/LaunchDaemons/com.automation.torrentmover.plist

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Disabled</key>
        <false/>
        <key>Label</key>
        <string>com.automation.torrentmover</string>
        <key>ProgramArguments</key>
        <array>
            <string>/var/mobile/torrentmover.sh</string>
        </array>
        <key>WatchPaths</key>
        <array>
            <string>/var/mobile/Library/Downloads</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>onDemand</key>
        <true/>
    </dict>
    </plist>
    3) Create the script /var/mobile/torrentmover.sh

    Code:
    #!/bin/bash
    
    /bin/echo "START" >> /var/log/torrentmover
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    LOG=/var/log/torrentmover
    DEST=username@xxx.xxx.xxx.xxx:/TORRENTDROP/iPhone_`date +%Y%m%d_%H:%M:%S`.torrent
    DIR=/var/mobile/Library/Downloads/
    
    FILELIST=`/bin/ls $DIR`
    
    /bin/echo "Change detected in $DIR" >> $LOG
    
    for f in $FILELIST
    do
    	echo "	Checking $DIR/$f" >> $LOG
    	file $DIR/$f | grep -i bittorrent 2>&1 > /dev/null
    	IS_TORRENT=$?
    	SUCCESS=-1
    	if [ $IS_TORRENT -eq 0 ]; then
    		echo "	Torrent file detected" >> $LOG
    		scp $DIR/$f $DEST 2>&1 >> $LOG
    		SUCCESS=$?
    	fi
    	if [ $SUCCESS -eq 0 ]; then
    		echo "	File sent, removing" >> $LOG
    		rm $DIR/$f
    	fi
    done
    
    exit
    Make that script executable with chmod +x. I have this file owned by root, I don't think it worked when owned by mobile.

    4) Install the launchd job:

    Code:
    launchctl load /Library/LaunchDaemons/com.automation.torrentmover.plist

    Now try downloading a .torrent file from mobile Safari, and it should get sent to the destination folder on your server, where you have Transmission or some other torrent client watching the dir for new torrents.

    NB I rename the files to iPhone_<date>.torrent because on some torrent sites I would end up with a file called torrent.php. That's why I use 'file' to determine if a file is BitTorrent.

    Hope this helps someone else, please let me know your thoughts.

    Jon

 

 

Similar Threads

  1. automatically send email/sms on event
    By puchat3k in forum General
    Replies: 0
    Last Post: 10-23-2009, 03:12 PM
  2. [Question, Request] Send files with mail.app
    By lolof in forum Free Toolchain Software (Cydia App's)
    Replies: 0
    Last Post: 10-06-2008, 11:17 AM
  3. [1.1.4][Solved] My iphone automatically switch on
    By Gigi23 in forum iPhone "2G" (Rev. 1)
    Replies: 23
    Last Post: 07-07-2008, 12:47 PM
  4. Replies: 7
    Last Post: 07-11-2007, 10:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Powered by vBulletin®
Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.
Search Engine Friendly URLs by vBSEO
(c) 2006-2012 Hackint0sh.org
All times are GMT +2. The time now is 09:53 AM.
twitter, follow us!