ansible/roles/mirror/thinlinc/files/sync-thinlinc-repo

47 lines
1.2 KiB
Bash
Executable file

#!/bin/bash
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 -s "${BASEURL}/thinlinc/download" | \
sed -n 's/^.*<a href="\(.*\.x86_64\.rpm\)">64-bit.*/\1/p')
if [ "${LOCATION}" = "" ]; then
echo "ERR: Failed to determine current thinlinc version" 1>&2
exit 1
fi
PKGNAME="$(basename "${LOCATION}")"
if [ ! -f "${REPODIR}/${PKGNAME}" ]; then
echo "New thinlinc version found"
echo ""
# assume that server version goes in-line with client
echo "Downloading server package:"
curl -so "${REPODIR}/.server.zip" "${BASEURL}/downloads/server/download.py"
echo "Extracting server rpm files:"
unzip -jd ${REPODIR} ${REPODIR}/.server.zip \*.rpm
echo "Cleaning up..."
rm -f ${REPODIR}/.server.zip
echo ""
echo "Downloading client rpm package:"
curl -so "${REPODIR}/${PKGNAME}" "${BASEURL}${LOCATION}"
echo ""
echo "Updating repository metadata:"
createrepo_c "${REPODIR}"
echo ""
fi