#!/bin/bash # # Shared code for update_gsi_files scripts... # # (c) Pavel Janík , 2007 # # GetGSI ISO URL # GetGSI () { ISO=$1 URL="$2" ( cd /tmp rm -f GSI_${ISO}.sdf.* date >/tmp/GSI_${ISO}.log wget --passive-ftp --tries=3 --timeout=15 "${URL}" 2>>/tmp/GSI_${ISO}.log || { echo "$ISO: ERROR - download!" rm -f GSI_${ISO}.sdf.* } ) [ -f /tmp/GSI_${ISO}.sdf.* ] && { gunzip -dc /tmp/GSI_${ISO}.sdf.* >/tmp/GSI_${ISO}.sdf 2>&1 || bunzip2 -c /tmp/GSI_${ISO}.sdf.* >/tmp/GSI_${ISO}.sdf 2>&1 CheckGSI ${ISO} rm /tmp/GSI_${ISO}.sdf } [ -f /tmp/GSI_${ISO}.sdf.* ] && [ /tmp/GSI_${ISO}.sdf.* -nt GSI_${ISO}.sdf.* ] && { mv /tmp/GSI_${ISO}.sdf.* . # Add the current log at the end of respective GSI log file cat /tmp/GSI_${ISO}.log >> GSI_${ISO}.log echo "$ISO: NEW" } } # # CheckGSI ISO # CheckGSI () { ISO=$1 GSIISO=`head -n2 /tmp/GSI_${ISO}.sdf |tail -n1 | awk -F' ' '{print $10}'` [ "x$ISO" != "x${GSIISO}" ] && echo "$ISO: ERROR - CheckGSI!" }