Require root privileges only when neccessary
This commit is contained in:
committed by
T. R. Bernstein
parent
5d8efcf238
commit
10b9b857b1
@@ -77,7 +77,6 @@ function main() {
|
|||||||
local traps=()
|
local traps=()
|
||||||
local -A colors=() errColors=()
|
local -A colors=() errColors=()
|
||||||
defineColors
|
defineColors
|
||||||
id -Gn | grep admin >&! /dev/null || { printError 'This script requires root access. Please run as an admin user.'; return 10 }
|
|
||||||
|
|
||||||
configureTerminal
|
configureTerminal
|
||||||
local tmpdir="`mktemp -d -t 'macos-system'`"
|
local tmpdir="`mktemp -d -t 'macos-system'`"
|
||||||
@@ -94,7 +93,7 @@ function main() {
|
|||||||
local -A colors=() errColors=()
|
local -A colors=() errColors=()
|
||||||
[ -t 1 ] && tput cnorm
|
[ -t 1 ] && tput cnorm
|
||||||
isDebug && export MACOS_SYSTEM_DEBUG=true
|
isDebug && export MACOS_SYSTEM_DEBUG=true
|
||||||
sudo --preserve-env=HOMEBREW_BREW_GIT_REMOTE,HOMEBREW_BREW_CORE_GIT_REMOTE,HOMEBREW_BREW_CASK_GIT_REMOTE,HOMEBREW_BREW_CASK_FONTS_GIT_REMOTE,MACOS_SYSTEM_DEBUG "${tmpdir}/install.sh" "$@"
|
"${tmpdir}/install.sh" "$@"
|
||||||
[ -t 1 ] && tput civis
|
[ -t 1 ] && tput civis
|
||||||
popd -q
|
popd -q
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ function isPlistBuddyInstalled() {
|
|||||||
function checkPrerequisites() {
|
function checkPrerequisites() {
|
||||||
isMacOS || { lop -- -e 'This setup is only for macOS 10.13 and up.'; return 10 }
|
isMacOS || { lop -- -e 'This setup is only for macOS 10.13 and up.'; return 10 }
|
||||||
isPlistBuddyInstalled || { lop -- -e 'This setup requires PlistBuddy to be either at /usr/libexec or in any of the PATH directories.'; return 11 }
|
isPlistBuddyInstalled || { lop -- -e 'This setup requires PlistBuddy to be either at /usr/libexec or in any of the PATH directories.'; return 11 }
|
||||||
test "`id -u`" -eq 0 || { lop -- -e 'This module requires root access. Please run as root.'; return 11 }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function configureTerminal() {
|
function configureTerminal() {
|
||||||
@@ -101,11 +100,11 @@ function main() {
|
|||||||
checkPrerequisites || return
|
checkPrerequisites || return
|
||||||
eval "`docopts -f -V - -h - : "$@" <<- USAGE
|
eval "`docopts -f -V - -h - : "$@" <<- USAGE
|
||||||
Usage: $0 [options] [-m PATH]... [<module>...]
|
Usage: $0 [options] [-m PATH]... [<module>...]
|
||||||
|
|
||||||
Install all modules in module search path. If any <module> arg is given,
|
Install all modules in module search path. If any <module> arg is given,
|
||||||
install only modules that either match any given <module> or whose path ends
|
install only modules that either match any given <module> or whose path ends
|
||||||
like any of the given <module>.
|
like any of the given <module>.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-i, --inverse Exclude the given <module> instead.
|
-i, --inverse Exclude the given <module> instead.
|
||||||
-m PATH, --modpath PATH Include PATH in the module search path.
|
-m PATH, --modpath PATH Include PATH in the module search path.
|
||||||
@@ -135,6 +134,7 @@ function main() {
|
|||||||
|
|
||||||
askNecessaryQuestions
|
askNecessaryQuestions
|
||||||
[ -z "${config_only}" ] || return 0
|
[ -z "${config_only}" ] || return 0
|
||||||
|
requireRootPrivileges
|
||||||
installModules
|
installModules
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user