mirror/thinlinc: Refactor download script
This commit is contained in:
parent
b6754d49e7
commit
7f3bb95d2f
1 changed files with 15 additions and 8 deletions
54
roles/mirror/thinlinc/files/sync-thinlinc-repo.sh
Executable file
54
roles/mirror/thinlinc/files/sync-thinlinc-repo.sh
Executable file
|
@ -0,0 +1,54 @@
|
|||
#!/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:"
|
||||
echo $LOCATION
|
||||
curl -sfo "${REPODIR}/${PKGNAME}" "${LOCATION}"
|
||||
echo ""
|
||||
echo "Updating repository metadata:"
|
||||
createrepo_c "${REPODIR}"
|
||||
echo ""
|
||||
fi
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue