File tree Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -6,19 +6,33 @@ APT_GET_CMD=$(which apt-get) # apt package manager for Ubuntu & other Debian bas
6
6
PACMAN_CMD=$( which pacman) # pacman package manager for ArchLinux
7
7
APK_CMD=$( which apk) # apk package manager for Alpine
8
8
9
+ USER=" $( id -un 2> /dev/null || true) "
10
+ PREFIX=' '
11
+ if [ " $USER " != ' root' ]; then
12
+ if command_exists sudo; then
13
+ PREFIX=' sudo'
14
+ else
15
+ cat >&2 << -'EOF '
16
+ Error: this installer needs the ability to run commands as root.
17
+ We are unable to find "sudo". Make sure its available to make this happen
18
+ EOF
19
+ exit 1
20
+ fi
21
+ fi
22
+
9
23
if [ ! -z $APT_GET_CMD ]; then
10
- sudo apt-get update
11
- sudo apt-get install git
24
+ $PREFIX apt-get update
25
+ $PREFIX apt-get install git
12
26
elif [ ! -z $DNF_CMD ]; then
13
- sudo dnf install git
27
+ $PREFIX dnf install git
14
28
elif [ ! -z $YUM_CMD ]; then
15
- sudo yum install git
29
+ $PREFIX yum install git
16
30
elif [ ! -z $PACMAN_CMD ]; then
17
31
pacman -Sy git
18
32
elif [ ! -z $APK_CMD ]; then
19
- sudo apk add git
33
+ $PREFIX apk add git
20
34
else
21
- echo " Couldn't install package"
35
+ echo " Couldn't find an installer matching to this package"
22
36
exit 1;
23
37
fi
24
38
You can’t perform that action at this time.
0 commit comments