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 # for mac/linux 'exe' refers to the uncompressed binary without extension
58 if [ -n "\$(command -v tar)" ]; then
61 my_ext="\$(echo "\$my_ext" | sed 's/,$//')" # nix trailing comma
70 export WEBI_CURL="\$(command -v curl)"
71 export WEBI_WGET="\$(command -v wget)"
74 export WEBI_HOST="\${WEBI_HOST:-https://webinstall.dev}"
75 export WEBI_UA="\$(uname -a)"
81 if [ -z "\$my_package" ]; then
82 >&2 echo "Usage: webi <package>@<version> ..."
83 >&2 echo "Example: webi node@lts rg"
87 export WEBI_BOOT="\$(mktemp -d -t "\$my_package-bootstrap.\$WEBI_TIMESTAMP.XXXXXXXX")"
89 my_installer_url="\$WEBI_HOST/api/installers/\$my_package.sh?formats=\$my_ext"
91 if [ -n "\$WEBI_CURL" ]; then
92 curl -fsSL "\$my_installer_url" -H "User-Agent: curl \$WEBI_UA" \\
93 -o "\$WEBI_BOOT/\$my_package-bootstrap.sh"
95 wget -q "\$my_installer_url" --user-agent="wget \$WEBI_UA" \\
96 -O "\$WEBI_BOOT/\$my_package-bootstrap.sh"
98 if ! [ \$? -eq 0 ]; then
99 >&2 echo "error fetching '\$my_installer_url'"
104 pushd "\$WEBI_BOOT" 2>&1 > /dev/null
105 bash "\$my_package-bootstrap.sh"
106 popd 2>&1 > /dev/null
112 show_path_updates() {
114 if ! [ -n "\${_WEBI_CHILD}" ]; then
115 if [ -f "\$_webi_tmp/.PATH.env" ]; then
116 my_paths=\$(cat "\$_webi_tmp/.PATH.env" | sort -u)
117 if [ -n "\$my_paths" ]; then
118 echo "IMPORTANT: You must update you PATH to use the installed program(s)"
120 echo "You can CLOSE and REOPEN Terminal, or RUN these exports:"
125 rm -f "\$_webi_tmp/.PATH.env"
133 webinstall "\$pkgname"
142 chmod a+x "$HOME/.local/bin/webi"
144 if [ -n "${WEBI_PKG:-}" ]; then
145 "$HOME/.local/bin/webi" "${WEBI_PKG}"