only try to install prerequisites when missing, only offer node packages, if node installed

This commit is contained in:
2025-05-15 10:53:04 -04:00
parent 1f800151e5
commit b45bd31954
5 changed files with 57 additions and 51 deletions
+15 -15
View File
@@ -4,40 +4,40 @@
# keep trying until we get a result
# dig
if [[ -n $(command -v "dig") ]]; then
if [[ -n $(command -v 'dig') ]]; then
# via opendns
address=$(dig "@resolver1.opendns.com" -4 "myip.opendns.com" "A" "+short")
if [[ "$?" -ne "0" ]]; then
address=$(dig '@resolver1.opendns.com' -4 'myip.opendns.com' A '+short')
if [[ "$?" -ne '0' ]]; then
# dig was unsuccessful
echo "$address" 1>&2
address=""
echo "${address}" 1>&2
address=''
fi
fi
# curl
if [[ -z "$address" ]] && [[ -n $(command -v "curl") ]]; then
if [[ -z "${address}" ]] && [[ -n $(command -v 'curl') ]]; then
# via ipinfo.io
address=$(curl -4 --fail --silent --show-error "https://ipinfo.io/ip")
address=$(curl -4 --fail --silent --show-error 'https://ipinfo.io/ip')
if [[ -z "$address" ]]; then
if [[ -z "${address}" ]]; then
# via google
address=$(curl -4 --fail --silent --show-error "https://domains.google.com/checkip")
address=$(curl -4 --fail --silent --show-error 'https://domains.google.com/checkip')
fi
fi
# wget
if [[ -z "$address" ]] && [[ -n $(command -v "wget") ]]; then
if [[ -z "${address}" ]] && [[ -n $(command -v 'wget') ]]; then
# via ipinfo.io
address=$(wget -4 --quiet --output-document - "https://ipinfo.io/ip")
address=$(wget -4 --quiet --output-document - 'https://ipinfo.io/ip')
if [[ -z "$address" ]]; then
if [[ -z "${address}" ]]; then
# via google
address=$(wget -4 --quiet --output-document - "https://domains.google.com/checkip")
address=$(wget -4 --quiet --output-document - 'https://domains.google.com/checkip')
fi
fi
if [[ -n "$address" ]]; then
echo "$address"
if [[ -n "${address}" ]]; then
echo "${address}"
else
echo 'Tried everything, unable to resolve IP address.' 1>&2
fi
+17 -17
View File
@@ -3,44 +3,44 @@
# there are a few different ways to resolve public-ip,
# keep trying until we get a result
# device info
address=$(ip -6 addr list scope global | grep -v " fc" | grep -v " fd" | sed -n 's/.*inet6 \([0-9a-f:]\+\).*/\1/p' | head -n 1)
# device address
address=$(ip -6 addr list scope global | grep -v ' fc' | grep -v ' fd' | sed -n 's/.*inet6 \([0-9a-f:]\+\).*/\1/p' | head -n 1)
# dig
if [[ -z "$address" ]] && [[ -n $(command -v "dig") ]]; then
if [[ -z "${address}" ]] && [[ -n $(command -v 'dig') ]]; then
# via opendns
address=$(dig "@resolver1.opendns.com" -6 "myip.opendns.com" "AAAA" "+short")
if [[ "$?" -ne "0" ]]; then
address=$(dig '@resolver1.opendns.com' -6 'myip.opendns.com' AAAA '+short')
if [[ "$?" -ne '0' ]]; then
# dig was unsuccessful
echo "$address" 1>&2
address=""
echo "${address}" 1>&2
address=''
fi
fi
# curl
if [[ -z "$address" ]] && [[ -n $(command -v "curl") ]]; then
if [[ -z "${address}" ]] && [[ -n $(command -v 'curl') ]]; then
# via ipinfo.io
address=$(curl -6 --fail --silent --show-error "https://v6.ipinfo.io/ip")
address=$(curl -6 --fail --silent --show-error 'https://v6.ipinfo.io/ip')
if [[ -z "$address" ]]; then
if [[ -z "${address}" ]]; then
# via google
address=$(curl -6 --fail --silent --show-error "https://domains.google.com/checkip")
address=$(curl -6 --fail --silent --show-error 'https://domains.google.com/checkip')
fi
fi
# wget
if [[ -z "$address" ]] && [[ -n $(command -v "wget") ]]; then
if [[ -z "${address}" ]] && [[ -n $(command -v 'wget') ]]; then
# via ipinfo.io
address=$(wget -6 --quiet --output-document - "https://v6.ipinfo.io/ip")
address=$(wget -6 --quiet --output-document - 'https://v6.ipinfo.io/ip')
if [[ -z "$address" ]]; then
if [[ -z "${address}" ]]; then
# via google
address=$(wget -6 --quiet --output-document - "https://domains.google.com/checkip")
address=$(wget -6 --quiet --output-document - 'https://domains.google.com/checkip')
fi
fi
if [[ -n "$address" ]]; then
echo "$address"
if [[ -n "${address}" ]]; then
echo "${address}"
else
echo 'Tried everything, unable to resolve IP address.' 1>&2
fi
+2 -2
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env bash
read -p 'Install git and vim? [y/N]: ' response
read -p 'Install prerequisites (git, vim, curl, and jq)? [y/N]: ' response
case "${response}" in
[Yy]* )
# before we can begin, we need what should have already been installed
sudo apt install git vim -y
sudo apt install git vim vim-editorconfig curl jq -y
;;
* )
echo 'Skipping'
+20 -16
View File
@@ -72,14 +72,14 @@ install_collection 'extra utilities: (ncdu, zip, php, rclone, etc.)' ncdu zip un
# ----------------------------------------------------------
if [[ -n $(command -v "php") ]]; then
if [[ -n $(command -v 'php') ]]; then
read -p 'Install PHP Composer? [y/N]: ' response
case "${response}" in
[Yy]* )
return_dir=$(pwd)
cd "${package_dir}"
"${package_dir}/composer-install/composer-install.sh"
if [[ -f "composer.phar" ]]; then
if [[ -f 'composer.phar' ]]; then
sudo mv composer.phar /usr/bin/composer
fi
cd "${return_dir}"
@@ -127,7 +127,7 @@ install_collection 'Ruby: (ruby, build-essential)' ruby-full build-essential zli
# ----------------------------------------------------------
if [[ -n $(command -v "ruby") ]]; then
if [[ -n $(command -v 'ruby') ]]; then
read -p 'Configure GEM_HOME and PATH for Ruby support? [y/N]: ' response
case "${response}" in
[Yy]* )
@@ -164,17 +164,19 @@ echo ''
# ----------------------------------------------------------
read -p 'Install Node.js packages "yarn" and "http-server" globally? [y/N]: ' response
case "${response}" in
[Yy]* )
sudo npm install --global yarn
sudo npm install --global http-server
;;
* )
echo 'Skipping'
;;
esac
echo ''
if [[ -n $(command -v 'npm') ]]; then
read -p 'Install Node.js packages "yarn" and "http-server" globally? [y/N]: ' response
case "${response}" in
[Yy]* )
sudo npm install --global yarn
sudo npm install --global http-server
;;
* )
echo 'Skipping'
;;
esac
echo ''
fi
# ----------------------------------------------------------
@@ -182,10 +184,12 @@ read -p 'Install GoLang? [y/N]: ' response
case "${response}" in
[Yy]* )
make_bashrc_backup
sudo apt install wget jq -y
if [[ -z $(command -v 'curl') ]] || [[ -z $(command -v 'jq') ]]; then
sudo apt install curl jq -y
fi
# load json file with version info, filter to only stable versions, take the first (newest), strip to just numeric
version_flag=''
go_version=$(wget --quiet --output-document - 'https://go.dev/dl/?mode=json' | jq -r '.[] | select( .stable ) | .version' | head -n 1 | sed 's/[^0-9.]*//g')
go_version=$(curl --fail --silent --show-error 'https://go.dev/dl/?mode=json' | jq -r '.[] | select( .stable ) | .version' | head -n 1 | sed 's/[^0-9.]*//g')
if [[ -n "${go_version}" ]]; then
version_flag='--version'
echo "Installing GoLand Version: ${go_version}"
+3 -1
View File
@@ -244,7 +244,9 @@ read -p 'Set VIM colors, config, and plugins? [y/N]: ' response
case "${response}" in
[Yy]* )
make_bashrc_backup
sudo apt install vim vim-editorconfig jq curl -y
if [[ -z $(command -v 'vim') ]] || [[ -z $(command -v 'curl') ]] || [[ -z $(command -v 'jq') ]]; then
sudo apt install vim curl jq -y
fi
( cat << 'BASHRC'
# ABS default to using vim