File:
1.17.5a/vm-upgrade.sh (
View as Code)
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 "Once the file upgrade is complete you will be prompted to upgrade or"
40: echo "refresh the database schema and configuration."
41: echo
42: echo -n "Proceed with upgrade (y/N): "
43: read proccheck
44: if [ "$proccheck" != "y" ]; then
45: echo
46: echo "Upgrade Aborted at User Request"
47: echo
48: FN_WEB=""
49: export FN_WEB
50: exit 0
51: fi
52: echo
53: echo "**************** FreeNATS Virtual Appliance Upgrade ****************"
54: echo
55: echo "Proceeding with upgrade..."
56: echo
57:
58:
59: if [ "$VM_DUMMY" == "1" ]; then
60: ./shell-install.sh dummy
61: else
62: ./shell-install.sh
63: fi
64:
65: FN_WEB=""
66: export FN_WEB
67:
68: echo
69: echo "**************** FreeNATS Virtual Appliance Upgrade ****************"
70: echo
71: echo "File structure update completed."
72: echo
73:
74: echo "You must now decide whether to update the database schema (recommended)"
75: echo "and how to do this."
76: echo
77: echo -n "Update database schema [Y/n]: "
78: read updatesch
79: if [ "$updatesch" == "n" ]; then
80: echo "You have chosen not to update the schema. Please be aware this can"
81: echo "cause adverse affects and failures."
82: echo
83: exit 0
84: fi
85: echo
86: echo "Please select the update method - fresh (recommended) will wipe all"
87: echo "existing data from the FreeNATS system. Alternatively you can try"
88: echo "the update method (experimental) to upgrade the schema with the data"
89: echo "and configuration kept intact."
90: echo
91:
92: UDMETH=0
93: while [ "$UDMETH" == 0 ]; do
94: echo -n "Update Method [Fresh/Upgrade]: "
95: read udinp
96: if [ "$udinp" == "f" ]; then
97: UDMETH=1
98: elif [ "$udinp" == "u" ]; then
99: UDMETH=2
100: else
101: echo "Please enter f for fresh or u for upgrade (Control-C to abort)"
102: echo
103: fi
104: done
105:
106: function mysql
107: {
108: if [ "$VM_DUMMY" == 1 ]; then
109: echo "/usr/bin/mysql -u freenats -pfreenats -h localhost --force freenats < server/base/sql/$1"
110: else
111: /usr/bin/mysql -u freenats -pfreenats -h localhost --force freenats < server/base/sql/$1
112: fi
113: }
114:
115: if [ "$UDMETH" == 1 ]; then
116: echo "Importing Fresh Schema"
117: mysql schema.drop.sql
118: mysql default.sql
119: mysql example.sql
120: else
121: echo "Upgrading Database Schema - Please Ignore Errors"
122: mysql schema.sql
123: mysql schema.upgrade.sql
124: mysql default.sql
125: fi
126:
127: echo "Virtual Machine Configuration Complete"
128: echo
129: echo
130: echo "**************** FreeNATS Virtual Appliance Complete ****************"
131: echo
132: