forked from Unidata/LDM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
58 lines (50 loc) · 1.79 KB
/
deploy.sh
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
# Deploys the LDM to a remote host. Assumes that this script is in the top-level
# development source-directory and that the necessary files already exist.
#
# Usage:
# $0 host [configOpts]
#
# where:
# host Name of the remote computer on which to deploy the LDM
# configOpts Optional configure(1) script options
set -e # terminate on error
host=${1:?Host name not specified}
configOpts=$2
# For convenience, make the directory that contains this script be the current
# working directory.
cd `dirname $0`
# Copy the source-distribution to the remote host.
#
scp $SOURCE_DISTRO_NAME $USER_NAME@$host:
trap "ssh -T $USER_NAME@$host rm -f $SOURCE_DISTRO_NAME; `trap -p ERR`" ERR
# bash(1) is explicitly used for remote executions because 1) not all LDM users
# have the same user-shell; and 2) not all sh(1)-s behave the same -- especially
# in the handling of substitutions, quotes, and escapes.
# As the LDM user on the remote host, unpack, build, and install the package.
#
ssh -T $USER_NAME@$host bash --login <<EOF
set -x -e
gunzip -c $SOURCE_DISTRO_NAME | (mkdir -p $PKG_ID &&
cd $PKG_ID && tar -xf - && rm -rf src && mv -f $PKG_ID src)
rm $SOURCE_DISTRO_NAME
cd $RELPATH_DISTRO_SOURCE_DIR
./configure --disable-root-actions ${configOpts} CFLAGS=-g
make install
EOF
# As the superuser on the remote host, perform the root actions.
#
ssh -T root@$host bash --login <<EOF
set -x -e
ldmHome=\`awk -F: '\$1~/^$USER_NAME\$/{print \$6}' /etc/passwd\`
cd \$ldmHome/$RELPATH_DISTRO_SOURCE_DIR
make root-actions
EOF
# As the LDM user on the remote host, execute the new package.
#
ssh -T $USER_NAME@$host bash --login <<EOF
set -x -e
ldmadmin isrunning && ldmadmin stop
rm -f runtime
ln -s $PKG_ID runtime
ldmadmin start
EOF