forked from RonIovine/pshell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstallPshell
More file actions
executable file
·261 lines (239 loc) · 9.58 KB
/
installPshell
File metadata and controls
executable file
·261 lines (239 loc) · 9.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#!/bin/bash
#################################################################################
#
# Copyright (c) 2009, Ron Iovine, All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Ron Iovine nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY Ron Iovine ''AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL Ron Iovine BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
#################################################################################
localDir=$(pwd)
if [ ! -e "$localDir/installPshell" ]
then
echo "ERROR: This script must be run from same directory where it resides"
exit 1
fi
if [ $# -ge 1 ]
then
if [ "$1" != "-local" -o $# -gt 2 ]
then
echo
echo "Usage: installPshell [-local [<shellEnvFile>]]"
echo
echo " This install script will either install this package on a system"
echo " wide basis or will setup a local install environment. A system"
echo " install must be done as 'root' and will copy all libraries, binaries,"
echo " include files, conf files, and manpages to their customary system"
echo " locations. A local install will not copy/move any files. It will"
echo " only create a pshell env file (.pshellrc) that can be sourced in the"
echo " current shell or can be added to your shell env file (i.e. .bashrc)"
echo " that will allow use of the package features from a local directory."
echo
echo " The location of the local install environment will be the directory"
echo " where this script resides."
echo
echo " where:"
echo " local - install locally, omit for system install"
echo " shellEnvFile - name of shell environment file to modify"
echo " (e.g. full path to your .bashrc)"
echo
exit 1
else
# local install, create .pshellrc env file
echo "Setting softlink libpshell-server to libpshell-server-full"
if [ -e "lib/libpshell-server.so" ]
then
rm -f lib/libpshell-server.so
fi
ln -s $localDir/lib/libpshell-server-full.so lib/libpshell-server.so
if [ -e "lib/libpshell-server.a" ]
then
rm -f lib/libpshell-server.a
fi
ln -s $localDir/lib/libpshell-server-full.a lib/libpshell-server.a
rm -f .pshellrc
echo "#" >> .pshellrc
echo "# Local PSHELL install env file" >> .pshellrc
echo "#" >> .pshellrc
echo "# This env file can be sourced in the current command shell with 'source .pshellrc'" >> .pshellrc
echo "# or can be sourced for all shells by adding 'source $localDir/.pshellrc' to your '.bashrc'" >> .pshellrc
echo "#" >> .pshellrc
echo export PSHELL_INSTALL=$localDir >> .pshellrc
echo export PSHELL_BATCH_DIR=\$PSHELL_INSTALL/batch >> .pshellrc
echo export PSHELL_STARTUP_DIR=\$PSHELL_INSTALL/startup >> .pshellrc
echo export PSHELL_CONFIG_DIR=\$PSHELL_INSTALL/config >> .pshellrc
echo export PATH=\$PSHELL_INSTALL/bin:\$PSHELL_INSTALL/utils:\$PATH >> .pshellrc
echo export MANPATH=\$PSHELL_INSTALL/man:\$MANPATH >> .pshellrc
echo export LD_LIBRARY_PATH=\$PSHELL_INSTALL/lib:\$LD_LIBRARY_PATH >> .pshellrc
echo "Local install environment setup in '.pshellrc'"
echo "To source enviromnent in current shell run 'source .pshellrc'"
if [ $# -eq 2 ]
then
shellEnvFile=$2
if [ ! -e "$shellEnvFile" ]
then
echo "ERROR: Shell env file: $shellEnvFile, not found"
echo "To source enviromnent in all shells add 'source $localDir/.pshellrc' to your '.bashrc'"
else
echo "#" >> $shellEnvFile
echo "# Setup local PSHELL install environment" >> $shellEnvFile
echo "#" >> $shellEnvFile
echo source $localDir/.pshellrc >> $shellEnvFile
fi
else
echo "To source enviromnent in all shells add 'source $localDir/.pshellrc' to your '.bashrc'"
fi
fi
else
# system wide install
if [ $(whoami) != "root" ]
then
echo "ERROR: Must be 'root' to do system install of this package,"
echo " run 'installPshell -l' for local install or 'installPshell -h' for usage"
exit 1
fi
binDir="/usr/bin"
includeDir="/usr/include"
pshellDir="/etc/pshell"
configDir="/etc/pshell/config"
batchDir="/etc/pshell/batch"
startupDir="/etc/pshell/startup"
man1Dir="/usr/share/man/man1"
man3Dir="/usr/share/man/man3"
if [ -d "/usr/lib64" ]
then
libDir="/usr/lib64"
else
libDir="/usr/lib"
fi
echo "Installing pshell files..."
echo "Installing libs..."
if [ ! -d $libDir/pshell ]
then
echo "Creating lib directory: $libDir"
mkdir $libDir/pshell
fi
echo "Copying libpshell-server-full.so to $libDir/pshell"
cp lib/libpshell-server-full.so $libDir/pshell/.
echo "Copying libpshell-server-full.a to $libDir/pshell"
cp lib/libpshell-server-full.a $libDir/pshell/.
echo "Copying libpshell-server-stub.so to $libDir/pshell"
cp lib/libpshell-server-stub.so $libDir/pshell/.
echo "Copying libpshell-server-stub.a to $libDir/pshell"
cp lib/libpshell-server-stub.a $libDir/pshell/.
echo "Copying libpshell-control.so to $libDir/pshell"
cp lib/libpshell-control.so $libDir/pshell/.
echo "Copying libpshell-control.a to $libDir/pshell"
cp lib/libpshell-control.a $libDir/pshell/.
echo "Setting softlink $libDir/libpshell-server to $libDir/pshell/libpshell-server-full"
if [ -e "$libDir/libpshell-server.so" ]
then
rm -f $libDir/libpshell-server.so
fi
ln -s $libDir/pshell/libpshell-server-full.so $libDir/libpshell-server.so
if [ -e "$libDir/libpshell-server.a" ]
then
rm -f $libDir/libpshell-server.a
fi
ln -s $libDir/pshell/libpshell-server-full.a $libDir/libpshell-server.a
echo "Setting softlink $libDir/libpshell-control to $libDir/pshell/libpshell-control"
if [ -e "$libDir/libpshell-control.so" ]
then
rm -f $libDir/libpshell-control.so
fi
ln -s $libDir/pshell/libpshell-control.so $libDir/libpshell-control.so
echo "Installing bins..."
echo "Copying pshell to $binDir"
cp bin/pshell $binDir/.
chmod +x $binDir/pshell
echo "Installing includes..."
echo "Copying PshellServer.h to $includeDir"
cp include/PshellServer.h $includeDir/.
echo "Copying PshellControl.h to $includeDir"
cp include/PshellControl.h $includeDir/.
echo "Copying TraceFilter.h to $includeDir"
cp include/TraceFilter.h $includeDir/.
echo "Copying TraceLog.h to $includeDir"
cp include/TraceLog.h $includeDir/.
if [ ! -d $pshellDir ]
then
echo "Creating pshell directory: $pshellDir"
mkdir $pshellDir
fi
echo "Installing conf files..."
if [ ! -d $configDir ]
then
echo "Creating conf directory: $configDir"
mkdir $configDir
fi
echo "Copying pshell-server.conf to $configDir"
cp config/pshell-server.conf $configDir/.
echo "Copying pshell-client.conf to $configDir"
cp config/pshell-client.conf $configDir/.
echo "Copying pshell-control.conf to $configDir"
cp config/pshell-control.conf $configDir/.
echo "Copying README to $configDir"
cp config/README $configDir/.
chmod 666 $configDir/*
echo "Installing batch files..."
if [ ! -d $batchDir ]
then
echo "Creating batch directory: $batchDir"
mkdir $batchDir
fi
#echo "Copying pshellServerDemo.batch to $batchDir"
#cp batch/pshellServerDemo.batch $batchDir/.
#echo "Copying traceFilterDemo.batch to $batchDir"
#cp batch/traceFilterDemo.batch $batchDir/.
echo "Copying README to $batchDir"
cp batch/README $batchDir/.
chmod 666 $batchDir/*
echo "Installing startup files..."
if [ ! -d $startupDir ]
then
echo "Creating startup directory: $startupDir"
mkdir $startupDir
fi
#echo "Copying pshellServerDemo.startup to $startupDir"
#cp startup/pshellServerDemo.startup $startupDir/.
#echo "Copying traceFilterDemo.startup to $startupDir"
#cp startup/traceFilterDemo.startup $startupDir/.
echo "Copying README to $startupDir"
cp startup/README $startupDir/.
chmod 666 $startupDir/*
echo "Installing manpages..."
echo "Copying pshell.1 to $man1Dir"
cp man/man1/pshell.1 $man1Dir/.
gzip -f $man1Dir/pshell.1
echo "Copying PshellControl.3 to $man3Dir"
cp man/man3/PshellControl.3 $man3Dir/.
gzip -f $man3Dir/PshellControl.3
echo "Copying PshellServer.3 to $man3Dir"
cp man/man3/PshellServer.3 $man3Dir/.
gzip -f $man3Dir/PshellServer.3
echo "Copying TraceFilter.3 to $man3Dir"
cp man/man3/TraceFilter.3 $man3Dir/.
gzip -f $man3Dir/TraceFilter.3
echo "Copying TraceLog.3 to $man3Dir"
cp man/man3/TraceLog.3 $man3Dir/.
gzip -f $man3Dir/TraceLog.3
fi