Skip to content

Commit

Permalink
feat(node): ask to install libstdc++ on Alpine
Browse files Browse the repository at this point in the history
  • Loading branch information
coolaj86 committed Dec 18, 2024
1 parent 910fa48 commit afe35f9
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions node/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,58 @@ pkg_done_message() {
b_dst="$(fn_sub_home "${pkg_dst}")"
echo ""
echo " Installed $(t_pkg 'node') and $(t_pkg 'npm') at $(t_path "${b_dst}/")"

if command -v apk > /dev/null; then
if ! apk info | grep -F 'libstdc++' > /dev/null; then
echo ""
echo " $(t_pkg 'WARNING'): $(t_pkg 'libstdc++') is required for $(t_pkg 'node'), but not installed" >&2
if command -v sudo > /dev/null; then
cmd_sudo='sudo '
fi
_install_webi_essentials_apk "${cmd_sudo}" 'libstdc++'
fi
fi
}

_install_webi_essentials_apk() { (
cmd_sudo="${1}"
b_pkgs="${2}"

#echo " $(t_dim 'Running') $(t_cmd "${cmd_sudo}apk add --no-cache")"
fn_polite_sudo "${cmd_sudo}" " $(t_cmd "apk add --no-cache ${b_pkgs}")"
# shellcheck disable=SC2086
${cmd_sudo} apk add --no-cache ${b_pkgs}
); }

fn_polite_sudo() { (
a_sudo="${1}"
a_cmds="${2}"

# no sudo needed, so don't ask
if test -z "${a_sudo}"; then
return 0
fi

# this is scripted, not user-interactive, continue
if test -z "${WEBI_TTY}"; then
return 0
fi

# this is user interactive, ask the user,defaulting to yes
echo ""
#shellcheck disable=SC2005 # echo for newline
printf '%s\n' "$(t_attn 'Use sudo to run the following? [Y/n] ')"
echo "${a_cmds}"
read -r b_yes < /dev/tty

b_yes="$(
echo "${b_yes}" |
tr '[:upper:]' '[:lower:]' |
tr -d '[:space:]'
)"
if test -z "${b_yes}" || test "${b_yes}" = "y" || test "${b_yes}" = "yes"; then
return 0
fi
echo " aborted"
return 1
); }

0 comments on commit afe35f9

Please sign in to comment.