install.sh: fix some shellcheck warnings

This commit is contained in:
Ivan Andreev 2021-03-20 15:58:59 +03:00
parent cb46092883
commit 088a83872d

View file

@ -25,13 +25,14 @@ fi
#create tmp directory and move to it with macOS compatibility fallback #create tmp directory and move to it with macOS compatibility fallback
tmp_dir=`mktemp -d 2>/dev/null || mktemp -d -t 'rclone-install.XXXXXXXXXX'`; cd $tmp_dir tmp_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'rclone-install.XXXXXXXXXX')
cd "$tmp_dir"
#make sure unzip tool is available and choose one to work with #make sure unzip tool is available and choose one to work with
set +e set +e
for tool in ${unzip_tools_list[*]}; do for tool in ${unzip_tools_list[*]}; do
trash=`hash $tool 2>>errors` trash=$(hash "$tool" 2>>errors)
if [ "$?" -eq 0 ]; then if [ "$?" -eq 0 ]; then
unzip_tool="$tool" unzip_tool="$tool"
break break
@ -40,7 +41,7 @@ done
set -e set -e
# exit if no unzip tools available # exit if no unzip tools available
if [ -z "${unzip_tool}" ]; then if [ -z "$unzip_tool" ]; then
printf "\nNone of the supported tools for extracting zip archives (${unzip_tools_list[*]}) were found. " printf "\nNone of the supported tools for extracting zip archives (${unzip_tools_list[*]}) were found. "
printf "Please install one of them and try again.\n\n" printf "Please install one of them and try again.\n\n"
exit 4 exit 4
@ -50,11 +51,11 @@ fi
export XDG_CONFIG_HOME=config export XDG_CONFIG_HOME=config
#check installed version of rclone to determine if update is necessary #check installed version of rclone to determine if update is necessary
version=`rclone --version 2>>errors | head -n 1` version=$(rclone --version 2>>errors | head -n 1)
if [ -z "${install_beta}" ]; then if [ -z "$install_beta" ]; then
current_version=`curl https://downloads.rclone.org/version.txt` current_version=$(curl https://downloads.rclone.org/version.txt)
else else
current_version=`curl https://beta.rclone.org/version.txt` current_version=$(curl https://beta.rclone.org/version.txt)
fi fi
if [ "$version" = "$current_version" ]; then if [ "$version" = "$current_version" ]; then
@ -63,9 +64,8 @@ if [ "$version" = "$current_version" ]; then
fi fi
#detect the platform #detect the platform
OS="`uname`" OS="$(uname)"
case $OS in case $OS in
Linux) Linux)
OS='linux' OS='linux'
@ -93,8 +93,8 @@ case $OS in
;; ;;
esac esac
OS_type="`uname -m`" OS_type="$(uname -m)"
case $OS_type in case "$OS_type" in
x86_64|amd64) x86_64|amd64)
OS_type='amd64' OS_type='amd64'
;; ;;
@ -115,43 +115,42 @@ esac
#download and unzip #download and unzip
if [ -z "${install_beta}" ]; then if [ -z "$install_beta" ]; then
download_link="https://downloads.rclone.org/rclone-current-$OS-$OS_type.zip" download_link="https://downloads.rclone.org/rclone-current-${OS}-${OS_type}.zip"
rclone_zip="rclone-current-$OS-$OS_type.zip" rclone_zip="rclone-current-${OS}-${OS_type}.zip"
else else
download_link="https://beta.rclone.org/rclone-beta-latest-$OS-$OS_type.zip" download_link="https://beta.rclone.org/rclone-beta-latest-${OS}-${OS_type}.zip"
rclone_zip="rclone-beta-latest-$OS-$OS_type.zip" rclone_zip="rclone-beta-latest-${OS}-${OS_type}.zip"
fi fi
curl -O $download_link curl -O "$download_link"
unzip_dir="tmp_unzip_dir_for_rclone" unzip_dir="tmp_unzip_dir_for_rclone"
# there should be an entry in this switch for each element of unzip_tools_list # there should be an entry in this switch for each element of unzip_tools_list
case $unzip_tool in case "$unzip_tool" in
'unzip') 'unzip')
unzip -a $rclone_zip -d $unzip_dir unzip -a "$rclone_zip" -d "$unzip_dir"
;; ;;
'7z') '7z')
7z x $rclone_zip -o$unzip_dir 7z x "$rclone_zip" "-o$unzip_dir"
;; ;;
'busybox') 'busybox')
mkdir -p $unzip_dir mkdir -p "$unzip_dir"
busybox unzip $rclone_zip -d $unzip_dir busybox unzip "$rclone_zip" -d "$unzip_dir"
;; ;;
esac esac
cd $unzip_dir/*
cd $unzip_dir/*
#mounting rclone to environment #mounting rclone to environment
case $OS in case "$OS" in
'linux') 'linux')
#binary #binary
cp rclone /usr/bin/rclone.new cp rclone /usr/bin/rclone.new
chmod 755 /usr/bin/rclone.new chmod 755 /usr/bin/rclone.new
chown root:root /usr/bin/rclone.new chown root:root /usr/bin/rclone.new
mv /usr/bin/rclone.new /usr/bin/rclone mv /usr/bin/rclone.new /usr/bin/rclone
#manuals #manual
if ! [ -x "$(command -v mandb)" ]; then if ! [ -x "$(command -v mandb)" ]; then
echo 'mandb not found. The rclone man docs will not be installed.' echo 'mandb not found. The rclone man docs will not be installed.'
else else
@ -161,11 +160,11 @@ case $OS in
fi fi
;; ;;
'freebsd'|'openbsd'|'netbsd') 'freebsd'|'openbsd'|'netbsd')
#bin #binary
cp rclone /usr/bin/rclone.new cp rclone /usr/bin/rclone.new
chown root:wheel /usr/bin/rclone.new chown root:wheel /usr/bin/rclone.new
mv /usr/bin/rclone.new /usr/bin/rclone mv /usr/bin/rclone.new /usr/bin/rclone
#man #manual
mkdir -p /usr/local/man/man1 mkdir -p /usr/local/man/man1
cp rclone.1 /usr/local/man/man1/ cp rclone.1 /usr/local/man/man1/
makewhatis makewhatis
@ -186,7 +185,7 @@ esac
#update version variable post install #update version variable post install
version=`rclone --version 2>>errors | head -n 1` version=$(rclone --version 2>>errors | head -n 1)
printf "\n${version} has successfully installed." printf "\n${version} has successfully installed."
printf '\nNow run "rclone config" for setup. Check https://rclone.org/docs/ for more details.\n\n' printf '\nNow run "rclone config" for setup. Check https://rclone.org/docs/ for more details.\n\n'