add brew user
This commit is contained in:
@@ -70,9 +70,18 @@ function install() {
|
||||
msg_info "Detecting Non-Root User"
|
||||
BREW_USER=$(awk -F: '$3 >= 1000 && $3 < 65534 { print $1; exit }' /etc/passwd)
|
||||
if [[ -z "$BREW_USER" ]]; then
|
||||
msg_error "No non-root user found (uid >= 1000). Homebrew cannot run as root. Create a user first."
|
||||
msg_warn "No non-root user found (uid >= 1000). Homebrew cannot run as root."
|
||||
read -r -p "${TAB}Create a 'brew' user automatically? (y/N): " create_user_prompt
|
||||
if [[ "${create_user_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||
msg_info "Creating user 'brew'"
|
||||
useradd -m -s /bin/bash brew
|
||||
BREW_USER="brew"
|
||||
msg_ok "Created user 'brew'"
|
||||
else
|
||||
msg_error "Cannot install Homebrew without a non-root user. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
msg_ok "Detected User: $BREW_USER"
|
||||
|
||||
msg_info "Installing Dependencies"
|
||||
@@ -134,8 +143,7 @@ if [[ -d "$INSTALL_PATH" ]]; then
|
||||
msg_warn "Homebrew is already installed."
|
||||
echo ""
|
||||
|
||||
echo -n "${TAB}Uninstall Homebrew? (y/N): "
|
||||
read -r uninstall_prompt
|
||||
read -r -p "${TAB}Uninstall Homebrew? (y/N): " uninstall_prompt
|
||||
if [[ "${uninstall_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||
uninstall
|
||||
exit 0
|
||||
@@ -153,8 +161,7 @@ echo -e "${TAB} - Homebrew (Linuxbrew) package manager"
|
||||
echo -e "${TAB} - Shell integration for the detected non-root user"
|
||||
echo ""
|
||||
|
||||
echo -n "${TAB}Install Homebrew? (y/N): "
|
||||
read -r install_prompt
|
||||
read -r -p "${TAB}Install Homebrew? (y/N): " install_prompt
|
||||
if [[ "${install_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||
install
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user