10 # TODO should this be BASEURL instead?
18 # TODO not sure if BUILD is the best name for this
28 ## Set up tmp, download, and install directories
31 WEBI_TMP=${WEBI_TMP:-"$(mktemp -d -t webinstall-${WEBI_PKG:-}.XXXXXXXX)"}
33 mkdir -p "$HOME/Downloads"
34 mkdir -p "$HOME/.local/bin"
35 mkdir -p "$HOME/.local/opt"
41 export WEBI_CURL="$(command -v curl)"
42 export WEBI_WGET="$(command -v wget)"
46 if [ -n "${1:-}" ]; then
49 if [ "error" == "$WEBI_CHANNEL" ]; then
50 echo "Could not find $WEBI_NAME v$WEBI_VERSION"
53 my_url="$WEBI_PKG_URL"
54 echo "Downloading $WEBI_NAME v$WEBI_VERSION"
56 if [ -n "${2:-}" ]; then
59 my_dl="$HOME/Downloads/$WEBI_PKG_FILE"
62 if [ -n "$WEBI_WGET" ]; then
63 # wget has resumable downloads
64 # TODO wget -c --content-disposition "$my_url"
66 wget -q --show-progress -c "$my_url" --user-agent="wget $WEBI_UA" -O "$my_dl"
67 if ! [ $? -eq 0 ]; then
68 echo "failed to download from $WEBI_PKG_URL"
73 # BSD curl is non-resumable, hence we don't bother
74 # TODO curl -fsSL --remote-name --remote-header-name --write-out "$my_url"
75 curl -fSL "$my_url" -H "User-Agent: curl $WEBI_UA" -o "$my_dl"
80 pushd "$WEBI_TMP" 2>&1 >/dev/null
81 if [ "tar" == "$WEBI_EXT" ]; then
82 echo "Extracting $HOME/Downloads/$WEBI_PKG_FILE"
83 tar xf "$HOME/Downloads/$WEBI_PKG_FILE"
84 elif [ "zip" == "$WEBI_EXT" ]; then
85 echo "Extracting $HOME/Downloads/$WEBI_PKG_FILE"
86 unzip "$HOME/Downloads/$WEBI_PKG_FILE"
87 elif [ "exe" == "$WEBI_EXT" ]; then
88 # do nothing (but don't leave an empty if block either)
90 elif [ "xz" == "$WEBI_EXT" ]; then
91 echo "Inflating $HOME/Downloads/$WEBI_PKG_FILE"
92 unxz -c "$HOME/Downloads/$WEBI_PKG_FILE" > $(basename "$WEBI_PKG_FILE")
95 echo "Failed to extract $HOME/Downloads/$WEBI_PKG_FILE"
102 # make sure that we don't recursively install pathman with webi
104 export PATH="$HOME/.local/bin:$PATH"
106 my_pathman=$(command -v pathman)
108 export PATH="$my_path"
110 # install pathman if not already installed
111 if [ -z "$my_pathman" ]; then
112 "$HOME/.local/bin/webi" pathman
113 "$HOME/.local/bin/pathman" add "$HOME/.local/bin"
114 export PATH="$HOME/.local/bin:$PATH"
117 # in case pathman was recently installed and the PATH not updated
118 "$HOME/.local/bin/pathman" add "$1"
123 ## BEGIN user-submited script
131 ## END user-submitted script