All pastes #778515 Raw Edit

Something

public shellscript v1 · immutable
·published 2007-11-17 17:32 UTC
rendered paste body
#!/bin/bash############################################This script was written by rob newland   ##and is free (as in speech) for all uses. ##it may be modified or have anything done ##to it as long as this notice remains.    ######################################################### VARIABLES #############var1="$1"var2="$2"############# FUNCTIONS #############function arguments () { echo "   Rob's tlm-project seed-server script." echo "Please supply one of the following arguments:" echo "    --check / -c      checks dependencies" echo "    --instdeps / -id  installs dependencies" echo "    --install / -i    installs the program" echo "    --help / -h       Displays this message" }checkforroot () {   if [[ ! `whoami`=="root" ]]     then      echo "********ERROR********"      echo "You must be logged in as root to run this script"      echo "Please log in as root and re-run this script."      echo "Aborting installation."      echo "********ERROR********"      exit   fi }function checkdeps () {checkforrootecho "Checking for bittorrent"which launchmany-curses.py &>/dev/null   if [ $? != "0" ];      then      echo -e "ERROR: bittorrent is either not installed or the required scripts are not installed." ;      read -p "Hit Enter to continue" blankvar   else      echo "Bittorrent is installed" ;   fiecho ""echo "Checking for cron"   if [[ -d /etc/cron.hourly ]]    then      echo "cron is installed" ;    else      echo "You do not have cron." ;   fiecho ""echo "checking for rsync"which rsync &>/dev/null    if [ $? != "0" ];      then      echo -e "rsync is not installed. Run $0 -i." ;      read -p "hit return to continue" blankvar ;   else      echo "rsync is installed" ;   fisleep 5 }function instdeps () {checkforrootecho checking for bittorrentwhich launchmany-curses.py &>/dev/null   if [ $? != "0" ];      then      echo -e "bittorrent -- NOT INSTALLED (OR INSTALLED CORRECTLY)";      cd /home/$USER ;      echo "Downloading bittorrent" ;      sleep 1 ;      wget http://download.bittorrent.com/dl/BitTorrent-4.4.0.tar.gz ;      tar -zxvf BitTorrent-4.4.0.tar.gz ;      cd BitTorrent-4.4.0 ;      echo "#!/bin/bash"  >> /usr/bin/launchmany-curses.py ;      echo "cd /home/$USER/BitTorrent-4.4.0 && ./launchmany-curses.py --torrent_dir /home/$USER/torrents --save_in /home/$USER/data --max_upload_rate 200"  >> /usr/bin/launchmany-curses.py ;      chmod 777 /usr/bin/launchmany-curses.py ;         echo ""   fiecho "Bittorrent is installed"echo ""echo checking for cron   if [[ -d /etc/cron.hourly ]]     then      echo "cron is installed"     else      echo "You do not have crond. Please find a way to install it. "   fiecho ""echo checking for rsync...which rsync &>/dev/null   if [ $? != "0" ];     then      echo "rsync -- NOT INSTALLED" ;      wget http://samba.anu.edu.au/ftp/rsync/rsync-2.6.7.tar.gz      tar -zxvf rsync-2.6.7.tar.gz      cd rsync*      ./configure && make & make install      read -p "hit return to continue" var      echo ""   fiecho "rsync is installed." }function installandcheck () {checkforrootecho "You need the following installed to run a seed server."echo "1. bittorrent"echo "2. cron"echo "3. rsync "echo ""read -p "Press ENTER to start" enterecho ""echo "Checking for bittorrent"which launchmany-curses.py &>/dev/null   if [ $? != "0" ];      then      echo -e "bittorrent -- NOT INSTALLED";      read -p "hit return to continue" var      exit;   fiecho bittorrent is installedecho ""echo checking for cron   if [[ -d /etc/cron.hourly ]]     then      echo "cron is installed"     else      echo "You do not have cron. Installation will now quit"; sleep 3; exit 0   fiecho ""echo checking for rsync...which rsync &>/dev/null   if [ $? != "0" ];      then      echo -e "rsync -- NOT INSTALLED";      read -p "Hit Enter to continue" var      exit;   fi echo "rsync is installed." echo "" echo "Making directories." if [[ ! -d /home/$USER/data ]] then        mkdir /home/$USER/data fi if [[ ! -d /home/$USER/torrents ]] then        mkdir /home/$USER/torrents fi torrentnum }function torrentnum () { if [[ -e /etc/cron.hourly/torrents ]] then        rm -f /etc/cron.hourly/torrents fi read -p "How many torrents would you like to seed? - CHOOSE 5, 10, 15 or 20 : " torrents case "$torrents" in        5  ) echo "Ok"; echo "rsync --delete --recursive -v rsync.tlm-project.org::seed-05 /home/$USER/torrents" &> /etc/cron.hourly/torrents; restinst;;        10 ) echo "Ok"; echo "rsync --delete --recursive -v rsync.tlm-project.org::seed-10 /home/$USER/torrents" &> /etc/cron.hourly/torrents; restinst;;        15 ) echo "Ok"; echo "rsync --delete --recursive -v rsync.tlm-project.org::seed-15 /home/$USER/torrents" &> /etc/cron.hourly/torrents; restinst;;        20 ) echo "Ok"; echo "rsync --delete --recursive -v rsync.tlm-project.org::seed-20 /home/$USER/torrents" &> /etc/cron.hourly/torrents; restinst;;        *  ) echo "Invalid option!"; torrentnum; restinst;; esac }function restinst () {chmod 777 /etc/cron.hourly/torrentsif [[ -e /usr/bin/torrentserver ]]then        rm -f /usr/bin/torrentserverfiecho "#!/bin/bash" &> /usr/bin/torrentserverecho "launchmany-curses.py" &> /usr/bin/torrentserverchmod 777 /usr/bin/torrentserverecho "Starting torrent server..."cd /etc/cron.hourly/./torrentstorrentserver }function checkargs () { case "$var1" in        -c            )  checkdeps;;        --check       )  checkdeps;;        --installdeps )  instdeps;;        -id           )  instdeps;;        -i            )  installandcheck;;        --install     )  installandcheck;;        --help        )  arguments;;        -h            )  arguments;;        *             )  arguments;; esac }########## END OF FUNCTIONS ####################### PROGRAM ##############checkargsexit