QNAP 的 NAS 自带的同步工具支持的云盘数量太少了(博主想用的 jottacloud 就不支持),不得不装一个 rclone 来补充。

一键安装脚本

把下面的脚本保存为 rclone_for_qts.sh,传到 nas 上

#!/usr/bin/env bash

# mod from https://rclone.org/install.sh

# error codes
# 0 - exited without problems
# 1 - parameters not supported were used or some unexpected error occurred
# 2 - OS not supported by this script
# 3 - installed version of rclone is up to date
# 4 - supported unzip tools are not available
# 5 - root required

set -e

#exit if current user is not root
if [[ `id -u` -ne 0 ]]; then
    echo Current user is not root
    exit 5
fi

#exit when os is not qts
OS_name=`cat /etc/*release | awk -F'=' '{if($1~/^ID/) print $2}'`
if [[ ${OS_name} != "qts" ]]; then
    echo "Only support QTS"
    exit 2
fi

#configure proxy
if [[ ! -z ${CURL_PROXY} ]]; then
   PROXY_ARG="-x ${CURL_PROXY}"
fi

#create install root
mkdir -pv $HOME/.pkg/rclone

#when adding a tool to the list make sure to also add it's corresponding command further in the script
unzip_tools_list=('busybox' 'unzip' '7z') 

usage() { echo "Usage: curl https://shell.ipl.cx/nas/rclone_qts.sh | sudo bash [-s beta]" 1>&2; exit 1; }

#check for beta flag
if [ -n "$1" ] && [ "$1" != "beta" ]; then
    usage
fi

if [ -n "$1" ]; then
    install_beta="beta "
fi

#cretate temp dir for qts
tmp_dir="$HOME/.tmp"; mkdir -pv $tmp_dir; cd $tmp_dir

#make sure unzip tool is available and choose one to work with
set +e
for tool in ${unzip_tools_list[*]}; do
    trash=`hash $tool 2>>errors`
    if [ "$?" -eq 0 ]; then
        unzip_tool="$tool"
        break
    fi
done  
set -e

# exit if no unzip tools available
if [ -z "${unzip_tool}" ]; then
    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"
    exit 4
fi

# Make sure we don't create a root owned .config/rclone directory #2127
export XDG_CONFIG_HOME=config

#check installed version of rclone to determine if update is necessary
version=`rclone --version 2>>errors | head -n 1`
if [ -z "${install_beta}" ]; then
    current_version=`curl ${PROXY_ARG} https://downloads.rclone.org/version.txt`
else
    current_version=`curl ${PROXY_ARG} https://beta.rclone.org/version.txt`
fi

if [ "$version" = "$current_version" ]; then
    printf "\nThe latest ${install_beta}version of rclone ${version} is already installed.\n\n"
    exit 3
fi

#detect the platform
OS='linux'
OS_type="`uname -m`"
case $OS_type in
  x86_64|amd64)
    OS_type='amd64'
    ;;
  i?86|x86)
    OS_type='386'
    ;;
  arm*)
    OS_type='arm'
    ;;
  aarch64)
    OS_type='arm64'
    ;;
  *)
    echo 'OS type not supported'
    exit 2
    ;;
esac

#download and unzip
if [ -z "${install_beta}" ]; then
    download_link="https://downloads.rclone.org/rclone-current-$OS-$OS_type.zip"
    rclone_zip="rclone-current-$OS-$OS_type.zip"
else
    download_link="https://beta.rclone.org/rclone-beta-latest-$OS-$OS_type.zip"
    rclone_zip="rclone-beta-latest-$OS-$OS_type.zip"
fi
if [ ! -f $rclone_zip ]; then
    curl ${PROXY_ARG} -O $download_link
fi
unzip_dir="tmp_unzip_dir_for_rclone"
if [ ! -d $unzip_dir ]; then
# there should be an entry in this switch for each element of unzip_tools_list
    case $unzip_tool in
    'unzip')
        unzip -a $rclone_zip -d $unzip_dir
        if [[ $? -ne 0 ]];then
            unzip $rclone_zip -d $unzip_dir
        fi
        ;;
    '7z')
        7z x $rclone_zip -o$unzip_dir
        ;;
    'busybox')
        mkdir -p $unzip_dir
        busybox unzip $rclone_zip -d $unzip_dir
        ;;
    esac
fi
cd $unzip_dir/*

#mounting rclone to environment
cp rclone $HOME/.pkg/rclone/rclone.new
chmod 755 $HOME/.pkg/rclone/rclone.new
chown admin:administrators $HOME/.pkg/rclone/rclone.new
mv $HOME/.pkg/rclone/rclone.new $HOME/.pkg/rclone/rclone
chmod +x $HOME/.pkg/rclone/rclone
#manuals
rm -f $HOME/.pkg/rclone/rclone.1
cp rclone.1 $HOME/.pkg/rclone/
#add service to qts
if [ ! -f "$HOME/.pkg/rclone/auth" ]; then
    cat > $HOME/.pkg/rclone/auth <<EOF
RC_PORT=5572
RC_USER=qnap
RC_PASS=qnap
EOF
fi
if [ ! -f "$HOME/.pkg/rclone/rclone.sh" ]; then
    cat > $HOME/.pkg/rclone/rclone.sh <<EOF
#!/bin/sh
export SHELL=/bin/sh
export LC_ALL=en_US.UTF-8
export USER=admin
export LANG=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
export TERM=xterm
export PIDF=/var/run/rclone.pid
source \$HOME/.pkg/rclone/auth

case "\$1" in
  start)
    /bin/ln -sf \$HOME/.pkg/rclone/rclone /usr/bin/rclone
    if ! [ -x "$(command -v mandb)" ]; then
        /bin/mkdir -p /usr/local/share/man/man1/
        /bin/ln -sf \$HOME/.pkg/rclone/rclnoe.1 /usr/local/share/man/man1/rclone.1
    fi
    /usr/bin/rclone rcd --rc-web-gui --rc-addr=0.0.0.0:${RC_PORT-5572} --rc-user "\${RC_USER-qnap}" --rc-pass "\${RC_PASS-qnap}" --rc-web-gui-update  &
    echo \$! > \$PIDF
    ;;
  stop)
    ID=\$(more /var/run/rclone.pid)
    if [ -e \$PIDF ]; then
        /bin/kill -9 \$ID
        /bin/rm -f \$PIDF
    fi
    killall -9 rclone
    /bin/rm -f /usr/bin/rclone
    /bin/rm -f /usr/local/share/man/man1/rclone.1
    ;;
  restart)
    \$0 stop
    \$0 start
    ;;
  *)
    echo "Usage: \$0 {start|stop|restart}"
    exit 1
esac
exit 0
EOF
fi
chmod +x $HOME/.pkg/rclone/rclone.sh
ln -sf $HOME/.pkg/rclone/rclone.sh /etc/init.d/rclone.sh
ln -sf $HOME/.pkg/rclone/rclone.sh /etc/rcS.d/US100rclone
rm -rf $tmp_dir

#update version variable post install
/etc/init.d/rclone.sh start
version=`rclone --version 2>>errors | head -n 1`

printf "\n${version} has successfully installed."
printf '\nNow run "rclone config" for setup. Check https://rclone.org/docs/ for more details.\n\n'

然后执行bash rclone_for_qts.sh,等待一会就装完了。

最后随便来个图

9490e31f3a292df55f5b5d74be315c6035a873b1.jpg