-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvcc
More file actions
executable file
·134 lines (131 loc) · 3.81 KB
/
vcc
File metadata and controls
executable file
·134 lines (131 loc) · 3.81 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
#!/bin/sh
# the vcc helper script
VCCIMAGE="hpchud/vcc-torque:latest"
SCRIPTVERSION="master"
SCRIPTURL="https://raw.githubusercontent.com/hpchud/vccjs/$SCRIPTVERSION/vcc"
error_exit()
{
echo "An error occurred: $@"
echo "Check proxy settings if applicable."
echo 'If the script is installed in a system folder, e.g. /usr/bin, you might need root privileges to update it.'
exit 1
}
if test "$1" = 'update'; then
echo "Updating VCC tool..."
echo ""
# dont assume we are in /usr/bin
# if mktemp is available, use that and replace the script where it is
# otherwise, download to current folder and replace
if type "mktemp" > /dev/null; then
UPDATEFILE="`mktemp`"
else
UPDATEFILE="`pwd`/vcc-new"
fi
CURRENTFILE="$0"
wget -O $UPDATEFILE $SCRIPTURL 2>&1 >/dev/null || error_exit "Could not download script"
# create a backup of the old script
cp $CURRENTFILE ${CURRENTFILE}.bak || error_exit "Could not backup current vcc script"
# move the updated version to replace the current version
echo "Replacing $CURRENTFILE with $UPDATEFILE..."
mv $UPDATEFILE $CURRENTFILE || error_exit "Could not replace current vcc script"
chmod 755 $CURRENTFILE || error_exit "Could not set mode 755 on the vcc script"
echo "The VCC tool has been updated."
echo "Pulling Docker images"
echo ""
docker pull $VCCIMAGE
if test "$?" = '0'; then
echo "Images downloaded/updated successfully."
else
echo 'There was a problem downloading the images. Check proxy settings.'
exit 1
fi
echo "If both the vcc tool and the images have been updated, you will need to run the update command twice."
exit 0
elif test "$1" = 'shell'; then
nids="`docker ps | grep $VCCIMAGE | awk '{print $1}' | wc -l`"
if test "$nids" = '1'; then
id="`docker ps | grep $VCCIMAGE | awk '{print $1}'`"
echo ""
echo ""
echo "*********"
echo "You are now entering the VCC shell for $id"
echo "To exit, type \`exit\` or press CTRL+D"
echo "*********"
echo ""
echo ""
docker exec -it $id /bin/bash
elif test "$nids" = '0'; then
echo "There are no containers running."
echo "Maybe you need to run \`docker start <id>\`?"
echo ""
echo "(to set up the lab testing environment, run \`vcc setuplab\`)"
else
echo "Please choose which container to enter:"
echo "(CTRL+C to cancel)"
echo ""
docker inspect --format='{{.Name}} {{.Id}}' $(docker ps -q --no-trunc) | tr '/' ' '
echo ""
echo -n "Name or Id : "
read id
echo ""
echo ""
echo "*********"
echo "You are now entering the VCC shell for $id"
echo "To exit, type \`exit\` or press CTRL+D"
echo "*********"
echo ""
echo ""
docker exec -it $id /bin/bash
fi
exit 0
elif test "$1" = 'krm'; then
docker kill $2
docker rm $2
elif test "$1" = 'setuplab'; then
docker run -d --name=discovery hpchud/vcc-discovery
docker run -d --link discovery:discovery \
--name=headnode \
-v /cluster:/cluster \
-p 2222:2222 \
$VCCIMAGE \
--cluster=testlab \
--storage-host=discovery \
--storage-port=2379 \
--service=headnode
docker run -d --link discovery:discovery \
--name=workernode \
-v /cluster:/cluster \
$VCCIMAGE \
--cluster=testlab \
--storage-host=discovery \
--storage-port=2379 \
--service=workernode
docker start headnode
docker start workernode
elif test "$1" = 'setupheadnode'; then
docker run -d --net=host --restart=always --name=discovery hpchud/vcc-discovery
docker run -d \
--name=headnode \
-v /cluster:/cluster \
--net=host \
--privileged \
$VCCIMAGE \
--cluster=testlab \
--storage-host=127.0.0.1 \
--storage-port=2379 \
--service=headnode
docker start headnode
elif test "$1" = 'setupworkernode'; then
docker run -d \
--name=workernode \
--net=host \
--privileged \
$VCCIMAGE \
--cluster=testlab \
--storage-host=$2 \
--storage-port=2379 \
--service=workernode
docker start workernode
else
docker run -d $DOCKER_ARGS $VCCIMAGE $@
fi