9 #WEBI_HOST=https://webinstall.dev
12 mkdir -p "$HOME/.local/bin"
14 cat << EOF > "$HOME/.local/bin/webi"
22 export WEBI_TIMESTAMP=\$(date +%F_%H-%M-%S)
23 export _webi_tmp="\${_webi_tmp:-\$(mktemp -d -t webi-\$WEBI_TIMESTAMP.XXXXXXXX)}"
25 if [ -n "\${_WEBI_PARENT:-}" ]; then
26 export _WEBI_CHILD=true
30 export _WEBI_PARENT=true
33 ## Detect acceptable package formats
38 # NOTE: the order here is least favorable to most favorable
39 if [ -n "\$(command -v pkgutil)" ]; then
42 # disable this check for the sake of building the macOS installer on Linux
43 #if [ -n "\$(command -v diskutil)" ]; then
44 # note: could also detect via hdiutil
47 if [ -n "\$(command -v git)" ]; then
50 if [ -n "\$(command -v unxz)" ]; then
53 if [ -n "\$(command -v unzip)" ]; then
56 if [ -n "\$(command -v tar)" ]; then
59 my_ext="\$(echo "\$my_ext" | sed 's/,$//')" # nix trailing comma
68 export WEBI_CURL="\$(command -v curl)"
69 export WEBI_WGET="\$(command -v wget)"
72 export WEBI_HOST="\${WEBI_HOST:-https://webinstall.dev}"
73 export WEBI_UA="\$(uname -a)"
79 if [ -z "\$my_package" ]; then
80 >&2 echo "Usage: webi <package>@<version> ..."
81 >&2 echo "Example: webi node@lts rg"
85 export WEBI_BOOT="\$(mktemp -d -t "\$my_package-bootstrap.\$WEBI_TIMESTAMP.XXXXXXXX")"
87 my_installer_url="\$WEBI_HOST/api/installers/\$my_package.sh?formats=\$my_ext"
89 if [ -n "\$WEBI_CURL" ]; then
90 curl -fsSL "\$my_installer_url" -H "User-Agent: curl \$WEBI_UA" \\
91 -o "\$WEBI_BOOT/\$my_package-bootstrap.sh"
93 wget -q "\$my_installer_url" --user-agent="wget \$WEBI_UA" \\
94 -O "\$WEBI_BOOT/\$my_package-bootstrap.sh"
96 if ! [ \$? -eq 0 ]; then
97 >&2 echo "error fetching '\$my_installer_url'"
102 pushd "\$WEBI_BOOT" 2>&1 > /dev/null
103 bash "\$my_package-bootstrap.sh"
104 popd 2>&1 > /dev/null
110 show_path_updates() {
112 if ! [ -n "\${_WEBI_CHILD}" ]; then
113 if [ -f "\$_webi_tmp/.PATH.env" ]; then
114 my_paths=\$(cat "\$_webi_tmp/.PATH.env" | sort -u)
115 if [ -n "\$my_paths" ]; then
116 echo "IMPORTANT: You must update you PATH to use the installed program(s)"
118 echo "You can CLOSE and REOPEN Terminal, or RUN these exports:"
123 rm -f "\$_webi_tmp/.PATH.env"
131 webinstall "\$pkgname"
140 chmod a+x "$HOME/.local/bin/webi"
142 if [ -n "${WEBI_PKG:-}" ]; then
143 "$HOME/.local/bin/webi" "${WEBI_PKG}"