53 lines
1.3 KiB
Bash
Executable file
53 lines
1.3 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
umask 022
|
|
|
|
BASEURL="https://www.cendio.com"
|
|
REPODIR="/srv/mirrors/thinlinc"
|
|
|
|
if [ ! -d "${REPODIR}" ]; then
|
|
echo "ERR: Cannot find repository directory ${REPODIR}" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
# we only do x86_64
|
|
REPODIR="${REPODIR}/x86_64"
|
|
if [ ! -d "${REPODIR}" ]; then
|
|
mkdir "${REPODIR}"
|
|
fi
|
|
|
|
LOCATION=$(curl -sf "${BASEURL}/thinlinc/download/" | \
|
|
sed -n 's/^.*<a href="\(.*\.x86_64\.rpm\)".*/\1/p' | head -n 1)
|
|
if [ "${LOCATION}" = "" ]; then
|
|
echo "ERR: Failed to determine current thinlinc version" 1>&2
|
|
exit 1
|
|
fi
|
|
PKGNAME="$(basename "${LOCATION}")"
|
|
|
|
if [ ! -f "${REPODIR}/${PKGNAME}" ]; then
|
|
VERSION="$(echo "$PKGNAME" | sed -n 's/^thinlinc-client-\([0-9\.]*\)-[0-9]*\.x86_64\.rpm/\1/p')"
|
|
|
|
echo "New thinlinc version ${VERSION} found"
|
|
echo ""
|
|
|
|
tmpfile="$(mktemp)"
|
|
trap 'rm -f "$tmpfile"' EXIT
|
|
|
|
# assume that server version goes in-line with client
|
|
echo "Downloading server package:"
|
|
curl -sfo "$tmpfile" "${BASEURL}/downloads/server/tl-${VERSION}-server.zip"
|
|
echo "Extracting server rpm files:"
|
|
unzip -jfvd "$REPODIR" "$tmpfile" \*.rpm
|
|
echo "Cleaning up..."
|
|
echo ""
|
|
|
|
echo "Downloading client rpm package:"
|
|
curl -sfo "${REPODIR}/${PKGNAME}" "${LOCATION}"
|
|
echo ""
|
|
echo "Updating repository metadata:"
|
|
createrepo_c "${REPODIR}"
|
|
echo ""
|
|
fi
|
|
|