#/usr/bin/bash
cd "$(dirname $0)"
current_version=`/usr/local/bin/aliyundrive-webdav --version|awk '{print $2}'`
echo "[$(date '+%Y-%m-%d %H:%M:%S')]当前版本:$current_version"
version=`curl -s -i "https://github.com/messense/aliyundrive-webdav/releases/latest"|grep "location: "|awk -F "/" '{ print $NF }'`
echo "[$(date '+%Y-%m-%d %H:%M:%S')]最新版本:$version"
if [[ -n $version ]] && [[ $version != *$current_version* ]];then
echo "[$(date '+%Y-%m-%d %H:%M:%S')]开始更新..."
rm -rf *.gz
download="https://github.com/messense/aliyundrive-webdav/releases/download/version/aliyundrive-webdav-version.armv7-unknown-linux-musleabihf.tar.gz"
link=${download//version/$version}
echo $link
wget $link
tar -xzvf aliyundrive*.tar.gz
mv /usr/local/bin/aliyundrive-webdav "aliyundrive-webdav.$current_version"
mv aliyundrive-webdav /usr/local/bin/aliyundrive-webdav
chmod +x /usr/local/bin/aliyundrive-webdav
echo "[$(date '+%Y-%m-%d %H:%M:%S')]重启程序..."
sh restart_webdav.sh `cat refresh_token`
echo "[$(date '+%Y-%m-%d %H:%M:%S')]已更新到$version版本"
# 使用pushdeer发送通知到手机
curl -G "https://api2.pushdeer.com/message/push?pushkey=xxxxxxxxxxxxxxxxxxxxxxxxxx" --data-urlencode "aliyundrive-webdav已更新到$version"
else
echo "[$(date '+%Y-%m-%d %H:%M:%S')]已是最新版本。"
fi
|