10 # TODO should this be BASEURL instead?
18 # TODO not sure if BUILD is the best name for this
27 ## Set up tmp, download, and install directories
30 WEBI_TMP=${WEBI_TMP:-"$(mktemp -d -t webinstall-go.XXXXXXXX)"}
32 mkdir -p "$HOME/Downloads"
33 mkdir -p "$HOME/.local/bin"
34 mkdir -p "$HOME/.local/opt"
40 export WEBI_CURL="$(command -v curl)"
41 export WEBI_WGET="$(command -v wget)"
45 if [ -n "${1:-}" ]; then
48 my_url="$WEBI_PKG_URL"
49 echo "Downloading $WEBI_NAME v$WEBI_VERSION"
51 if [ -n "${2:-}" ]; then
54 my_dl="$HOME/Downloads/$WEBI_PKG_FILE"
57 if [ -n "$WEBI_WGET" ]; then
58 # wget has resumable downloads
59 # TODO wget -c --content-disposition "$my_url"
60 wget -q --show-progress -c "$my_url" --user-agent="wget $WEBI_UA" -O "$my_dl"
62 # BSD curl is non-resumable, hence we don't bother
63 # TODO curl -fsSL --remote-name --remote-header-name --write-out "$my_url"
64 curl -fSL "$my_url" -H "User-Agent: curl $WEBI_UA" -o "$my_dl"
69 pushd "$WEBI_TMP" 2>&1 >/dev/null
70 if [ "tar" == "$WEBI_EXT" ]; then
71 echo "Extracting $HOME/Downloads/$WEBI_PKG_FILE"
72 tar xf "$HOME/Downloads/$WEBI_PKG_FILE"
73 elif [ "zip" == "$WEBI_EXT" ]; then
74 echo "Extracting $HOME/Downloads/$WEBI_PKG_FILE"
75 unzip "$HOME/Downloads/$WEBI_PKG_FILE"
78 echo "Failed to extract $HOME/Downloads/$WEBI_PKG_FILE"
85 # make sure that we don't recursively install pathman with webi
87 export PATH="$HOME/.local/bin:$PATH"
89 my_pathman=$(command -v pathman)
91 export PATH="$my_path"
93 # install pathman if not already installed
94 if [ -z "$my_pathman" ]; then
95 "$HOME/.local/bin/webi" pathman
96 "$HOME/.local/bin/pathman" add "$HOME/.local/bin"
97 export PATH="$HOME/.local/bin:$PATH"
100 # in case pathman was recently installed and the PATH not updated
101 "$HOME/.local/bin/pathman" add "$1"
106 ## BEGIN user-submited script
114 ## END user-submitted script