Skip to content

Commit 647b22c

Browse files
author
Waylon S. Walker
committed
use sudo if ya got it
1 parent 1cab69a commit 647b22c

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

installer/install-base.sh

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4+
if command -v sudo >/dev/null 2>&1; then
5+
SUDO="sudo"
6+
else
7+
SUDO=""
8+
fi
49
# Universal packages across Arch, Alpine, Debian, Ubuntu, Fedora
510
PACKAGES=(
611
bat
@@ -32,13 +37,13 @@ PACKAGES=(
3237
)
3338

3439
install_arch() {
35-
pacman -Syu --noconfirm
36-
pacman -S --noconfirm base-devel "${PACKAGES[@]/pip/python-pip}"
40+
$SUDO pacman -Syu --noconfirm
41+
$SUDO pacman -S --noconfirm base-devel "${PACKAGES[@]/pip/python-pip}"
3742
}
3843

3944
install_alpine() {
40-
apk update
41-
apk add --no-cache alpine-sdk \
45+
$SUDO apk update
46+
$SUDO apk add --no-cache alpine-sdk \
4247
bash \
4348
"${PACKAGES[@]/pip/py3-pip}" \
4449
python3 \
@@ -50,22 +55,22 @@ install_alpine() {
5055
}
5156

5257
install_debian() {
53-
apt-get update
54-
apt-get install -y --no-install-recommends \
58+
$SUDO apt-get update
59+
$SUDO apt-get install -y --no-install-recommends \
5560
build-essential \
5661
"${PACKAGES[@]/pip/python3-pip}" \
5762
libbz2-dev \
5863
libc6-dev \
5964
libreadline-dev \
6065
libsqlite3-dev \
6166
libssl-dev
62-
apt-get clean
63-
rm -rf /var/lib/apt/lists/*
67+
$SUDO apt-get clean
68+
$SUDO rm -rf /var/lib/apt/lists/*
6469
}
6570

6671
install_fedora() {
67-
dnf groupinstall -y "Development Tools"
68-
dnf install -y \
72+
$SUDO dnf groupinstall -y "Development Tools"
73+
$SUDO dnf install -y \
6974
"${PACKAGES[@]/pip/python3-pip}" \
7075
bzip2-devel \
7176
glibc-devel \

0 commit comments

Comments
 (0)