#!/bin/bash # # --- adsdownload --- # This script is part of the Automatic Download System. # if [ ! -x `which mysql` ] then echo "The MySQL command does not exist! Please install mysql first." exit 1 fi myname=$0 if [ -s "$myname" ] && [ -x "$myname" ] then # $myname is already a valid file name mypath=$myname else case "$myname" in /*) exit 1;; # absolute path - do not search PATH *) # Search all directories from the PATH variable. Take # care to interpret leading and trailing ":" as meaning # the current directory; the same is true for "::" within # the PATH. for dir in `echo "$PATH" | sed 's/^:/.:/g;s/::/:.:/g;s/:$/:./;s/:/ /g'` do [ -f "$dir/$myname" ] || continue # no file [ -x "$dir/$myname" ] || continue # not executable mypath=$dir/$myname break # only return first matching file done ;; esac fi if [ -f "$mypath" ] then : # echo >&2 "DEBUG: mypath=<$mypath>" else echo >&2 "cannot find full path name: $myname" exit 1 fi mypath=`dirname "$mypath"` #path: $mypath if [ "$1" = "bittorrent" ] then "$mypath/adsdl_bittorrent" "$2" "$3" "$mypath" & elif [ "$1" = "" ] then echo "Usage:" echo "./adsdownload PROTOCOL URL DOWNLOADID" echo "This version of ADS supports:" echo "BitTorrent" echo "URL can be a direct path or a web path." echo "WARNING!! Please do not call this file !!WARNING" echo "WARNING!! from the shell directly!! !!WARNING" echo "WARNING!! It needs variables that !!WARNING" echo "WARNING!! should be given by the PHP !!WARNING" echo "WARNING!! scripts of the ADS!! !!WARNING" else echo "ADS doesn't know the $1 protocol." fi