5 function __install_webi() {
8 #WEBI_HOST=https://webinstall.dev
12 echo "Thanks for using webi to install '${WEBI_PKG:-}' on '$(uname -s)/$(uname -m)'."
13 echo "Have a problem? Experience a bug? Please let us know:"
14 echo " https://github.com/webinstall/packages/issues"
22 mkdir -p "$HOME/.local/bin"
24 cat << EOF > "$HOME/.local/bin/webi"
31 function __webi_main () {
33 export WEBI_TIMESTAMP=\$(date +%F_%H-%M-%S)
34 export _webi_tmp="\${_webi_tmp:-\$(mktemp -d -t webi-\$WEBI_TIMESTAMP.XXXXXXXX)}"
36 if [ -n "\${_WEBI_PARENT:-}" ]; then
37 export _WEBI_CHILD=true
41 export _WEBI_PARENT=true
44 ## Detect acceptable package formats
49 # NOTE: the order here is least favorable to most favorable
50 if [ -n "\$(command -v pkgutil)" ]; then
53 # disable this check for the sake of building the macOS installer on Linux
54 #if [ -n "\$(command -v diskutil)" ]; then
55 # note: could also detect via hdiutil
58 if [ -n "\$(command -v git)" ]; then
61 if [ -n "\$(command -v unxz)" ]; then
64 if [ -n "\$(command -v unzip)" ]; then
67 # for mac/linux 'exe' refers to the uncompressed binary without extension
69 if [ -n "\$(command -v tar)" ]; then
72 my_ext="\$(echo "\$my_ext" | sed 's/,$//')" # nix trailing comma
81 export WEBI_CURL="\$(command -v curl)"
82 export WEBI_WGET="\$(command -v wget)"
85 export WEBI_HOST="\${WEBI_HOST:-https://webinstall.dev}"
86 export WEBI_UA="\$(uname -a)"
89 function webinstall() {
92 if [ -z "\$my_package" ]; then
93 >&2 echo "Usage: webi <package>@<version> ..."
94 >&2 echo "Example: webi node@lts rg"
98 export WEBI_BOOT="\$(mktemp -d -t "\$my_package-bootstrap.\$WEBI_TIMESTAMP.XXXXXXXX")"
100 my_installer_url="\$WEBI_HOST/api/installers/\$my_package.sh?formats=\$my_ext"
102 if [ -n "\$WEBI_CURL" ]; then
103 curl -fsSL "\$my_installer_url" -H "User-Agent: curl \$WEBI_UA" \\
104 -o "\$WEBI_BOOT/\$my_package-bootstrap.sh"
106 wget -q "\$my_installer_url" --user-agent="wget \$WEBI_UA" \\
107 -O "\$WEBI_BOOT/\$my_package-bootstrap.sh"
109 if ! [ \$? -eq 0 ]; then
110 >&2 echo "error fetching '\$my_installer_url'"
115 pushd "\$WEBI_BOOT" 2>&1 > /dev/null
116 bash "\$my_package-bootstrap.sh"
117 popd 2>&1 > /dev/null
123 show_path_updates() {
125 if ! [ -n "\${_WEBI_CHILD}" ]; then
126 if [ -f "\$_webi_tmp/.PATH.env" ]; then
127 my_paths=\$(cat "\$_webi_tmp/.PATH.env" | sort -u)
128 if [ -n "\$my_paths" ]; then
129 echo "IMPORTANT: You must update you PATH to use the installed program(s)"
131 echo "You can either"
132 echo "A) can CLOSE and REOPEN Terminal or"
133 echo "B) RUN these exports:"
138 rm -f "\$_webi_tmp/.PATH.env"
146 webinstall "\$pkgname"
157 chmod a+x "$HOME/.local/bin/webi"
159 if [ -n "${WEBI_PKG:-}" ]; then
160 "$HOME/.local/bin/webi" "${WEBI_PKG}"
163 echo "Hmm... no WEBI_PKG was specified. This is probably an error in the script."
165 echo "Please open an issue with this information: Package '${WEBI_PKG:-}' on '$(uname -s)/$(uname -m)'"
166 echo " https://github.com/webinstall/packages/issues"