6 #WEBI_HOST=https://webinstall.dev
9 mkdir -p "$HOME/.local/bin"
11 cat << EOF > "$HOME/.local/bin/webi"
20 if [ -z "\$my_package" ]; then
21 echo "Usage: webi <package>@<version>"
22 echo "Example: webi node@latest"
27 ## Detect acceptable package formats
32 # NOTE: the order here is least favorable to most favorable
33 if [ -n "\$(command -v pkgutil)" ]; then
36 # disable this check for the sake of building the macOS installer on Linux
37 #if [ -n "\$(command -v diskutil)" ]; then
38 # note: could also detect via hdiutil
41 if [ -n "\$(command -v git)" ]; then
44 if [ -n "\$(command -v unxz)" ]; then
47 if [ -n "\$(command -v unzip)" ]; then
50 echo "WARN: 'unzip' not found"
52 if [ -n "\$(command -v tar)" ]; then
55 my_ext="\$(echo "\$my_ext" | sed 's/,$//')" # nix trailing comma
62 export WEBI_CURL="\$(command -v curl)"
63 export WEBI_WGET="\$(command -v wget)"
66 export WEBI_BOOT="\$(mktemp -d -t "\$my_package-bootstrap.XXXXXXXX")"
67 export WEBI_HOST="\${WEBI_HOST:-https://webinstall.dev}"
68 export WEBI_UA="\$(uname -a)"
70 my_installer_url="\$WEBI_HOST/api/installers/\$my_package.bash?formats=\$my_ext"
72 if [ -n "\$WEBI_CURL" ]; then
73 curl -fsSL "\$my_installer_url" -H "User-Agent: curl \$WEBI_UA" \\
74 -o "\$WEBI_BOOT/\$my_package-bootstrap.sh"
76 wget -q "\$my_installer_url" --user-agent="wget \$WEBI_UA" \\
77 -O "\$WEBI_BOOT/\$my_package-bootstrap.sh"
79 if ! [ \$? -eq 0 ]; then
80 echo "error fetching '\$my_installer_url'"
85 pushd "\$WEBI_BOOT" 2>&1 > /dev/null
86 bash "\$my_package-bootstrap.sh"
94 chmod a+x "$HOME/.local/bin/webi"
96 if [ -n "${WEBI_PKG:-}" ]; then
97 "$HOME/.local/bin/webi" "${WEBI_PKG}"