#!/bin/bash # get new vesions of scripts and any new scripts prefix='bash' DEST='/root/bin' URI="http://repo.hpc.lsu.edu/files/${prefix}" scriptFile='scripts.txt' scriptList="${URI}/${scriptFile}" if [[ ! -d ${DEST} ]] then mkdir -p ${DEST} fi cd ${DEST} rm -f ${scriptFile} if [[ ! -f ${prefix}-sync.bash ]] then ln -s ${prefix}-sync1.bash ${prefix}-sync.bash fi echo 'Downloading script list' wget "${scriptList}" >/dev/null 2>/dev/null cat ${scriptFile} | while read line do set ${line} sum="$1" file="$2" # sum of 0 says file should be deleted if [[ '0' == "${sum}" ]] then if [[ -f ${file} ]] then echo "-Removing: ${file} -- File marked to be deleted!" rm -f ${file} fi else # normal checksum if [[ -f ${file} ]] then local=$(sha1sum ${file} | awk '{print $1}') if [[ "${local}" != "${sum}" ]] then echo "-Removing: ${file} -- it has been updated" rm -f ${file} fi fi if [[ -f ${file} ]] then echo "=File is current: ${file}" else echo "+Downloading current copy of: ${file}" wget "${URI}/${file}" >/dev/null 2>/dev/null chmod a+x ${file} fi fi done