File: 0.02.40a/vm-upgrade.sh (View as HTML)

  1: #!/bin/bash
  2: # FreeNATS vm-upgade.sh : VM Specific Upgrader
  3: # Copyright 2008 PurplePixie Systems, All Rights Reserved
  4: # Part of the FreeNATS Package released under the GNU GPL v3
  5: # See http://www.purplepixie.org/freenats for more information
  6: #
  7: 
  8: if [ "$1" == "dummy" ]; then
  9:  VM_DUMMY="1"
 10: else
 11:  VM_DUMMY="0"
 12: fi
 13: 
 14: echo "Upgrading Virtual Machine..."
 15: if [ "$VM_DUMMY" == "1" ]; then
 16:  echo "-- Dummy Run --"
 17: fi
 18: 
 19: echo
 20: 
 21: if [ ! -f "shell-install.sh" ]; then
 22:  echo "shell-install.sh not found - must be in the same directory"
 23:  echo "and have the same working directory!"
 24:  echo
 25:  exit 0
 26: fi
 27: 
 28: FN_WEB="/srv/www/html/"
 29: export FN_WEB
 30: 
 31: echo
 32: echo "**************** FreeNATS Virtual Appliance Upgrade ****************"
 33: echo
 34: echo "The upgrade process will now call the file upgrade script with values"
 35: echo "pre-set for the FreeNATS rPath Virtual Appliance. You to just select"
 36: echo "upgrade (press return) and accept the default directory locations"
 37: echo "(by pressing return)."
 38: echo 
 39: echo
 40: echo -n "Proceed with upgrade (y/N): "
 41: read proccheck
 42: if [ "$proccheck" != "y" ]; then
 43:  echo
 44:  echo "Upgrade Aborted at User Request"
 45:  echo
 46:  FN_WEB=""
 47:  export FN_WEB
 48:  exit 0
 49: fi
 50: echo
 51: echo "**************** FreeNATS Virtual Appliance Upgrade ****************"
 52: echo
 53: echo "Proceeding with upgrade..."
 54: echo
 55:  
 56:  
 57: if [ "$VM_DUMMY" == "1" ]; then
 58:  ./shell-install.sh dummy
 59: else
 60:  ./shell-install.sh
 61: fi
 62: 
 63: FN_WEB=""
 64: export FN_WEB
 65: 
 66: echo
 67: echo "**************** FreeNATS Virtual Appliance Upgrade ****************"
 68: echo
 69: echo "File structure update completed."
 70: echo
 71: 
 72: echo "You must now decide whether to update the database schema (recommended)"
 73: echo "and how to do this."
 74: echo
 75: echo -n "Update database schema [Y/n]: "
 76: read updatesch
 77: if [ "$updatesch" == "n" ]; then
 78:  echo "You have chosen not to update the schema. Please be aware this can"
 79:  echo "cause adverse affects and failures."
 80:  echo
 81:  exit 0
 82: fi
 83: echo
 84: echo "Please select the update method - fresh (recommended) will wipe all"
 85: echo "existing data from the FreeNATS system. Alternatively you can try"
 86: echo "the update method (experimental) to upgrade the schema with the data"
 87: echo "and configuration kept intact."
 88: echo
 89: 
 90: UDMETH=0
 91: while [ "$UDMETH" == 0 ]; do
 92:  echo -n "Update Method [Fresh/Upgrade]: "
 93:  read udinp
 94:  if [ "$udinp" == "f" ]; then
 95:   UDMETH=1
 96:  elif [ "$udinp" == "u" ]; then
 97:   UDMETH=2
 98:  else
 99:   echo "Please enter f for fresh or u for upgrade (Control-C to abort)"
100:   echo
101:  fi
102: done
103: 
104: function mysql
105:  {
106:  if [ "$VM_DUMMY" == 1 ]; then
107:   echo "/usr/bin/mysql -u freenats -pfreenats -h localhost --force freenats < server/base/sql/$1"
108:  else
109:   /usr/bin/mysql -u freenats -pfreenats -h localhost --force freenats < server/base/sql/$1
110:  fi
111:  }
112: 
113: if [ "$UDMETH" == 1 ]; then
114:  mysql schema.drop.sql
115:  mysql default.sql
116:  mysql example.sql
117: else
118:  mysql schema.sql
119:  mysql schema.upgrade.sql
120:  mysql default.sql
121: fi
122: 
123: echo "Virtual Machine Configuration Complete"
124: echo
125: