-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·153 lines (127 loc) · 3.87 KB
/
install.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
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
#!/bin/bash
set -e
VERSION=v0.0.2
CLIENT=sge
INSTALL_PREFIX=${INSTALL_PREFIX:-/usr/local/bin}
GHPATH="https://github.com/nimbix/jarvice-hpc/releases/download"
GOOS="linux"
GOARCH="amd64"
CLI_NAME="jarvice"
DEBUG="&> /dev/null"
function usage {
cat <<EOF
Usage:
$0 [options]
Options:
--version <version> Version to install (Default: $VERSION)
--client <client> HPC client to install (Default: $CLIENT)
--build Build client from source
--keep-cli Keep CLI binary used for installation
--install-prefix Path for installation (Default: $INSTALL_PREFIX)
--os Target os <linux | darwin | windows>
--debug Enable debug logging
--no-install Skip install
Example:
$0 --version $VERSION
EOF
}
while [ $# -gt 0 ]; do
case $1 in
--help)
usage
exit 0
;;
--version)
VERSION=$2
shift; shift
;;
--client)
CLIENT=$2
shift; shift
;;
--build)
BUILD=true
shift
;;
--keep-cli)
KEEP_CLI=true
shift
;;
--install-prefix)
INSTALL_PREFIX=$2
shift; shift
;;
--os)
GOOS=$2
shift; shift
;;
--debug)
unset DEBUG
shift
;;
--no-install)
NOINSTALL=true
shift
;;
*)
usage
exit 1
;;
esac
done
if [ "$BUILD" = true ]; then
[ ! -d "$CLIENT" ] && echo "$CLIENT directory does not exists" && exit 1
command -v docker &> /dev/null || (echo "docker missing" && exit 1)
source $CLIENT/$CLIENT-cli
cp *.go $CLIENT
rm $CLIENT/template.go || true
echo "BUILDING $CLIENT FOR $GOOS"
GO_BUILD_OPT="-v -o ${CLI_NAME}-${CLIENT} -a -ldflags '-extldflags -static -s -w'"
docker run --rm -v "$PWD":/usr/src/jarvice-hpc \
-w /usr/src/jarvice-hpc \
-e GOOS=${GOOS} \
-e CGO_ENABLED=0 \
golang:1.19 \
/bin/bash -c "mkdir -p /go/src/jarvice.io/jarvice-hpc \
&& ln -s /usr/src/jarvice-hpc/core /go/src/jarvice.io/jarvice-hpc/core \
&& ln -s /usr/src/jarvice-hpc/logger /go/src/jarvice.io/jarvice-hpc/logger \
&& touch /usr/src/jarvice-hpc/logger/go.mod \
&& touch /usr/src/jarvice-hpc/core/go.mod \
&& go build $GO_BUILD_OPT $CLIENT/*.go ${DEBUG}"
echo "BUILD COMPLETE"
for file in `ls *.go`; do
rm -f $CLIENT/$file
done
rm -f core/go.mod logger/go.mod
else
command -v wget &> /dev/null || (echo "wget missing" && exit 1)
WD=`pwd`
WORKDIR=`mktemp -d`
cd "${WORKDIR}"
wget "${GHPATH}/${VERSION}/SHA256SUMS" ${DEBUG} \
|| (echo "$VERSION SHA256SUMS Not Found" && exit 1)
wget "${GHPATH}/${VERSION}/${CLI_NAME}_${VERSION}_${GOOS}_${GOARCH}.tar.gz" ${DEBUG} \
|| (echo "$VERSION archive Not Found" && exit 1)
CHECKSUM="-c SHA256SUMS"
sha256sum ${CHECKSUM} &> /dev/null || shasum -a 256 ${CHECKSUM} &> /dev/null \
|| (echo "Checksum failed" && exit 1)
tar -xvf "${CLI_NAME}_${VERSION}_${GOOS}_${GOARCH}.tar.gz" ${DEBUG}
[ -e "$CLIENT-cli" ] || (echo "Missing $CLIENT-cli" && exit 1)
source "$CLIENT-cli"
cp ${CLI_NAME}-* $WD
cd $WD
fi
[ ! "$BUILD" ] && rm -r "${WORKDIR}"
[ "${NOINSTALL}" ] && exit 0
if [ -z "$COMS" ]; then
usage
exit 1
fi
mkdir -p ${INSTALL_PREFIX}
echo "INSTALLING $CLIENT TO $INSTALL_PREFIX"
cp ${CLI_NAME}-${CLIENT} ${INSTALL_PREFIX}/${CLI_NAME}
for com in $COMS; do
ln -fs ${INSTALL_PREFIX}/${CLI_NAME} ${INSTALL_PREFIX}/$com
done
[ ! "$KEEP_CLI" ] && rm ${CLI_NAME}-*
echo "INSTALLATION COMPLETE"