-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare
executable file
·36 lines (27 loc) · 1.47 KB
/
prepare
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
#!/usr/bin/env bash
export PACKAGE_BIN=/usr/src/tools
export SUDOCMD=$(which sudo)
export CURDIR=$(pwd)
export RUNDIR=$(dirname ${0})
export GOROOT=$(echo ${GOROOT})
export GOPATH=$(echo ${GOPATH})
GOPATH=${GOPATH}
[[ "${GOPATH}" != "" ]] || export GOPATH=/go
mkdir -vp ${GOPATH}/src ${GOPATH}/bin ${GOPATH}/pkg || ${SUDOCMD} mkdir -vp ${GOPATH}/src ${GOPATH}/bin ${GOPATH}/pkg || exit 1
chown -R ${USER}:users ${GOPATH} || ${SUDOCMD} chown -R ${USER}:users ${GOPATH} || exit 1
chmod -R ug+rw ${GOPATH} || ${SUDOCMD} chmod -R ug+rw ${GOPATH} || exit 1
[[ -e ${PACKAGE_BIN} ]] || ${SUDOCMD} mkdir -vp ${PACKAGE_BIN} || exit 1
[[ "${USER}" = "root" ]] || [[ "${UID}" = "0" ]] || ${SUDOCMD} chown -vR ${USER}:users ${PACKAGE_BIN} || exit 1
if [[ "$(which apt-get)" = "" ]]
then
${SUDOCMD} $(which apk) add --no-cache wget curl openssl git tar jq || exit 1
else
DEBIAN_FRONTEND=noninteractive ${SUDOCMD} $(which apt-get) --assume-yes update || exit 1
DEBIAN_FRONTEND=noninteractive ${SUDOCMD} $(which apt-get) --assume-yes -o Dpkg::Options::="--force-confold" --no-install-recommends install wget curl openssl git tar jq || exit 1
fi
echo -e "\n\n\n\t >>> get last release of 'github.com/snyk/snyk'... "
${RUNDIR}/github_get_last_release 'snyk/snyk' 'linux' 'sha|arm' || exit 1
echo -e "\n\n\n\t >>> run gotools... "
${RUNDIR}/gotools || exit 1
${SUDOCMD} chmod -v +x ${PACKAGE_BIN}/*
ln -svf ${PACKAGE_BIN}/* /usr/local/bin/ || ${SUDOCMD} ln -svf ${PACKAGE_BIN}/* /usr/local/bin/ || exit 1