5 function __install_webi() {
8 #WEBI_HOST=https://webinstall.dev
12 printf "Thanks for using webi to install '\e[32m${WEBI_PKG:-}\e[0m' on '\e[31m$(uname -s)/$(uname -m)\e[0m'.\n"
13 echo "Have a problem? Experience a bug? Please let us know:"
14 echo " https://github.com/webinstall/webi-installers/issues"
16 printf "\e[31mLovin'\e[0m it? Say thanks with a \e[34mStar on GitHub\e[0m:\n"
17 printf " \e[32mhttps://github.com/webinstall/webi-installers\e[0m\n"
26 mkdir -p "$HOME/.local/bin"
28 cat << EOF > "$HOME/.local/bin/webi"
35 function __webi_main () {
37 export WEBI_TIMESTAMP=\$(date +%F_%H-%M-%S)
38 export _webi_tmp="\${_webi_tmp:-\$(mktemp -d -t webi-\$WEBI_TIMESTAMP.XXXXXXXX)}"
40 if [ -n "\${_WEBI_PARENT:-}" ]; then
41 export _WEBI_CHILD=true
45 export _WEBI_PARENT=true
48 ## Detect acceptable package formats
53 # NOTE: the order here is least favorable to most favorable
54 if [ -n "\$(command -v pkgutil)" ]; then
57 # disable this check for the sake of building the macOS installer on Linux
58 #if [ -n "\$(command -v diskutil)" ]; then
59 # note: could also detect via hdiutil
62 if [ -n "\$(command -v git)" ]; then
65 if [ -n "\$(command -v unxz)" ]; then
68 if [ -n "\$(command -v unzip)" ]; then
71 # for mac/linux 'exe' refers to the uncompressed binary without extension
73 if [ -n "\$(command -v tar)" ]; then
76 my_ext="\$(echo "\$my_ext" | sed 's/,$//')" # nix trailing comma
85 export WEBI_CURL="\$(command -v curl)"
86 export WEBI_WGET="\$(command -v wget)"
89 export WEBI_HOST="\${WEBI_HOST:-https://webinstall.dev}"
90 export WEBI_UA="\$(uname -a)"
93 function webinstall() {
96 if [ -z "\$my_package" ]; then
97 >&2 echo "Usage: webi <package>@<version> ..."
98 >&2 echo "Example: webi node@lts rg"
102 export WEBI_BOOT="\$(mktemp -d -t "\$my_package-bootstrap.\$WEBI_TIMESTAMP.XXXXXXXX")"
104 my_installer_url="\$WEBI_HOST/api/installers/\$my_package.sh?formats=\$my_ext"
106 if [ -n "\$WEBI_CURL" ]; then
107 curl -fsSL "\$my_installer_url" -H "User-Agent: curl \$WEBI_UA" \\
108 -o "\$WEBI_BOOT/\$my_package-bootstrap.sh"
110 wget -q "\$my_installer_url" --user-agent="wget \$WEBI_UA" \\
111 -O "\$WEBI_BOOT/\$my_package-bootstrap.sh"
113 if ! [ \$? -eq 0 ]; then
114 >&2 echo "error fetching '\$my_installer_url'"
119 pushd "\$WEBI_BOOT" 2>&1 > /dev/null
120 bash "\$my_package-bootstrap.sh"
121 popd 2>&1 > /dev/null
127 show_path_updates() {
129 if ! [ -n "\${_WEBI_CHILD}" ]; then
130 if [ -f "\$_webi_tmp/.PATH.env" ]; then
131 my_paths=\$(cat "\$_webi_tmp/.PATH.env" | sort -u)
132 if [ -n "\$my_paths" ]; then
133 echo "IMPORTANT: You must update you PATH to use the installed program(s)"
135 echo "You can either"
136 echo "A) can CLOSE and REOPEN Terminal or"
137 echo "B) RUN these exports:"
142 rm -f "\$_webi_tmp/.PATH.env"
150 webinstall "\$pkgname"
161 chmod a+x "$HOME/.local/bin/webi"
163 if [ -n "${WEBI_PKG:-}" ]; then
164 "$HOME/.local/bin/webi" "${WEBI_PKG}"
167 echo "Hmm... no WEBI_PKG was specified. This is probably an error in the script."
169 echo "Please open an issue with this information: Package '${WEBI_PKG:-}' on '$(uname -s)/$(uname -m)'"
170 echo " https://github.com/webinstall/packages/issues"