10 # TODO should this be BASEURL instead?
19 # TODO not sure if BUILD is the best name for this
29 ## Set up tmp, download, and install directories
32 WEBI_TMP=${WEBI_TMP:-"$(mktemp -d -t webinstall-${WEBI_PKG:-}.XXXXXXXX)"}
34 mkdir -p "$HOME/Downloads"
35 mkdir -p "$HOME/.local/bin"
36 mkdir -p "$HOME/.local/opt"
42 export WEBI_CURL="$(command -v curl)"
43 export WEBI_WGET="$(command -v wget)"
47 if [ -n "${1:-}" ]; then
50 if [ "error" == "$WEBI_CHANNEL" ]; then
51 echo "Could not find $WEBI_NAME v$WEBI_VERSION"
54 my_url="$WEBI_PKG_URL"
55 echo "Downloading $WEBI_NAME v$WEBI_VERSION"
57 if [ -n "${2:-}" ]; then
60 my_dl="$HOME/Downloads/$WEBI_PKG_FILE"
63 if [ -n "$WEBI_WGET" ]; then
64 # wget has resumable downloads
65 # TODO wget -c --content-disposition "$my_url"
67 wget -q --show-progress -c "$my_url" --user-agent="wget $WEBI_UA" -O "$my_dl"
68 if ! [ $? -eq 0 ]; then
69 echo "failed to download from $WEBI_PKG_URL"
74 # BSD curl is non-resumable, hence we don't bother
75 # TODO curl -fsSL --remote-name --remote-header-name --write-out "$my_url"
76 curl -fSL "$my_url" -H "User-Agent: curl $WEBI_UA" -o "$my_dl"
81 pushd "$WEBI_TMP" 2>&1 >/dev/null
82 if [ "tar" == "$WEBI_EXT" ]; then
83 echo "Extracting $HOME/Downloads/$WEBI_PKG_FILE"
84 tar xf "$HOME/Downloads/$WEBI_PKG_FILE"
85 elif [ "zip" == "$WEBI_EXT" ]; then
86 echo "Extracting $HOME/Downloads/$WEBI_PKG_FILE"
87 unzip "$HOME/Downloads/$WEBI_PKG_FILE"
88 elif [ "exe" == "$WEBI_EXT" ]; then
89 # do nothing (but don't leave an empty if block either)
91 elif [ "xz" == "$WEBI_EXT" ]; then
92 echo "Inflating $HOME/Downloads/$WEBI_PKG_FILE"
93 unxz -c "$HOME/Downloads/$WEBI_PKG_FILE" > $(basename "$WEBI_PKG_FILE")
96 echo "Failed to extract $HOME/Downloads/$WEBI_PKG_FILE"
103 # make sure that we don't recursively install pathman with webi
105 export PATH="$HOME/.local/bin:$PATH"
107 my_pathman=$(command -v pathman)
109 export PATH="$my_path"
111 # install pathman if not already installed
112 if [ -z "$my_pathman" ]; then
113 "$HOME/.local/bin/webi" pathman
114 "$HOME/.local/bin/pathman" add "$HOME/.local/bin"
115 export PATH="$HOME/.local/bin:$PATH"
118 # in case pathman was recently installed and the PATH not updated
119 "$HOME/.local/bin/pathman" add "$1"
124 ## BEGIN user-submited script
132 ## END user-submitted script