56 lines
1.2 KiB
Bash
Executable File
56 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Base wget command
|
|
BASE_CMD="wget -r -c --no-host-directories --no-parent --reject='index.html*'"
|
|
|
|
# Let's get the URL first
|
|
if [ "$1" == "" ]; then
|
|
echo "No url given!" >&2
|
|
echo "Usage: $0 URL RATELIMIT [USER PASSWORD]" >&2
|
|
exit 1
|
|
else
|
|
PARAM_URL="'$1'"
|
|
shift
|
|
fi
|
|
|
|
# Collect non-essential parameters and build the final command to run
|
|
FINAL_CMD="$BASE_CMD"
|
|
|
|
# Collect rate limit
|
|
if [ "$1" != "" ]; then
|
|
PARAM_LIMIT="--limit-rate='$1'"
|
|
FINAL_CMD="$FINAL_CMD $PARAM_LIMIT"
|
|
fi
|
|
shift
|
|
|
|
# Collect user + pass, error out if one is missing
|
|
if [ "$1" != "" ]; then
|
|
PARAM_USER="--user='$1'"
|
|
shift
|
|
# Collect password, too
|
|
if [ "$1" == "" ] ; then
|
|
echo "User given, but password missing?!" >&2
|
|
exit 1
|
|
else
|
|
PARAM_PASS="--password='$1'"
|
|
fi
|
|
FINAL_CMD="$FINAL_CMD $PARAM_USER $PARAM_PASS"
|
|
fi
|
|
shift
|
|
|
|
# Append URL and that's it.
|
|
FINAL_CMD="$FINAL_CMD $PARAM_URL"
|
|
|
|
# Debug output
|
|
echo "-------------------------------------"
|
|
echo "PARAM_LIMIT: $PARAM_LIMIT"
|
|
echo "PARAM_USER: $PARAM_USER"
|
|
echo "PARAM_PASS: $PARAM_PASS"
|
|
echo "PARAM_URL: $PARAM_URL"
|
|
echo "-------------------------------------"
|
|
echo "Running command: $FINAL_CMD"
|
|
echo "-------------------------------------"
|
|
echo ""
|
|
eval $FINAL_CMD
|
|
|