~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
cvs/emstar/bin/push-upgrade.sh


  1 #!/bin/bash
  2 
  3 usage() {
  4         echo "push-upgrade.sh [--ip ADDRESS / --node NODE] <build tarfile>"
  5         echo
  6         echo "  Specify either IP address or node ID.  If node ID "
  7         echo "  is specified, assumes address is 192.168.11.<NODE>."
  8         echo 
  9         echo "  The build tarfile is assumed to have an intall script"
 10         echo "  in it, called ./tmp/UPGRADE.sh"
 11         echo
 12         echo "  This script will copy the tar file to /tmp on the node,"
 13         echo "  extract the upgrade script, and then execute the script."
 14         echo
 15         exit 1
 16 } 
 17 
 18 install() {
 19     if ! scp $1 root@$ADDR:/tmp/NEW_BUILD.tgz
 20         then
 21         echo "Unable to push upgrade file."
 22         exit 1
 23     fi
 24     if ! ssh root@$ADDR "tar -C / -xzvf /tmp/NEW_BUILD.tgz ./tmp/UPGRADE.sh"
 25         then
 26         echo "Unable to extract upgrade script file."
 27         echo "Make sure it is in archive as ./tmp/UPGRADE.sh"
 28         exit 1
 29     fi
 30     if ! ssh root@$ADDR "sh /tmp/UPGRADE.sh"
 31         then
 32         echo "*** WARNING *** upgrade appears to have FAILED"
 33         echo "CHECK NODE BEFORE POWERING OFF"
 34         exit 1
 35     fi
 36     echo "Success!"
 37     exit 0
 38 }
 39 
 40 NETWORK=192.168.11
 41 ADDRSET=0
 42 
 43 while [ $1 ] ; do 
 44     case "$1" in 
 45       -h)
 46         usage
 47         ;;
 48       --help)
 49         usage
 50         ;;
 51       -?)
 52         usage
 53         ;;
 54       --ip)
 55         if [[ $ADDRSET == 1 ]]
 56             then
 57             echo "Set ip or node, not both." 
 58             exit 1 
 59         fi
 60         ADDR=$2
 61         ADDRSET=1
 62         shift
 63         shift
 64         ;;
 65       --node)
 66         if [[ $ADDRSET == 1 ]]
 67             then 
 68             echo "Set ip or node, not both." 
 69             exit 1
 70         fi
 71         ADDR=$NETWORK.$2
 72         ADDRSET=1
 73         shift
 74         shift
 75         ;;
 76       *)
 77         if [[ $ADDRSET == 0 ]]
 78             then 
 79             echo "Please provide ip or node id."
 80             exit 1
 81         fi
 82         install $1
 83         ;;
 84     esac
 85 done
 86 
 87 echo "No installation file specified?"
 88 exit 1

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.