Skip to content

Commit

Permalink
[script] remove usage of sudo from bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
lmnotran committed Feb 7, 2024
1 parent 2fd57d5 commit 353f13e
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions script/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,25 @@ script_dir="$(realpath "$(dirname "${script_path}")")"
repo_dir="$(dirname "${script_dir}")"

# ==============================================================================
# Fancy red-colored `error` function with `stderr` redirection with `exit`.
error ()
{
{ printf '\E[31m'; echo "$@"; printf '\E[0m'; } >&2
exit 1
}

install_packages_apt()
{
# Test for root user.
if [ "$EUID" -ne 0 ]; then
error "Please re-run this script as root or with sudo"
fi

echo 'Installing script dependencies...'

# apt-get update and install dependencies
sudo apt-get update
sudo apt-get --no-install-recommends install -y \
# Install dependencies
apt-get update
apt-get --no-install-recommends install -y \
coreutils \
openjdk-17-jre \
python3-setuptools \
Expand Down Expand Up @@ -146,8 +157,10 @@ install_arm_toolchain()
# Extract
tar xf "${toolchain_dir}/${tarball}" --directory "${toolchain_dir}/${extract_dir}" --strip-components=1

# Link
sudo ln -s -f "${toolchain_dir}"/"${extract_dir}"/bin/* /usr/local/bin/
# Link if root
if [ "$EUID" -eq 0 ]; then
ln -s -f "${toolchain_dir}"/"${extract_dir}"/bin/* /usr/local/bin/
fi

# Cleanup
rm -rf "${toolchain_dir:?}/${tarball:?}"
Expand Down

0 comments on commit 353f13e

Please sign in to comment.