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-${WEBI_PKG:-}.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 if [ "error" == "$WEBI_CHANNEL" ]; then
49 echo "Could not find $WEBI_NAME v$WEBI_VERSION"
52 my_url="$WEBI_PKG_URL"
53 echo "Downloading $WEBI_NAME v$WEBI_VERSION"
55 if [ -n "${2:-}" ]; then
58 my_dl="$HOME/Downloads/$WEBI_PKG_FILE"
61 if [ -n "$WEBI_WGET" ]; then
62 # wget has resumable downloads
63 # TODO wget -c --content-disposition "$my_url"
64 wget -q --show-progress -c "$my_url" --user-agent="wget $WEBI_UA" -O "$my_dl"
66 # BSD curl is non-resumable, hence we don't bother
67 # TODO curl -fsSL --remote-name --remote-header-name --write-out "$my_url"
68 curl -fSL "$my_url" -H "User-Agent: curl $WEBI_UA" -o "$my_dl"
73 pushd "$WEBI_TMP" 2>&1 >/dev/null
74 if [ "tar" == "$WEBI_EXT" ]; then
75 echo "Extracting $HOME/Downloads/$WEBI_PKG_FILE"
76 tar xf "$HOME/Downloads/$WEBI_PKG_FILE"
77 elif [ "zip" == "$WEBI_EXT" ]; then
78 echo "Extracting $HOME/Downloads/$WEBI_PKG_FILE"
79 unzip "$HOME/Downloads/$WEBI_PKG_FILE"
82 echo "Failed to extract $HOME/Downloads/$WEBI_PKG_FILE"
89 # make sure that we don't recursively install pathman with webi
91 export PATH="$HOME/.local/bin:$PATH"
93 my_pathman=$(command -v pathman)
95 export PATH="$my_path"
97 # install pathman if not already installed
98 if [ -z "$my_pathman" ]; then
99 "$HOME/.local/bin/webi" pathman
100 "$HOME/.local/bin/pathman" add "$HOME/.local/bin"
101 export PATH="$HOME/.local/bin:$PATH"
104 # in case pathman was recently installed and the PATH not updated
105 "$HOME/.local/bin/pathman" add "$1"
110 ## BEGIN user-submited script
118 ## END user-submitted script