Updated scripts to version v7.1

This commit is contained in:
clamsawd 2015-10-05 20:29:13 +02:00
parent e2e6829523
commit 277aca28de
7 changed files with 386 additions and 86 deletions

View File

@ -2,11 +2,11 @@
# aria2 script for bittorrent downloads. # aria2 script for bittorrent downloads.
# http://aria2.sourceforge.net/ # http://aria2.sourceforge.net/
# Created by Quique (quuiqueee@gmail.com) # Created by clamsawd (clamsawd@openmailbox.org)
# Licensed by GPL v.2 # Licensed by GPL v.2
# Last update: 27-10-2014 # Last update: 03-10-2015
# -------------------------------------- # --------------------------------------
VERSION=6.5 VERSION=7.1
#Check if exist .aria2 folder. #Check if exist .aria2 folder.
if [ -d $HOME/.aria2 ] ; then if [ -d $HOME/.aria2 ] ; then
@ -31,18 +31,25 @@ VERSION=6.5
echo "MAX_DOWNLOADS=25" >> $CONFIG_FILE echo "MAX_DOWNLOADS=25" >> $CONFIG_FILE
echo "ENCRYPTION=yes" >> $CONFIG_FILE echo "ENCRYPTION=yes" >> $CONFIG_FILE
echo "RPC=yes" >> $CONFIG_FILE echo "RPC=yes" >> $CONFIG_FILE
echo "RPC_PORT=6800" >> $CONFIG_FILE
echo "SEEDING=yes" >> $CONFIG_FILE echo "SEEDING=yes" >> $CONFIG_FILE
echo "SEED_RATIO=0.0" >> $CONFIG_FILE echo "SEED_RATIO=0.0" >> $CONFIG_FILE
echo "DEBUG=no" >> $CONFIG_FILE echo "DEBUG=no" >> $CONFIG_FILE
echo "DEBUG_LEVEL=info" >> $CONFIG_FILE echo "DEBUG_LEVEL=info" >> $CONFIG_FILE
echo "FILE_ALLOCATION=none" >> $CONFIG_FILE echo "FILE_ALLOCATION=none" >> $CONFIG_FILE
echo "CA_CERTIFICATE=no" >> $CONFIG_FILE
echo "CA_CERTIFICATE_FILE=/etc/ssl/certs/ca-certificates.crt" >> $CONFIG_FILE
source $CONFIG_FILE source $CONFIG_FILE
fi fi
#VARIABLES #VARIABLES
SPEED_OPTIONS="--max-overall-download-limit=$MAX_SPEED_DOWNLOAD --max-overall-upload-limit=$MAX_SPEED_UPLOAD" SPEED_OPTIONS="--max-overall-download-limit=$MAX_SPEED_DOWNLOAD --max-overall-upload-limit=$MAX_SPEED_UPLOAD"
PEER_OPTIONS="--bt-max-peers=$BT_MAX_PEERS" PEER_OPTIONS="--bt-max-peers=$BT_MAX_PEERS"
OTHER_OPTIONS="-V -j $MAX_DOWNLOADS --file-allocation=$FILE_ALLOCATION" if [ "$CA_CERTIFICATE" == "no" ] ; then
OTHER_OPTIONS="-V -j $MAX_DOWNLOADS --file-allocation=$FILE_ALLOCATION --auto-file-renaming=false --allow-overwrite=false"
elif [ "$CA_CERTIFICATE" == "yes" ] ; then
OTHER_OPTIONS="-V -j $MAX_DOWNLOADS --file-allocation=$FILE_ALLOCATION --auto-file-renaming=false --allow-overwrite=false --ca-certificate=$CA_CERTIFICATE_FILE"
fi
#check aria2 on system. #check aria2 on system.
aria2c -h > /dev/null aria2c -h > /dev/null
@ -67,7 +74,7 @@ VERSION=6.5
if [ "$RPC" == "no" ] ; then if [ "$RPC" == "no" ] ; then
RPC_OPTIONS="--rpc-listen-all=false" RPC_OPTIONS="--rpc-listen-all=false"
elif [ "$RPC" == "yes" ] ; then elif [ "$RPC" == "yes" ] ; then
RPC_OPTIONS="--enable-rpc --rpc-listen-all=true --rpc-allow-origin-all" RPC_OPTIONS="--enable-rpc --rpc-listen-all=true --rpc-allow-origin-all --rpc-listen-port=$RPC_PORT"
fi fi
if [ "$SEEDING" == "no" ] ; then if [ "$SEEDING" == "no" ] ; then
@ -82,6 +89,35 @@ VERSION=6.5
ALL_OPTIONS="$TORRENT_OPTIONS $SPEED_OPTIONS $PEER_OPTIONS $RPC_OPTIONS $SEED_OPTIONS --console-log-level=$DEBUG_LEVEL" ALL_OPTIONS="$TORRENT_OPTIONS $SPEED_OPTIONS $PEER_OPTIONS $RPC_OPTIONS $SEED_OPTIONS --console-log-level=$DEBUG_LEVEL"
fi fi
#Show help
if [ "$1" == "--help" ] ; then
clear
echo ""
echo "** aria2 bittorrent script v.$VERSION **"
echo ""
echo "USAGE:"
echo ""
echo "$0 [parameter | file.torrent]"
echo ""
echo "AVAILABLE PARAMETERS:"
echo ""
echo "--help - Show help"
echo "--now - Run immediately the script without menu"
echo ""
echo "Note: If you run the script without parameters,"
echo " this will show a menu with all options."
echo ""
exit
fi
#Run immediately the script without menu
if [ "$1" == "--now" ] ; then
echo ""
echo "** aria2 bittorrent script v.$VERSION **"
echo ""
aria2c $OTHER_OPTIONS "$TORRENT_FILES"/*.torrent $ALL_OPTIONS -d "$TORRENT_FOLDER"
fi
#Check input file. #Check input file.
if [ -f "$1" ] ; then if [ -f "$1" ] ; then
@ -89,20 +125,20 @@ VERSION=6.5
if [ "$CHECK_TORRENT" == "$1" ] ; then if [ "$CHECK_TORRENT" == "$1" ] ; then
clear clear
echo "" echo ""
echo "Detected torrent file!" echo "* Detected torrent file!"
echo "" echo ""
echo "Can you copy this file to '$TORRENT_FILES' directory and" echo "- Do you want to copy this file in '$TORRENT_FILES' directory"
echo -n "run aria2? (y/n); " ; read LOAD echo -n "and run aria2? (y/n): " ; read LOAD
if [ "$LOAD" == "y" ] ; then if [ "$LOAD" == "y" ] ; then
cp "$1" $TORRENT_FILES cp "$1" "$TORRENT_FILES"
cp -rf "$1" $TORRENT_FILES cp -rf "$1" "$TORRENT_FILES"
elif [ "$LOAD" == "n" ] ; then elif [ "$LOAD" == "n" ] ; then
echo "Exiting..." echo "Exiting..."
exit exit
else else
cp "$1" $TORRENT_FILES cp "$1" "$TORRENT_FILES"
cp -rf "$1" $TORRENT_FILES cp -rf "$1" "$TORRENT_FILES"
fi fi
else else
clear clear
@ -134,18 +170,19 @@ VERSION=6.5
echo " * Download directory: $TORRENT_FOLDER" echo " * Download directory: $TORRENT_FOLDER"
echo " * Torrent directory: $TORRENT_FILES/*.torrent" echo " * Torrent directory: $TORRENT_FILES/*.torrent"
echo " * Download speed: $MAX_SPEED_DOWNLOAD | Upload speed: $MAX_SPEED_UPLOAD" echo " * Download speed: $MAX_SPEED_DOWNLOAD | Upload speed: $MAX_SPEED_UPLOAD"
echo " * Encryption: $ENCRYPTION | RPC: $RPC" echo " * Encryption: $ENCRYPTION | RPC: $RPC (Port: $RPC_PORT)"
echo " * Max.peers: $BT_MAX_PEERS | Max.downloads: $MAX_DOWNLOADS" echo " * Max.peers: $BT_MAX_PEERS | Max.downloads: $MAX_DOWNLOADS"
echo " * Seeding: $SEEDING | Seed ratio: $SEED_RATIO" echo " * Seeding: $SEEDING | Seed ratio: $SEED_RATIO"
echo " * Debugging: $DEBUG | Debug.level: $DEBUG_LEVEL" echo " * Debugging: $DEBUG | Debug.level: $DEBUG_LEVEL"
echo " * CA-Certificate: $CA_CERTIFICATE ($CA_CERTIFICATE_FILE)"
echo " * File allocation: $FILE_ALLOCATION" echo " * File allocation: $FILE_ALLOCATION"
echo "" echo ""
echo -n "- run(r) | list(l) | magnet(m) | file(f) | quit(q): " ; read RUN echo -n "- run(r) | list(l) | magnet(m) | urls(u) | quit(q): " ; read RUN
if [ "$RUN" == "r" ] ; then if [ "$RUN" == "r" ] ; then
clear clear
aria2c $OTHER_OPTIONS $TORRENT_FILES/*.torrent $ALL_OPTIONS -d $TORRENT_FOLDER aria2c $OTHER_OPTIONS "$TORRENT_FILES"/*.torrent $ALL_OPTIONS -d "$TORRENT_FOLDER"
echo "Exiting..." echo "Exiting..."
elif [ "$RUN" == "q" ] ; then elif [ "$RUN" == "q" ] ; then
@ -159,11 +196,11 @@ VERSION=6.5
echo "" echo ""
echo "* List of torrents that will be loaded:" echo "* List of torrents that will be loaded:"
echo "" echo ""
ls $TORRENT_FILES | grep ".torrent" ls "$TORRENT_FILES" | grep ".torrent"
echo "" echo ""
echo "* List of incomplete downloads:" echo "* List of incomplete downloads:"
echo "" echo ""
ls $TORRENT_FOLDER | grep ".aria2" ls "$TORRENT_FOLDER" | grep ".aria2"
echo "" echo ""
echo -n "Press 'ENTER' to return " echo -n "Press 'ENTER' to return "
read notoption read notoption
@ -176,51 +213,38 @@ VERSION=6.5
echo "" echo ""
echo -n "- Type the Magnet-link: " ; read MAGNET echo -n "- Type the Magnet-link: " ; read MAGNET
echo "" echo ""
aria2c --bt-metadata-only=true --bt-save-metadata=true "$MAGNET" -d $TORRENT_FILES aria2c --bt-metadata-only=true --bt-save-metadata=true "$MAGNET" -d "$TORRENT_FILES"
echo "" echo ""
echo -n "Press 'ENTER' to return " echo -n "Press 'ENTER' to return "
read notoption read notoption
elif [ "$RUN" == "f" ] ; then elif [ "$RUN" == "u" ] ; then
URLS_FILE="$TORRENT_FILES"/urls.txt
if [ -f "$URLS_FILE" ] ; then
echo "$URLS_FILE" detected
else
echo -n > "$URLS_FILE"
fi
clear clear
echo "" echo ""
echo "* Load links from a file/metalink" echo "* List URLs ($URLS_FILE):"
echo "" echo ""
echo -n "- Type the path of the file: " ; read FILE cat "$URLS_FILE"
echo "" echo ""
if [ "${FILE:-NO_VALUE}" != "NO_VALUE" ] ; then echo -n "- Load URLs? (y/n): " ; read LOAD_URLS
if [ -f $FILE ] ; then if [ "$LOAD_URLS" == "y" ] ; then
clear clear
echo "" aria2c $OTHER_OPTIONS -i "$URLS_FILE" $ALL_OPTIONS -d "$TORRENT_FOLDER"
echo "* File: $FILE"
echo ""
echo -n "Press 'ENTER' to load file "
read notoption
clear
aria2c $OTHER_OPTIONS -i "$FILE" $ALL_OPTIONS -d $TORRENT_FOLDER
echo "Exiting..." echo "Exiting..."
else else
clear echo "Returning..."
echo ""
echo "* '$FILE' not exist!"
echo ""
echo -n "Press 'ENTER' to return "
read notoption
fi
else
clear
echo ""
echo "Invalid path (empty)"
echo ""
echo -n "Press 'ENTER' to return "
read notoption
fi fi
else else
clear clear
echo "" echo ""
echo "Invalid option, please, choose any available version" echo "Invalid option, please, choose any available option"
echo "" echo ""
echo -n "Press 'ENTER' to return " echo -n "Press 'ENTER' to return "
read notoption read notoption

242
scripts/aria2bt.cmd Normal file
View File

@ -0,0 +1,242 @@
@echo off
rem # aria2 script for bittorrent downloads.
rem # http://aria2.sourceforge.net/
rem # Created by clamsawd (clamsawd@openmailbox.org)
rem # Licensed by GPL v.2
rem # Last update: 03-10-2015
rem # --------------------------------------
set VERSION=7.1
set COMMAND_TEST=aria2c -v
set ARIA2_PATH=%USERPROFILE%\aria2
set CONFIG_FILE=%ARIA2_PATH%\aria2bt-conf.cmd
if not exist %ARIA2_PATH% mkdir %ARIA2_PATH%
if exist %CONFIG_FILE% goto load_config_file
if not exist %CONFIG_FILE% goto create_config_file
:create_config_file
echo rem # DEFAULT ARIA2BT SCRIPT CONFIG > %CONFIG_FILE%
echo. >> %CONFIG_FILE%
echo set DISC_FILES=C:>> %CONFIG_FILE%
echo set TORRENT_FOLDER=C:\Torrent>> %CONFIG_FILE%
echo set TORRENT_FILES=C:\Torrent\Files>> %CONFIG_FILE%
echo set MAX_SPEED_DOWNLOAD=300K>> %CONFIG_FILE%
echo set MAX_SPEED_UPLOAD=5K>> %CONFIG_FILE%
echo set BT_MAX_PEERS=25>> %CONFIG_FILE%
echo set MAX_DOWNLOADS=25>> %CONFIG_FILE%
echo set ENCRYPTION=yes>> %CONFIG_FILE%
echo set RPC=yes>> %CONFIG_FILE%
echo set RPC_PORT=6800>> %CONFIG_FILE%
echo set DEBUG=no>> %CONFIG_FILE%
echo set SEEDING=yes>> %CONFIG_FILE%
echo set SEED_RATIO=0.0>> %CONFIG_FILE%
echo set DEBUG_LEVEL=info>> %CONFIG_FILE%
echo set FILE_ALLOCATION=none>> %CONFIG_FILE%
echo set CA_CERTIFICATE=no>> %CONFIG_FILE%
echo set CA_CERTIFICATE_FILE=C:\Program Files\aria2\certs\ca-certificates.crt>> %CONFIG_FILE%
call %CONFIG_FILE%
:load_config_file
call %CONFIG_FILE%
rem # VARIABLES
set SPEED_OPTIONS=--max-overall-download-limit=%MAX_SPEED_DOWNLOAD% --max-overall-upload-limit=%MAX_SPEED_UPLOAD%
set PEER_OPTIONS=--bt-max-peers=%BT_MAX_PEERS%
if %CA_CERTIFICATE%==no set OTHER_OPTIONS=-V -j %MAX_DOWNLOADS% --file-allocation=%FILE_ALLOCATION% --auto-file-renaming=false --allow-overwrite=false
if %CA_CERTIFICATE%==yes set OTHER_OPTIONS=-V -j %MAX_DOWNLOADS% --file-allocation=%FILE_ALLOCATION% --auto-file-renaming=false --allow-overwrite=false --ca-certificate="%CA_CERTIFICATE_FILE%"
set TEMP_FILE=aria2-list.txt
if %ENCRYPTION%==yes set TORRENT_OPTIONS=--bt-min-crypto-level=arc4 --bt-require-crypto=true
if %RPC%==yes set RPC_OPTIONS=--enable-rpc --rpc-listen-all=true --rpc-allow-origin-all --rpc-listen-port=%RPC_PORT%
if %ENCRYPTION%==no set TORRENT_OPTIONS=--bt-require-crypto=false
if %RPC%==no set RPC_OPTIONS=--rpc-listen-all=false
if %SEEDING%==no set SEED_OPTIONS=--seed-time=0
if %SEEDING%==yes set SEED_OPTIONS=--seed-ratio=%SEED_RATIO%
set ALL_OPTIONS=%TORRENT_OPTIONS% %SPEED_OPTIONS% %PEER_OPTIONS% %RPC_OPTIONS% %SEED_OPTIONS%
:check_aria2_system
%COMMAND_TEST%
if %ERRORLEVEL%==0 goto check_input
cls
echo.
echo Error: 'aria2' is not installed!
echo Help: http://aria2.sourceforge.net/
echo.
echo Press 'ENTER' to exit
pause > nul
exit
:check_input
if exist "%1" goto input_file
if "%1"=="--help" goto show_help
if "%1"=="--now" goto run_now
if not exist "%1" goto aria2_run
:show_help
cls
echo.
echo ** aria2 bittorrent script v.%VERSION% **
echo.
echo USAGE:
echo.
echo aria2bt.cmd [parameter / file.torrent]
echo.
echo AVAILABLE PARAMETERS:
echo.
echo --help - Show help
echo --now - Run immediately the script without menu
echo.
echo Note: If you run the script without parameters,
echo this will show a menu with all options.
echo.
goto exit_aria2_script
:run_now
cls
echo.
echo ** aria2 bittorrent script v.%VERSION% **
echo.
%DISC_FILES%
cd %TORRENT_FILES%
dir /B | find ".torrent" > %TEMP_FILE%
if %DEBUG%==yes (
aria2c %OTHER_OPTIONS% -i %TEMP_FILE% %ALL_OPTIONS% -d %TORRENT_FOLDER% --console-log-level=%DEBUG_LEVEL%)
if %DEBUG%==no (
aria2c %OTHER_OPTIONS% -i %TEMP_FILE% %ALL_OPTIONS% -d %TORRENT_FOLDER%)
goto aria2_run
:input_file
cls
echo.
echo * File detected: "%1"
echo.
echo - Do you want to copy file to "%TORRENT_FILES%" directory
set /p LOAD=and run aria2 (y/n):
if %LOAD%==* goto copy_input_file
if %LOAD%==y goto copy_input_file
if %LOAD%==n goto exit_aria2_script
:copy_input_file
copy /Y "%1" "%TORRENT_FILES%"
xcopy /Y "%1" "%TORRENT_FILES%"
goto aria2_run
:aria2_run
cls
echo.
echo ** aria2 bittorrent script v.%VERSION% **
echo - http://aria2.sourceforge.net/
echo.
echo - aria2 config:
echo.
echo * Config.file: %CONFIG_FILE%
echo.
echo * Download directory: %TORRENT_FOLDER%
echo * Torrent directory: %TORRENT_FILES%\*.torrent (%DISC_FILES%)
echo * Download speed: %MAX_SPEED_DOWNLOAD% / Upload speed: %MAX_SPEED_UPLOAD%
echo * Encryption: %ENCRYPTION% / RPC: %RPC% (Port: %RPC_PORT%)
echo * Max.peers: %BT_MAX_PEERS% / Max.downloads: %MAX_DOWNLOADS%
echo * Seeding: %SEEDING% / Seed ratio: %SEED_RATIO%
echo * Debugging: %DEBUG% / Debug.level: %DEBUG_LEVEL%
echo * CA-Certificate: %CA_CERTIFICATE% (%CA_CERTIFICATE_FILE%)
echo * File allocation: %FILE_ALLOCATION%
echo.
set /p RUN=- run(r) / list(l) / magnet(m) / urls(u) / quit(q):
if %RUN%==* goto error_msg
if %RUN%==r goto aria2_command
if %RUN%==run goto aria2_command
if %RUN%==q goto exit_aria2_script
if %RUN%==quit goto exit_aria2_script
if %RUN%==l goto list_torrent
if %RUN%==list goto list_torrent
if %RUN%==m goto magnet_link
if %RUN%==magnet goto magnet_link
if %RUN%==urls goto load_urls
if %RUN%==u goto load_urls
:aria2_command
cls
%DISC_FILES%
cd %TORRENT_FILES%
dir /B | find ".torrent" > %TEMP_FILE%
if %DEBUG%==yes (
aria2c %OTHER_OPTIONS% -i %TEMP_FILE% %ALL_OPTIONS% -d %TORRENT_FOLDER% --console-log-level=%DEBUG_LEVEL%)
if %DEBUG%==no (
aria2c %OTHER_OPTIONS% -i %TEMP_FILE% %ALL_OPTIONS% -d %TORRENT_FOLDER%)
del %TEMP_FILE%
goto aria2_run
:list_torrent
cls
%DISC_FILES%
cd %TORRENT_FILES%
dir /B | find ".torrent" > %TEMP_FILE%
cls
echo.
echo * List of torrents that will be loaded:
echo.
type %TEMP_FILE%
echo.
echo * List of incomplete downloads:
echo.
dir /B %TORRENT_FOLDER% | find ".aria2"
echo.
echo Press 'ENTER' to return
pause > nul
del %TEMP_FILE%
goto aria2_run
:magnet_link
cls
echo.
echo * Make torrent file from Magnet-link
echo.
set /p MAGNET=- Type the Magnet-link:
echo.
aria2c --bt-metadata-only=true --bt-save-metadata=true "%MAGNET%" -d %TORRENT_FILES%
echo.
echo Press 'ENTER' to return
pause > nul
goto aria2_run
:load_urls
set URLS_FILE=%TORRENT_FILES%\urls.txt
if not exist %URLS_FILE% echo.> %URLS_FILE%
cls
echo.
echo * List URLs (%URLS_FILE%):
echo.
type %URLS_FILE%
echo.
set /p LOAD_URLS=- Load URLs? (y/n):
if %LOAD_URLS%==* goto init_load_urls
if %LOAD_URLS%==y goto init_load_urls
if %LOAD_URLS%==n goto aria2_run
:init_load_urls
cls
if %DEBUG%==yes (
aria2c %OTHER_OPTIONS% -i "%URLS_FILE%" %ALL_OPTIONS% -d %TORRENT_FOLDER% --console-log-level=%DEBUG_LEVEL%)
if %DEBUG%==no (
aria2c %OTHER_OPTIONS% -i "%URLS_FILE%" %ALL_OPTIONS% -d %TORRENT_FOLDER%)
goto aria2_run
:error_msg
cls
echo.
echo Invalid option, please, choose any available option
echo.
echo Press 'ENTER' to return
pause > nul
goto aria2_run
:exit_aria2_script
echo Exiting...

View File

@ -2,11 +2,11 @@
# aria2 script for bittorrent downloads. # aria2 script for bittorrent downloads.
# http://aria2.sourceforge.net/ # http://aria2.sourceforge.net/
# Created by Quique (quuiqueee@gmail.com) # Created by clamsawd (clamsawd@openmailbox.org)
# Licensed by GPL v.2 # Licensed by GPL v.2
# Last update: 27-10-2014 # Last update: 03-10-2015
# -------------------------------------- # --------------------------------------
set VERSION=6.5 set VERSION=7.1
#Check if exist .aria2 folder. #Check if exist .aria2 folder.
if ( -d $HOME/.aria2 ) then if ( -d $HOME/.aria2 ) then
@ -31,18 +31,25 @@ set VERSION=6.5
echo "set MAX_DOWNLOADS=25" >> $CONFIG_FILE echo "set MAX_DOWNLOADS=25" >> $CONFIG_FILE
echo "set ENCRYPTION=yes" >> $CONFIG_FILE echo "set ENCRYPTION=yes" >> $CONFIG_FILE
echo "set RPC=yes" >> $CONFIG_FILE echo "set RPC=yes" >> $CONFIG_FILE
echo "set RPC_PORT=6800" >> $CONFIG_FILE
echo "set SEEDING=yes" >> $CONFIG_FILE echo "set SEEDING=yes" >> $CONFIG_FILE
echo "set SEED_RATIO=0.0" >> $CONFIG_FILE echo "set SEED_RATIO=0.0" >> $CONFIG_FILE
echo "set DEBUG=no" >> $CONFIG_FILE echo "set DEBUG=no" >> $CONFIG_FILE
echo "set DEBUG_LEVEL=info" >> $CONFIG_FILE echo "set DEBUG_LEVEL=info" >> $CONFIG_FILE
echo "set FILE_ALLOCATION=none" >> $CONFIG_FILE echo "set FILE_ALLOCATION=none" >> $CONFIG_FILE
echo "set CA_CERTIFICATE=no" >> $CONFIG_FILE
echo "set CA_CERTIFICATE_FILE=/etc/ssl/certs/ca-certificates.crt" >> $CONFIG_FILE
source $CONFIG_FILE source $CONFIG_FILE
endif endif
# VARIABLES # VARIABLES
set SPEED_OPTIONS="--max-overall-download-limit=$MAX_SPEED_DOWNLOAD --max-overall-upload-limit=$MAX_SPEED_UPLOAD" set SPEED_OPTIONS="--max-overall-download-limit=$MAX_SPEED_DOWNLOAD --max-overall-upload-limit=$MAX_SPEED_UPLOAD"
set PEER_OPTIONS="--bt-max-peers=$BT_MAX_PEERS" set PEER_OPTIONS="--bt-max-peers=$BT_MAX_PEERS"
set OTHER_OPTIONS="-V -j $MAX_DOWNLOADS --file-allocation=$FILE_ALLOCATION" if ( "$CA_CERTIFICATE" == "no" ) then
set OTHER_OPTIONS="-V -j $MAX_DOWNLOADS --file-allocation=$FILE_ALLOCATION --auto-file-renaming=false --allow-overwrite=false"
else if ( "$ENCRYPTION" == "yes" ) then
set OTHER_OPTIONS="-V -j $MAX_DOWNLOADS --file-allocation=$FILE_ALLOCATION --auto-file-renaming=false --allow-overwrite=false --ca-certificate=$CA_CERTIFICATE_FILE"
endif
#check aria2 on system. #check aria2 on system.
aria2c -h > /dev/null aria2c -h > /dev/null
@ -67,7 +74,7 @@ set VERSION=6.5
if ( "$RPC" == "no" ) then if ( "$RPC" == "no" ) then
set RPC_OPTIONS="--rpc-listen-all=false" set RPC_OPTIONS="--rpc-listen-all=false"
else if ( "$RPC" == "yes" ) then else if ( "$RPC" == "yes" ) then
set RPC_OPTIONS="--enable-rpc --rpc-listen-all=true --rpc-allow-origin-all" set RPC_OPTIONS="--enable-rpc --rpc-listen-all=true --rpc-allow-origin-all --rpc-listen-port=$RPC_PORT"
endif endif
if ( "$SEEDING" == "no" ) then if ( "$SEEDING" == "no" ) then
@ -82,6 +89,35 @@ set VERSION=6.5
set ALL_OPTIONS="$TORRENT_OPTIONS $SPEED_OPTIONS $PEER_OPTIONS $RPC_OPTIONS $SEED_OPTIONS --console-log-level=$DEBUG_LEVEL" set ALL_OPTIONS="$TORRENT_OPTIONS $SPEED_OPTIONS $PEER_OPTIONS $RPC_OPTIONS $SEED_OPTIONS --console-log-level=$DEBUG_LEVEL"
endif endif
#Show help
if ( "$1" == "--help" ) then
clear
echo ""
echo "** aria2 bittorrent script v.$VERSION **"
echo ""
echo "USAGE:"
echo ""
echo "$0 [parameter | file.torrent]"
echo ""
echo "AVAILABLE PARAMETERS:"
echo ""
echo "--help - Show help"
echo "--now - Run immediately the script without menu"
echo ""
echo "Note: If you run the script without parameters,"
echo " this will show a menu with all options."
echo ""
exit
endif
#Run immediately the script without menu
if ( "$1" == "--now" ) then
echo ""
echo "** aria2 bittorrent script v.$VERSION **"
echo ""
aria2c $OTHER_OPTIONS "$TORRENT_FILES"/*.torrent $ALL_OPTIONS -d "$TORRENT_FOLDER"
endif
# Check input file. # Check input file.
if ( -f "$1" ) then if ( -f "$1" ) then
@ -89,21 +125,21 @@ set VERSION=6.5
if ( "$CHECK_TORRENT" == "$1" ) then if ( "$CHECK_TORRENT" == "$1" ) then
clear clear
echo "" echo ""
echo "Detected torrent file!" echo "* Detected torrent file!"
echo "" echo ""
echo "Can you copy this file to '$TORRENT_FILES' directory and" echo "- Do you want to copy this file in '$TORRENT_FILES' directory"
echo -n "run aria2? (y/n); " echo -n "and run aria2? (y/n); "
set LOAD="$<" set LOAD="$<"
if ( "$LOAD" == "y" ) then if ( "$LOAD" == "y" ) then
cp "$1" $TORRENT_FILES cp "$1" "$TORRENT_FILES"
cp -rf "$1" $TORRENT_FILES cp -rf "$1" "$TORRENT_FILES"
else if ( "$LOAD" == "n" ) then else if ( "$LOAD" == "n" ) then
echo "Exiting..." echo "Exiting..."
exit exit
else else
cp "$1" $TORRENT_FILES cp "$1" "$TORRENT_FILES"
cp -rf "$1" $TORRENT_FILES cp -rf "$1" "$TORRENT_FILES"
endif endif
else else
clear clear
@ -136,19 +172,20 @@ set VERSION=6.5
echo " * Download directory: $TORRENT_FOLDER" echo " * Download directory: $TORRENT_FOLDER"
echo " * Torrent directory: $TORRENT_FILES/*.torrent" echo " * Torrent directory: $TORRENT_FILES/*.torrent"
echo " * Download speed: $MAX_SPEED_DOWNLOAD | Upload speed: $MAX_SPEED_UPLOAD" echo " * Download speed: $MAX_SPEED_DOWNLOAD | Upload speed: $MAX_SPEED_UPLOAD"
echo " * Encryption: $ENCRYPTION | RPC: $RPC" echo " * Encryption: $ENCRYPTION | RPC: $RPC (Port: $RPC_PORT)"
echo " * Max.peers: $BT_MAX_PEERS | Max.downloads: $MAX_DOWNLOADS" echo " * Max.peers: $BT_MAX_PEERS | Max.downloads: $MAX_DOWNLOADS"
echo " * Seeding: $SEEDING | Seed ratio: $SEED_RATIO" echo " * Seeding: $SEEDING | Seed ratio: $SEED_RATIO"
echo " * Debugging: $DEBUG | Debug.level: $DEBUG_LEVEL" echo " * Debugging: $DEBUG | Debug.level: $DEBUG_LEVEL"
echo " * CA-Certificate: $CA_CERTIFICATE ($CA_CERTIFICATE_FILE)"
echo " * File allocation: $FILE_ALLOCATION" echo " * File allocation: $FILE_ALLOCATION"
echo "" echo ""
echo -n "- run(r) | list(l) | magnet(m) | file(f) | quit(q): " echo -n "- run(r) | list(l) | magnet(m) | urls(u) | quit(q): "
set RUN="$<" set RUN="$<"
if ( "$RUN" == "r" ) then if ( "$RUN" == "r" ) then
clear clear
aria2c $OTHER_OPTIONS $TORRENT_FILES/*.torrent $ALL_OPTIONS -d $TORRENT_FOLDER aria2c $OTHER_OPTIONS "$TORRENT_FILES"/*.torrent $ALL_OPTIONS -d "$TORRENT_FOLDER"
else if ( "$RUN" == "q" ) then else if ( "$RUN" == "q" ) then
@ -161,11 +198,11 @@ set VERSION=6.5
echo "" echo ""
echo "* List of torrents that will be loaded:" echo "* List of torrents that will be loaded:"
echo "" echo ""
ls $TORRENT_FILES | grep ".torrent" ls "$TORRENT_FILES" | grep ".torrent"
echo "" echo ""
echo "* List of incomplete downloads:" echo "* List of incomplete downloads:"
echo "" echo ""
ls $TORRENT_FOLDER | grep ".aria2" ls "$TORRENT_FOLDER" | grep ".aria2"
echo "" echo ""
echo -n "Press 'ENTER' to return " echo -n "Press 'ENTER' to return "
set NOOPTION="$<" set NOOPTION="$<"
@ -179,42 +216,39 @@ set VERSION=6.5
echo -n "- Type the Magnet-link: " echo -n "- Type the Magnet-link: "
set MAGNET="$<" set MAGNET="$<"
echo "" echo ""
aria2c --bt-metadata-only=true --bt-save-metadata=true "$MAGNET" -d $TORRENT_FILES aria2c --bt-metadata-only=true --bt-save-metadata=true "$MAGNET" -d "$TORRENT_FILES"
echo "" echo ""
echo -n "Press 'ENTER' to return " echo -n "Press 'ENTER' to return "
set NOOPTION="$<" set NOOPTION="$<"
else if ( "$RUN" == "f" ) then else if ( "$RUN" == "u" ) then
set URLS_FILE="$TORRENT_FILES"/urls.txt
if ( -f "$URLS_FILE" ) then
echo "$URLS_FILE" detected
else
echo -n > "$URLS_FILE"
endif
clear clear
echo "" echo ""
echo "* Load links from a file/metalink" echo "* List URLs ($URLS_FILE):"
echo "" echo ""
echo -n "- Type the path of the file: " cat "$URLS_FILE"
set FILE="$<" echo ""
if ( -f $FILE ) then echo -n "- Load URLS? (y/n): "
set LOAD_URLS="$<"
if ( "$LOAD_URLS" == "y" ) then
clear clear
echo "" aria2c $OTHER_OPTIONS -i "$URLS_FILE" $ALL_OPTIONS -d "$TORRENT_FOLDER"
echo "* File: $FILE"
echo ""
echo -n "Press 'ENTER' to load file "
set NOOPTION="$<"
clear
aria2c $OTHER_OPTIONS -i "$FILE" $ALL_OPTIONS -d $TORRENT_FOLDER
echo "Exiting..." echo "Exiting..."
else else
clear echo "Returning..."
echo ""
echo "* '$FILE' not exist!"
echo ""
echo -n "Press 'ENTER' to return "
set NOOPTION="$<"
endif endif
else else
clear clear
echo "" echo ""
echo "Invalid option, please, choose any available version" echo "Invalid option, please, choose any available option"
echo "" echo ""
echo -n "Press 'ENTER' to return " echo -n "Press 'ENTER' to return "
set NOOPTION="$<" set NOOPTION="$<"