#!/bin/bash

VER='v1.67.0'

script_dir="$(realpath $(dirname $0))"
WORK_DIR="${script_dir}"


# MARK: Safety for not existing mounting ${VER} directory
if [ ! -d "${WORK_DIR}/${VER}" ]; then
        mkdir -p "${WORK_DIR}/${VER}"
        echo "Directory '${WORK_DIR}${VER}' created."
fi

cd "${WORK_DIR}/${VER}" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-windows-amd64.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-osx-amd64.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-amd64.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-amd64.deb" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-amd64.rpm" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-freebsd-amd64.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-netbsd-amd64.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-openbsd-amd64.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-plan9-amd64.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-solaris-amd64.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-windows-386.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-386.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-386.deb" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-386.rpm" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-freebsd-386.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-netbsd-386.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-openbsd-386.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-plan9-386.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-arm.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-arm.deb" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-arm.rpm" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-freebsd-arm.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-netbsd-arm.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-arm-v6.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-arm-v6.deb" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-arm-v6.rpm" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-freebsd-arm-v6.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-netbsd-arm-v6.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-arm-v7.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-arm-v7.deb" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-arm-v7.rpm" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-freebsd-arm-v7.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-netbsd-arm-v7.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-windows-arm64.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-osx-arm64.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-arm64.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-arm64.deb" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-arm64.rpm" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-mips.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-mips.deb" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-mips.rpm" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-mipsle.zip" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-mipsle.deb" && \
aria2c -x 16 "https://downloads.rclone.org/${VER}/rclone-${VER}-linux-mipsle.rpm" && \
chown -R www-data:www-data . && \
echo ''  && \
echo ''  && \
echo '========== Finished ========='  && \
echo ''
