| 1 |
#!/bin/csh -f |
| 2 |
############################################################################ |
| 3 |
############################################################################ |
| 4 |
## File: xcl |
| 5 |
# This file is part of the ACEDB package |
| 6 |
# Author: J Thierry-Mieg, ([email protected]) |
| 7 |
# Copyright (C) R.Dubin & Thierry-Mieg, 1997 |
| 8 |
#------------------------------------------------------------------- |
| 9 |
# Usage: xcl host port |
| 10 |
# example: xcl beta 20000100 |
| 11 |
#------------------------------------------------------------------- |
| 12 |
# Description: |
| 13 |
# Launches a graphic acedb xace working as a client on an ace-server |
| 14 |
# |
| 15 |
# $Id: xcl,v 1.13 1998/04/24 13:45:47 mieg Exp $ |
| 16 |
############################################################################ |
| 17 |
############################################################################ |
| 18 |
## Check for correct the existence of the server |
| 19 |
|
| 20 |
setenv ici `pwd` |
| 21 |
|
| 22 |
if ($1 == "") goto usage |
| 23 |
|
| 24 |
setenv PORT 536871169 |
| 25 |
if ($2 != "") setenv PORT $2 |
| 26 |
|
| 27 |
############################################################################ |
| 28 |
# Check the client_update directory |
| 29 |
|
| 30 |
if (-e clientUpdate) then |
| 31 |
setenv wcu `wc clientUpdate | awk '{print $1}'` |
| 32 |
if ($wcu != "0") then |
| 33 |
echo ' ' |
| 34 |
echo 'ERROR' |
| 35 |
echo There exist a file './clientUpdate' |
| 36 |
echo ' ' |
| 37 |
echo Either a separate client code is already running in this direstoty |
| 38 |
echo or the last one failed to complete |
| 39 |
echo possibly, some data were not transmitted bsck to the server |
| 40 |
echo Please verify the content of the `pwd`/clientUpdate |
| 41 |
echo Then remove it and restart |
| 42 |
echo ' ' |
| 43 |
exit 1 |
| 44 |
endif |
| 45 |
endif |
| 46 |
|
| 47 |
touch clientUpdate |
| 48 |
|
| 49 |
############################################################################ |
| 50 |
if (-x /bin/env) then |
| 51 |
setenv BINENV /bin/env |
| 52 |
else |
| 53 |
if (-x /usr/bin/env) setenv BINENV /usr/bin/env |
| 54 |
else setenv BINENV env |
| 55 |
endif |
| 56 |
|
| 57 |
echo trying to connect to aceserver $1 $PORT |
| 58 |
|
| 59 |
$BINENV saceclient $1 -port $PORT -passwd edgrif 38a6557860893d95c7e738c0e5cd233d << END >! ___getserver___ || goto noconnect |
| 60 |
status |
| 61 |
END |
| 62 |
|
| 63 |
setenv SERVER_DIR `grep directory ___getserver___ | awk '{dd=$4; i = length(dd); print substr(dd,1,i-2);}'` |
| 64 |
\rm -rf ___getserver___ |
| 65 |
echo Successful connection to aceserver $1 $PORT |
| 66 |
echo Server directory: $SERVER_DIR |
| 67 |
|
| 68 |
############################################################################ |
| 69 |
## Without write access, simply start xace |
| 70 |
|
| 71 |
|
| 72 |
############################################################################ |
| 73 |
# Create a local copy of the wspec directory |
| 74 |
|
| 75 |
cd $ici |
| 76 |
|
| 77 |
if !(-d wspec.xclient) then |
| 78 |
mkdir wspec.xclient |
| 79 |
touch wspec.xclient/XCLIENT.$1.$PORT |
| 80 |
\rm -rf wspec.xclient/server.wrm |
| 81 |
echo EXTERNAL_SERVER $1 >! wspec.xclient/server.wrm |
| 82 |
echo EXTERNAL_PORT $PORT >> wspec.xclient/server.wrm |
| 83 |
setenv ADMIN `whoami` |
| 84 |
echo ' ' |
| 85 |
echo " I add $ADMIN to the password file" |
| 86 |
echo ' ' >! wspec.xclient/passwd.wrm |
| 87 |
echo -n $ADMIN >> wspec.xclient/passwd.wrm |
| 88 |
echo ' // Login name of the user starting the xclient' >> wspec.xclient/passwd.wrm |
| 89 |
echo ' ' |
| 90 |
echo 'I uncomment NOLOCK, in passwd.wrm because locking is missing on many machines' |
| 91 |
echo 'NOLOCK // uncommented by wtools/xcl' >> wspec.xclient/passwd.wrm |
| 92 |
echo ' ' >> wspec.xclient/passwd.wrm |
| 93 |
endif |
| 94 |
|
| 95 |
############################################################################ |
| 96 |
# Verify that we run from the correct server |
| 97 |
|
| 98 |
check.wspec: |
| 99 |
cd $ici |
| 100 |
if (-e wspec) then |
| 101 |
cd wspec |
| 102 |
if !(-e XCLIENT.$1.$PORT) then |
| 103 |
echo Cannot find file wspec/XCLIENT.$1.$PORT |
| 104 |
echo This means that the local wspec directory does not |
| 105 |
echo correspond to the server invoked |
| 106 |
echo I quit |
| 107 |
goto usage |
| 108 |
endif |
| 109 |
cd $ici |
| 110 |
else |
| 111 |
ln -s wspec.xclient wspec |
| 112 |
endif |
| 113 |
|
| 114 |
echo local wspec directory verified |
| 115 |
############################################################################ |
| 116 |
# import the current wspec from the server |
| 117 |
|
| 118 |
cd $ici |
| 119 |
$BINENV saceclient $1 -port $PORT -passwd edgrif 38a6557860893d95c7e738c0e5cd233d << END >! wspec/___getspec___ || goto noconnect |
| 120 |
wspec |
| 121 |
END |
| 122 |
cd wspec |
| 123 |
chmod 644 ___getspec___ |
| 124 |
uudecode ___getspec___ |
| 125 |
chmod 644 server.wspec.tar |
| 126 |
tar xf server.wspec.tar |
| 127 |
\rm -rf ___getspec___ |
| 128 |
|
| 129 |
echo current models imported |
| 130 |
############################################################################ |
| 131 |
# Possibly, reinitialise and seed the database |
| 132 |
|
| 133 |
cd $ici |
| 134 |
if ! (-d database) mkdir database |
| 135 |
|
| 136 |
setenv ACEDB `pwd` |
| 137 |
setenv ACEDB_NO_BANNER 1 |
| 138 |
|
| 139 |
if !(-e database/ACEDB.wrm) then |
| 140 |
echo Initialising a local database, please wait |
| 141 |
$BINENV tace << END > /dev/null || goto notace |
| 142 |
y // do reinitialise |
| 143 |
pparse $SERVER_DIR/xclient.data.ace |
| 144 |
save |
| 145 |
quit |
| 146 |
END |
| 147 |
else |
| 148 |
echo Verifying the models, please wait |
| 149 |
$BINENV tace > /dev/null << END || goto notace |
| 150 |
read-models |
| 151 |
save |
| 152 |
quit |
| 153 |
END |
| 154 |
endif |
| 155 |
|
| 156 |
if !(-e database/ACEDB.wrm) then |
| 157 |
echo Sorry, I was not able to create a local database |
| 158 |
echo I quit |
| 159 |
goto usage |
| 160 |
endif |
| 161 |
|
| 162 |
############################################################################ |
| 163 |
# Start the graphic interface |
| 164 |
|
| 165 |
echo Connected to aceserver: $1 $PORT |
| 166 |
echo Starting the xaceclient graphic interface |
| 167 |
|
| 168 |
if ($3 == "gcc") then |
| 169 |
cd ~/ace |
| 170 |
gdb bin.$ACEDB_MACHINE/sxaceclient |
| 171 |
else |
| 172 |
$BINENV sxaceclient || goto noxaceclient |
| 173 |
endif |
| 174 |
|
| 175 |
cd $ici |
| 176 |
echo Graphic session finished, |
| 177 |
if (-e clientUpdate) then |
| 178 |
setenv nb `wc clientUpdate | awk '{print $1}'` |
| 179 |
if ($nb == "0") then |
| 180 |
\rm clientUpdate |
| 181 |
endif |
| 182 |
endif |
| 183 |
|
| 184 |
if (-e clientUpdate.done) then |
| 185 |
echo '########################################' |
| 186 |
echo '### The following data were sent to the server' |
| 187 |
echo |
| 188 |
cat clientUpdate.done |
| 189 |
echo '########################################' |
| 190 |
echo |
| 191 |
endif |
| 192 |
if (-e clientUpdate) then |
| 193 |
echo '########################################' |
| 194 |
echo '### The following editions were not saved to the server' |
| 195 |
echo |
| 196 |
cat clientUpdate |
| 197 |
echo |
| 198 |
echo '########################################' |
| 199 |
ask: |
| 200 |
echo should I save these additional editions on the server, please answer yes/no |
| 201 |
switch("$<") |
| 202 |
case "yes" |
| 203 |
echo I try to save to host $1 port $PORT |
| 204 |
$BINENV aceclient $1 -port $PORT -ace_in < clientUpdate || goto noconnect |
| 205 |
touch clientUpdate.done |
| 206 |
cat clientUpdate >> clientUpdate.done |
| 207 |
breaksw |
| 208 |
case "no" |
| 209 |
echo ok, i do not save your editions, but i keep them temporarilly |
| 210 |
echo as $ici/clientUpdate.old.ace |
| 211 |
\mv clientUpdate clientUpdate.notDone |
| 212 |
breaksw |
| 213 |
default: |
| 214 |
echo please answer yes or no |
| 215 |
goto ask |
| 216 |
endsw |
| 217 |
endif |
| 218 |
echo |
| 219 |
echo done |
| 220 |
exit 0 |
| 221 |
|
| 222 |
############################################################################ |
| 223 |
## Usage |
| 224 |
notace: |
| 225 |
echo 'Sorry, tace step failed, this maybe because tace is not in current path or because tace itself failed.' |
| 226 |
echo ' ' |
| 227 |
goto usage |
| 228 |
|
| 229 |
noxaceclient: |
| 230 |
echo 'Sorry, xaceclient step failed, this maybe because xaceclient is not in current path or because xaceclient itself failed.' |
| 231 |
echo ' ' |
| 232 |
goto usage |
| 233 |
|
| 234 |
noconnect: |
| 235 |
echo cannot connect to $1 $PORT sorry |
| 236 |
if (-e ___getserver___) then |
| 237 |
echo error message: |
| 238 |
cat ___getserver___ |
| 239 |
\rm -rf ___getserver___ |
| 240 |
endif |
| 241 |
usage: |
| 242 |
echo 'Usage: xcl host port' |
| 243 |
echo 'example: xcl beta.crbm.cnrs-mop.fr 20000100' |
| 244 |
exit 1 |
| 245 |
|
| 246 |
############################################################################ |
| 247 |
############################################################################ |
| 248 |
|