Files
mgmt/misc/make-path.sh
Karpfen 7e8ced534f misc: Use /usr/bin/env for a more generic shebang
Use path based SHELL in Makefiles. It was suggested that this is a
better solution for make for cases when there is no /usr/bin/env.

See: https://github.com/purpleidea/mgmt/pull/694#discussion_r1015596204
2025-03-22 14:53:21 -04:00

49 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# setup a few environment path values
if ! env | grep -q '^GOPATH='; then
export GOPATH="$HOME/gopath/"
mkdir "$GOPATH"
if ! grep -q '^export GOPATH=' ~/.bashrc; then
echo "export GOPATH=~/gopath/" >> ~/.bashrc
fi
echo "setting go path to: $GOPATH"
fi
echo "gopath is: $GOPATH"
# some versions of golang apparently require this to run go get :(
if ! env | grep -q '^GOBIN='; then
export GOBIN="${GOPATH}bin/"
mkdir "$GOBIN"
if ! grep -q '^export GOBIN=' ~/.bashrc; then
echo 'export GOBIN="${GOPATH}bin/"' >> ~/.bashrc
fi
echo "setting go bin to: $GOBIN"
fi
echo "gobin is: $GOBIN"
# add gobin to $PATH
if ! env | grep '^PATH=' | grep -q "$GOBIN"; then
if ! grep -q '^export PATH="'"${GOBIN}"':${PATH}"' ~/.bashrc; then
echo 'export PATH="'"${GOBIN}"':${PATH}"' >> ~/.bashrc
fi
export PATH="${GOBIN}:${PATH}"
echo "setting path to: $PATH"
fi
echo "path is: $PATH"
# add ~/bin/ to $PATH
if ! env | grep '^PATH=' | grep -q "$HOME/bin"; then
mkdir -p "${HOME}/bin"
if ! grep -q '^export PATH="'"${HOME}/bin"':${PATH}"' ~/.bashrc; then
echo 'export PATH="'"${HOME}/bin"':${PATH}"' >> ~/.bashrc
fi
export PATH="${HOME}/bin:${PATH}"
echo "setting path to: $PATH"
fi
echo "path is: $PATH"