use package name for tmp folder
[webi-installers/.git] / webi / template.bash
index 8c42305ff9fdc953628fd431f1841e35c722a07f..651d5bd238bf7bab399e3723a9335579cb16ad49 100644 (file)
@@ -27,7 +27,7 @@ set -u
 ## Set up tmp, download, and install directories
 ##
 
-WEBI_TMP=${WEBI_TMP:-"$(mktemp -d -t webinstall-go.XXXXXXXX)"}
+WEBI_TMP=${WEBI_TMP:-"$(mktemp -d -t webinstall-${WEBI_PKG:-}.XXXXXXXX)"}
 
 mkdir -p "$HOME/Downloads"
 mkdir -p "$HOME/.local/bin"
@@ -45,20 +45,26 @@ webi_download() {
     if [ -n "${1:-}" ]; then
         my_url="$1"
     else
+        if [ "error" == "$WEBI_CHANNEL" ]; then
+            echo "Could not find $WEBI_NAME v$WEBI_VERSION"
+            exit 1
+        fi
         my_url="$WEBI_PKG_URL"
         echo "Downloading $WEBI_NAME v$WEBI_VERSION"
     fi
     if [ -n "${2:-}" ]; then
         my_dl="$2"
     else
-        my_dl="$WEBI_PKG_FILE"
+        my_dl="$HOME/Downloads/$WEBI_PKG_FILE"
     fi
 
     if [ -n "$WEBI_WGET" ]; then
         # wget has resumable downloads
-        wget -c "$my_url" --user-agent="wget $WEBI_UA" -O "$my_dl"
+        # TODO wget -c --content-disposition "$my_url"
+        wget -q --show-progress -c "$my_url" --user-agent="wget $WEBI_UA" -O "$my_dl"
     else
         # BSD curl is non-resumable, hence we don't bother
+        # TODO curl -fsSL --remote-name --remote-header-name --write-out "$my_url"
         curl -fSL "$my_url" -H "User-Agent: curl $WEBI_UA" -o "$my_dl"
     fi
 }
@@ -95,7 +101,8 @@ webi_path_add() {
         export PATH="$HOME/.local/bin:$PATH"
     fi
 
-    pathman add "$1"
+    # in case pathman was recently installed and the PATH not updated
+    "$HOME/.local/bin/pathman" add "$1"
 }
 
 ##