KitzKikz  KitzKikz: SelfUpdatingShellScript   RecentChanges 
 PopularPages 
 SearchPages 
 Home | Trail - SelfUpdatingShell...
 
 

#!/bin/bash
#
# SUSS - Self Updating Shell Script
# Make sure file in svn has property set = svn:keywords "URL Rev"

SUSS_URL=$(echo "$URL: http://svn-repos-path/suss.sh $" | awk '{print $2}')
SUSS_REV=$(echo "$Rev: 1150 $" | awk '{print $2}')
SUSS_REMOTE_REV=$(svn list -v $SUSS_URL | awk '{print $1}'; exit ${PIPESTATUS[0]})
if (( $? > 0 )); then
   echo "Problem with subversion tool or url: svn list -v $SUSS_URL"
   exit 1
fi

echo -n "Local revision $SUSS_REV.  Remote revision $SUSS_REMOTE_REV. "
if [[ $SUSS_REV != $SUSS_REMOTE_REV ]]; then
   echo "Newer revision of $(basename $0) is available"
   svn log -r $SUSS_REV:HEAD $SUSS_URL
   echo -n "Update? (Y/n)"
   read UPDATE
   if [[ $UPDATE == [yY]* || -z $UPDATE ]]; then
      cp $0 $0.bak
      svn cat $SUSS_URL > $0
      if (( $? > 0 )); then
         echo "Unable to complete update."
         exit 4
      fi
      exec $0
   else
      echo 'No update.'
   fi
else
   echo "$(basename $0) is up to date."
fi

# Remainder of script goes here...

 

 

 
 EditThisPage · LinksToPage · PageInfo 04/05/16 17:31:14  ·  0.0546s