#!/usr/bin/env bash repo="bcicen/ctop" current=$(reprepro -b /var/www/repos/apt/debian list stable docker-ctop | head -n1 | awk '{print $3}') api=$(curl --silent "https://api.github.com/repos/$repo/releases/latest") new=$(echo $api | grep -Po '"tag_name": "v\K.*?(?=")') if [ "$current" == "$new" ]; then exit fi echo "New DOCKER-CTOP version $current -> $new" END="ctop-" bin_urls=$(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'].startswith('$END')))" | grep linux) for bin_url in $bin_urls; do STARTDIR="/tmp/ctop" DESTDIR="$STARTDIR/pkg" OUTDIR="$STARTDIR/deb" rm -rf "$STARTDIR" mkdir "$STARTDIR" wget -q $bin_url -O "$STARTDIR/ctop" install -Dm 755 "$STARTDIR/ctop" "$DESTDIR/usr/bin/ctop" mkdir -p "$DESTDIR/DEBIAN" archi=$(echo $bin_url | cut -d '-' -f4) if [[ "$bin_url" != *linux* ]]; then continue fi [ "$archi" == "arm" ] && archi="armhf" echo "ARCHI - $archi" cat >"$DESTDIR/DEBIAN/control"< Description: Top-like interface for container metrics Homepage: https://github.com/bcicen/ctop Bugs: https://github.com/bcicen/ctop/issues EOL cat >"$STARTDIR/changelog"< $(date -R) EOL install -Dm 644 "$STARTDIR/changelog" "$DESTDIR/usr/share/doc/docker-ctop/changelog.Debian" gzip "$DESTDIR/usr/share/doc/docker-ctop/changelog.Debian" rm -rf "$OUTDIR" mkdir "$OUTDIR" dpkg-deb --build "$DESTDIR" "$OUTDIR" reprepro -b /var/www/repos/apt/debian includedeb stable "$OUTDIR"/*.deb reprepro -b /var/www/repos/apt/debian includedeb oldstable "$OUTDIR"/*.deb done rm -rf "$STARTDIR"