File:
0.04.17a/shell-install.sh (
View as Code)
1: #!/bin/bash
2:
3: # FreeNATS shell-install.sh : Installer/Upgrader
4: # Version 0.00
5: # Copyright 2008 PurplePixie Systems, All Rights Reserved
6: # Part of the FreeNATS Package released under the GNU GPL v3
7: # See http://www.purplepixie.org/freenats for more information
8: #
9:
10: if [ "$1" == "dummy" ]; then
11: FN_DUMMY="1"
12: else
13: FN_DUMMY="0"
14: fi
15:
16: if [ "$FN_BASE" == "" ]; then
17: FN_BASE="/opt/freenats/server/base/"
18: fi
19: if [ "$FN_BIN" == "" ]; then
20: FN_BIN="/opt/freenats/server/bin/"
21: fi
22: if [ "$FN_WEB" == "" ]; then
23: FN_WEB="/opt/freenats/server/web/"
24: fi
25:
26: # FN_BASE="/tmp/freenats/server/base/"
27: # FN_BIN="/tmp/freenats/server/bin/"
28: # FN_WEB="/tmp/freenats/server/web/"
29:
30: echo
31: echo FreeNATS Shell Install/Upgrade 0.00
32: echo http://www.purplepixie.org/freenats
33: echo
34: if [ "$FN_DUMMY" == "1" ]; then
35: echo "Dummy Run"
36: echo
37: fi
38:
39: function domv
40: {
41: echo "/bin/mv $1 $2"
42: if [ "$FN_DUMMY" != "1" ]; then
43: /bin/mv $1 $2
44: fi
45: }
46:
47: function docp
48: {
49: echo "/bin/cp -Rf -v --reply=yes $1 $2"
50: if [ "$FN_DUMMY" != "1" ]; then
51: /bin/cp -Rf -v --reply=yes $1 $2
52: fi
53: }
54:
55: function docpa
56: {
57: echo "/bin/cp -Rf -v --reply=yes $1* $2"
58: if [ "$FN_DUMMY" != "1" ]; then
59: /bin/cp -Rf -v --reply=yes $1* $2
60: fi
61: }
62:
63: function domkdir
64: {
65: echo "/bin/mkdir -p $1"
66: if [ "$FN_DUMMY" != "1" ]; then
67: /bin/mkdir -p $1
68: fi
69: }
70:
71:
72:
73: if [ ! -f "server/base/nats.php" ]; then
74: echo "Error: server/base/nats.php not found"
75: echo
76: echo "You must run this script from within the freenats directory i.e."
77: echo "the working directory is /downloads/freenats-xxx/"
78: echo
79: exit 0
80: fi
81:
82: echo -n "Is this an Upgrade or Install [U/i]: "
83: read itype
84:
85: if [ "$itype" == "i" ]; then
86: echo "Performing Fresh Installation"
87:
88:
89: else
90: echo "Performing System Upgrade"
91:
92: fi
93:
94: echo
95: echo "Directory locations - INCLUDE TRAILING SLASH!"
96: echo -n "Base [$FN_BASE]: "
97: read ubase
98: echo -n "Bin [$FN_BIN]: "
99: read ubin
100: echo -n "Web [$FN_WEB]: "
101: read uweb
102:
103: if [ "$ubase" != "" ]; then
104: FN_BASE="$ubase"
105: fi
106: if [ "$ubin" != "" ]; then
107: FN_BIN="$ubin"
108: fi
109: if [ "$uweb" != "" ]; then
110: FN_WEB="$uweb"
111: fi
112:
113: echo
114: echo "Using Installation Directories:"
115: echo "Base: $FN_BASE"
116: echo "Bin : $FN_BIN"
117: echo "Web : $FN_WEB"
118:
119: if [ "$itype" != "i" ]; then
120: if [ ! -d "$FN_BASE" ]; then
121: echo "Upgrade Error: $FN_BASE does not exist"
122: exit 0
123: fi
124: if [ ! -d "$FN_WEB" ]; then
125: echo "Upgrade Error: $FN_WEB does not exist"
126: exit 0
127: fi
128: if [ ! -d "$FN_BIN" ]; then
129: echo "Upgrade Error: $FN_BIN does not exist"
130: exit 0
131: fi
132: else
133: if [ -d "$FN_BASE" ]; then
134: echo "Install Error: $FN_BASE exists"
135: exit 0
136: fi
137: if [ -d "$FN_WEB" ]; then
138: echo "Install Error: $FN_WEB exists"
139: exit 0
140: fi
141: if [ -d "$FN_BIN" ]; then
142: echo "Install Error: $FN_BIN exists"
143: exit 0
144: fi
145: fi
146:
147: echo
148: echo "Installing/Upgrading ---"
149:
150: function cleanup
151: {
152: echo "- Cleaning Up"
153: if [ -f "server/web/firstrun.php" ]; then
154: CMD="server/web/firstrun.php server/web/firstrun-.php"
155: domv $CMD
156: fi
157: if [ -f "server/web/include-.php" ]; then
158: CMD="server/web/include-.php server/web/include.php"
159: domv $CMD
160: fi
161: if [ -f "server/bin/include-.php" ]; then
162: CMD="server/bin/include-.php server/bin/include.php"
163: domv $CMD
164: fi
165: if [ -f "server/base/config-.inc.php" ]; then
166: CMD="server/base/config-.inc.php server/base/config.inc.php"
167: domv $CMD
168: fi
169: }
170:
171: cleanup
172:
173:
174: if [ "$itype" == "i" ]; then
175: echo "- Fresh Install"
176: echo "- Creating Directories"
177:
178: CMD="$FN_BASE"
179: domkdir $CMD
180: CMD="$FN_WEB"
181: domkdir $CMD
182: CMD="$FN_BIN"
183: domkdir $CMD
184:
185: echo "- Enabling First Run Script"
186: CMD="server/web/firstrun-.php server/web/firstrun.php";
187: domv $CMD
188:
189: else
190:
191: echo "- Upgrade"
192: echo "- Protecting Existing Config"
193: CMD="server/web/include.php server/web/include-.php"
194: domv $CMD
195: CMD="server/bin/include.php server/bin/include-.php"
196: domv $CMD
197: CMD="server/base/config.inc.php server/base/config-.inc.php"
198: domv $CMD
199:
200:
201: fi
202:
203: echo "- Copying Files"
204: CMD="server/base/ $FN_BASE"
205: docpa $CMD
206: CMD="server/web/ $FN_WEB"
207: docpa $CMD
208: CMD="server/bin/ $FN_BIN"
209: docpa $CMD
210:
211:
212: cleanup
213: echo "--- Complete"
214: echo
215:
216: echo "**** THE NEXT STEP ****"
217: echo
218:
219: if [ "$itype" == "i" ]; then
220: echo "If you have moved the directories in relation to each other"
221: echo "i.e. base DOESN\'T lie at ../base from bin and/or web you will"
222: echo "need to edit the following files and change the BaseDir value:"
223: echo -n "$FN_WEB"
224: echo "include.php"
225: echo -n "$FN_BIN"
226: echo "include.php"
227: echo
228: echo "You will also need to edit the following file:"
229: echo -n "$FN_BASE"
230: echo "config.inc.php"
231: echo "and put in your MySQL connection information"
232: echo
233: echo "Once that is done you should browse to http://WEBINSTALL/firstrun.php"
234: echo "to complete database schema setup etc.."
235: echo
236: echo "You will also need to setup the CRON system processes to run the various"
237: echo "scripts as described in the install.html document and online at"
238: echo "http://www.purplepixie.org/freenats"
239: else
240: echo "The files should now have been upgraded and your include"
241: echo "and config.inc files not changed."
242: echo
243: echo "If you need to update the database schema (almost certainly) there are"
244: echo "three ways of doing this - creating fresh (recommended), manually"
245: echo "updating the or you can try the new (pre-pre-pre-alpha) update method."
246: echo
247: echo "To create fresh (reset the database to the current schema) you should"
248: echo "rename the web/firstrun-.php file to web/firstrun.php and browse to"
249: echo "it. Follow the instructions for a clean setup. (You can also manually"
250: echo "import the files see install.html for details)."
251: echo
252: echo "To try the experimental upgrade process see the install.html file."
253: echo
254: echo "If you need to update the schema manually the current schema is in:"
255: echo -n "$FN_BASE"
256: echo "sql/schema.sql"
257: fi
258:
259: echo
260:
261: