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 apt-get)" ]; then
57 >&2 echo "WARN: please install 'unzip':"
58 >&2 echo " sudo apt-get install -y unzip"
60 >&2 echo "WARN: 'unzip' not found"
63 if [ -n "\$(command -v tar)" ]; then
66 my_ext="\$(echo "\$my_ext" | sed 's/,$//')" # nix trailing comma
75 export WEBI_CURL="\$(command -v curl)"
76 export WEBI_WGET="\$(command -v wget)"
79 export WEBI_HOST="\${WEBI_HOST:-https://webinstall.dev}"
80 export WEBI_UA="\$(uname -a)"
86 if [ -z "\$my_package" ]; then
87 >&2 echo "Usage: webi <package>@<version> ..."
88 >&2 echo "Example: webi node@lts rg"
92 export WEBI_BOOT="\$(mktemp -d -t "\$my_package-bootstrap.\$WEBI_TIMESTAMP.XXXXXXXX")"
94 my_installer_url="\$WEBI_HOST/api/installers/\$my_package.sh?formats=\$my_ext"
96 if [ -n "\$WEBI_CURL" ]; then
97 curl -fsSL "\$my_installer_url" -H "User-Agent: curl \$WEBI_UA" \\
98 -o "\$WEBI_BOOT/\$my_package-bootstrap.sh"
100 wget -q "\$my_installer_url" --user-agent="wget \$WEBI_UA" \\
101 -O "\$WEBI_BOOT/\$my_package-bootstrap.sh"
103 if ! [ \$? -eq 0 ]; then
104 >&2 echo "error fetching '\$my_installer_url'"
109 pushd "\$WEBI_BOOT" 2>&1 > /dev/null
110 bash "\$my_package-bootstrap.sh"
111 popd 2>&1 > /dev/null
117 show_path_updates() {
119 if ! [ -n "\${_WEBI_CHILD}" ]; then
120 if [ -f "\$_webi_tmp/.PATH.env" ]; then
121 my_paths=\$(cat "\$_webi_tmp/.PATH.env" | sort -u)
122 if [ -n "\$my_paths" ]; then
123 echo "IMPORTANT: You must update you PATH to use the installed program(s)"
125 echo "You can CLOSE and REOPEN Terminal, or RUN these exports:"
130 rm -f "\$_webi_tmp/.PATH.env"
138 webinstall "\$pkgname"
147 chmod a+x "$HOME/.local/bin/webi"
149 if [ -n "${WEBI_PKG:-}" ]; then
150 "$HOME/.local/bin/webi" "${WEBI_PKG}"