5 function __install_webi() {
8 #WEBI_HOST=https://webinstall.dev
12 echo -e "Thanks for using webi to install '\e[32m${WEBI_PKG:-}\e[0m' on '\e[31m$(uname -s)/$(uname -m)\e[0m'."
13 echo "Have a problem? Experience a bug? Please let us know:"
14 echo " https://github.com/webinstall/webi-installers/issues"
16 echo -e "\e[31mLovin'\e[0m it? Say thanks with a \e[34mStar on GitHub\e[0m:"
17 echo -e " \e[32mhttps://github.com/webinstall/webi-installers\e[0m"
25 mkdir -p "$HOME/.local/bin"
27 cat << EOF > "$HOME/.local/bin/webi"
34 function __webi_main () {
36 export WEBI_TIMESTAMP=\$(date +%F_%H-%M-%S)
37 export _webi_tmp="\${_webi_tmp:-\$(mktemp -d -t webi-\$WEBI_TIMESTAMP.XXXXXXXX)}"
39 if [ -n "\${_WEBI_PARENT:-}" ]; then
40 export _WEBI_CHILD=true
44 export _WEBI_PARENT=true
47 ## Detect acceptable package formats
52 # NOTE: the order here is least favorable to most favorable
53 if [ -n "\$(command -v pkgutil)" ]; then
56 # disable this check for the sake of building the macOS installer on Linux
57 #if [ -n "\$(command -v diskutil)" ]; then
58 # note: could also detect via hdiutil
61 if [ -n "\$(command -v git)" ]; then
64 if [ -n "\$(command -v unxz)" ]; then
67 if [ -n "\$(command -v unzip)" ]; then
70 # for mac/linux 'exe' refers to the uncompressed binary without extension
72 if [ -n "\$(command -v tar)" ]; then
75 my_ext="\$(echo "\$my_ext" | sed 's/,$//')" # nix trailing comma
84 export WEBI_CURL="\$(command -v curl)"
85 export WEBI_WGET="\$(command -v wget)"
88 export WEBI_HOST="\${WEBI_HOST:-https://webinstall.dev}"
89 export WEBI_UA="\$(uname -a)"
92 function webinstall() {
95 if [ -z "\$my_package" ]; then
96 >&2 echo "Usage: webi <package>@<version> ..."
97 >&2 echo "Example: webi node@lts rg"
101 export WEBI_BOOT="\$(mktemp -d -t "\$my_package-bootstrap.\$WEBI_TIMESTAMP.XXXXXXXX")"
103 my_installer_url="\$WEBI_HOST/api/installers/\$my_package.sh?formats=\$my_ext"
105 if [ -n "\$WEBI_CURL" ]; then
106 curl -fsSL "\$my_installer_url" -H "User-Agent: curl \$WEBI_UA" \\
107 -o "\$WEBI_BOOT/\$my_package-bootstrap.sh"
109 wget -q "\$my_installer_url" --user-agent="wget \$WEBI_UA" \\
110 -O "\$WEBI_BOOT/\$my_package-bootstrap.sh"
112 if ! [ \$? -eq 0 ]; then
113 >&2 echo "error fetching '\$my_installer_url'"
118 pushd "\$WEBI_BOOT" 2>&1 > /dev/null
119 bash "\$my_package-bootstrap.sh"
120 popd 2>&1 > /dev/null
126 show_path_updates() {
128 if ! [ -n "\${_WEBI_CHILD}" ]; then
129 if [ -f "\$_webi_tmp/.PATH.env" ]; then
130 my_paths=\$(cat "\$_webi_tmp/.PATH.env" | sort -u)
131 if [ -n "\$my_paths" ]; then
132 echo "IMPORTANT: You must update you PATH to use the installed program(s)"
134 echo "You can either"
135 echo "A) can CLOSE and REOPEN Terminal or"
136 echo "B) RUN these exports:"
141 rm -f "\$_webi_tmp/.PATH.env"
149 webinstall "\$pkgname"
160 chmod a+x "$HOME/.local/bin/webi"
162 if [ -n "${WEBI_PKG:-}" ]; then
163 "$HOME/.local/bin/webi" "${WEBI_PKG}"
166 echo "Hmm... no WEBI_PKG was specified. This is probably an error in the script."
168 echo "Please open an issue with this information: Package '${WEBI_PKG:-}' on '$(uname -s)/$(uname -m)'"
169 echo " https://github.com/webinstall/packages/issues"