Skip to content

Commit 8f452db

Browse files
committed
Fixed sudo issue in git installer
1 parent 4a51b0b commit 8f452db

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

installers/git/installer.sh

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,32 @@ APT_GET_CMD=$(which apt-get) # apt package manager for Ubuntu & other Debian bas
66
PACMAN_CMD=$(which pacman) # pacman package manager for ArchLinux
77
APK_CMD=$(which apk) # apk package manager for Alpine
88

9+
PREFIX=''
10+
if [ "$user" != 'root' ]; then
11+
if command_exists sudo; then
12+
PREFIX='sudo'
13+
else
14+
cat >&2 <<-'EOF'
15+
Error: this installer needs the ability to run commands as root.
16+
We are unable to find "sudo" available to make this happen.
17+
EOF
18+
exit 1
19+
fi
20+
fi
21+
922
if [ ! -z $APT_GET_CMD ]; then
10-
sudo apt-get update
11-
sudo apt-get install git
23+
PREFIX apt-get update
24+
PREFIX apt-get install git
1225
elif [ ! -z $DNF_CMD ]; then
13-
sudo dnf install git
26+
PREFIX dnf install git
1427
elif [ ! -z $YUM_CMD ]; then
15-
sudo yum install git
28+
PREFIX yum install git
1629
elif [ ! -z $PACMAN_CMD ]; then
1730
pacman -Sy git
1831
elif [ ! -z $APK_CMD ]; then
19-
sudo apk add git
32+
PREFIX apk add git
2033
else
21-
echo "Couldn't install package"
34+
echo "Couldn't find an installer matching to this package"
2235
exit 1;
2336
fi
2437

0 commit comments

Comments
 (0)