From 7f3bb95d2f5870bd96ed5b03eda7f0f8ef6fc11d Mon Sep 17 00:00:00 2001 From: Timo Makinen Date: Sat, 26 Aug 2023 16:26:11 +0000 Subject: [PATCH] mirror/thinlinc: Refactor download script --- ...nc-thinlinc-repo => sync-thinlinc-repo.sh} | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) rename roles/mirror/thinlinc/files/{sync-thinlinc-repo => sync-thinlinc-repo.sh} (59%) diff --git a/roles/mirror/thinlinc/files/sync-thinlinc-repo b/roles/mirror/thinlinc/files/sync-thinlinc-repo.sh similarity index 59% rename from roles/mirror/thinlinc/files/sync-thinlinc-repo rename to roles/mirror/thinlinc/files/sync-thinlinc-repo.sh index 2638197..6d6c44a 100755 --- a/roles/mirror/thinlinc/files/sync-thinlinc-repo +++ b/roles/mirror/thinlinc/files/sync-thinlinc-repo.sh @@ -1,4 +1,6 @@ -#!/bin/bash +#!/bin/sh + +set -eu umask 022 @@ -16,8 +18,8 @@ if [ ! -d "${REPODIR}" ]; then mkdir "${REPODIR}" fi -LOCATION=$(curl -s "${BASEURL}/thinlinc/download" | \ - sed -n 's/^.*64-bit.*/\1/p') +LOCATION=$(curl -sf "${BASEURL}/thinlinc/download/" | \ + sed -n 's/^.*&2 exit 1 @@ -25,20 +27,25 @@ fi PKGNAME="$(basename "${LOCATION}")" if [ ! -f "${REPODIR}/${PKGNAME}" ]; then - echo "New thinlinc version found" + 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 -so "${REPODIR}/.server.zip" "${BASEURL}/downloads/server/download.py" + curl -sfo "$tmpfile" "${BASEURL}/downloads/server/tl-${VERSION}-server.zip" echo "Extracting server rpm files:" - unzip -jd ${REPODIR} ${REPODIR}/.server.zip \*.rpm + unzip -jfvd "$REPODIR" "$tmpfile" \*.rpm echo "Cleaning up..." - rm -f ${REPODIR}/.server.zip echo "" echo "Downloading client rpm package:" - curl -so "${REPODIR}/${PKGNAME}" "${BASEURL}${LOCATION}" + echo $LOCATION + curl -sfo "${REPODIR}/${PKGNAME}" "${LOCATION}" echo "" echo "Updating repository metadata:" createrepo_c "${REPODIR}"