File tree 1 file changed +16
-6
lines changed
1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -26,12 +26,22 @@ function fail {
26
26
# The goal is to allow the user to run this script as a normal user and
27
27
# to be asked for authorizations as needed
28
28
function askRoot {
29
- echo " The following command needs administrator privileges:"
30
- echo
31
- echo -e " \\ t$* "
32
- echo
33
- # The -k flag forces sudo to re-ask the user for their authorization
34
- sudo -k " $@ "
29
+ if [ $( id -u) -eq 0 ]; then
30
+ " $@ "
31
+ else
32
+ echo " The following command needs administrator privileges:"
33
+ echo
34
+ echo -e " \\ t$* "
35
+ echo
36
+ # The -k flag forces sudo to re-ask the user for their authorization
37
+ if command -v sudo > /dev/null; then
38
+ sudo -k " $@ "
39
+ elif command -v su > /dev/null; then
40
+ su root -c " /bin/bash $@ "
41
+ else
42
+ fail " neither sudo nor su are installed"
43
+ fi
44
+ fi
35
45
}
36
46
37
47
function install {
You can’t perform that action at this time.
0 commit comments