check_update.sh 1.0 KB

123456789101112131415161718192021
  1. #!/bin/bash
  2. # Created By [CTCGFW]Project OpenWRT
  3. # https://github.com/project-openwrt
  4. commit_info="$(curl -s https://github.com/nondanee/UnblockNeteaseMusic/commits/master)"
  5. latest_ver="$(echo -e "${commit_info}" |tr -d '\n' | grep -Eo 'commit\/[0-9a-z]+' |sed -n 1p |sed 's#commit/##g')"
  6. latest_ver_mini="$(echo -e "${commit_info}" |tr -d '\n' | grep -Eo 'BtnGroup-item"> [0-9a-z]+' |sed -n 1p |sed 's#BtnGroup-item"> ##g')"
  7. [ -z "${commit_info}" ] && echo "无法检测最新版本,请稍后重试" && exit 1
  8. [ -z "${latest_ver}" ] && echo "无法检测最新版本,请稍后重试" && exit 1
  9. [ -z "${latest_ver_mini}" ] && echo "无法检测最新版本,请稍后重试" && exit 1
  10. if [ ! -e "/usr/share/unblockneteasemusic/local_ver" ]; then
  11. echo "最新版本:${latest_ver_mini},点此更新"
  12. else
  13. if [ "$(cat /usr/share/unblockneteasemusic/local_ver)" != "${latest_ver}" ]; then
  14. echo "最新版本:${latest_ver_mini},点此更新"
  15. else
  16. echo "目前已是最新版本,无需更新"
  17. fi
  18. fi