#!/usr/bin/env bash # stable repo="rclone/rclone" api=$(curl -s https://api.github.com/repos/$repo/releases | jq ".[0]") new=$(echo $api | grep -Po '"tag_name": "v\K.*?(?=")') current=$(reprepro -b /var/www/repos/apt/debian list stable rclone | head -n1| awk '{print $3}') all_suffix=('linux-386.deb' 'linux-amd64.deb' 'linux-arm.deb' 'linux-arm64.deb') path="/tmp/rclone.deb" if [ "$current" != "$new" ]; then for suffix in "${all_suffix[@]}"; do deb_url=$(echo $api | python3 -c "import sys; from json import loads as l; x = l(sys.stdin.read()); print(''.join(s['browser_download_url'] for s in x['assets'] if s['name'].endswith('$suffix')))") echo "New rclone version $current -> $new" wget -q $deb_url -O $path reprepro -b /var/www/repos/apt/debian includedeb stable $path reprepro -b /var/www/repos/apt/debian includedeb oldstable $path rm $path done fi # beta url='https://beta.rclone.org/' all_path=('rclone-beta-latest-linux-386.deb' 'rclone-beta-latest-linux-amd64.deb' 'rclone-beta-latest-linux-arm.deb' 'rclone-beta-latest-linux-arm64.deb') for path in "${all_path[@]}"; do curl -s "$url$path" --output "$path" reprepro -b /var/www/repos/apt/debian includedeb sid "$path" rm "$path" done