Add Ninja to base
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
|
||||
set -e
|
||||
|
||||
# Colors
|
||||
GREEN='\033[1;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[1;31m'
|
||||
@@ -14,20 +13,17 @@ DEFAULT_USER="mangopig"
|
||||
DEFAULT_UID="1000"
|
||||
DEFAULT_GID="1000"
|
||||
|
||||
# Root Check
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo -e "${RED}Please run this script as root.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# OS Detection
|
||||
echo -e "${YELLOW}LOG: Detecting OS...${NC}"
|
||||
if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
OS=$ID
|
||||
fi
|
||||
|
||||
# IP Address Retrieval
|
||||
echo -e "${YELLOW}LOG: Determining primary IPv4 address...${NC}"
|
||||
if command -v hostname >/dev/null 2>&1 && hostname -I >/dev/null 2>&1; then
|
||||
IP=$(hostname -I | awk '{print $1}')
|
||||
@@ -39,7 +35,6 @@ else
|
||||
IP="127.0.0.1"
|
||||
fi
|
||||
|
||||
# Install Prerequisites (Git, Make, Zsh, Sudo)
|
||||
echo -e "${YELLOW}LOG: Updating system and installing base tools...${NC}"
|
||||
|
||||
if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then
|
||||
@@ -54,7 +49,6 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Interactive Prompts
|
||||
if [ -t 0 ]; then
|
||||
echo -e "${GREEN}---------------------------------------${NC}"
|
||||
echo -e "${GREEN} USER PROVISIONING WIZARD ${NC}"
|
||||
@@ -70,13 +64,11 @@ if [ -t 0 ]; then
|
||||
USER_GID=${INPUT_GID:-$DEFAULT_GID}
|
||||
else
|
||||
echo -e "${YELLOW}LOG: Non-interactive session detected. Using defaults.${NC}"
|
||||
# Allow Environment Variables to override defaults in Docker/Headless
|
||||
USERNAME=${USERNAME:-$DEFAULT_USER}
|
||||
USER_UID=${USER_UID:-$DEFAULT_UID}
|
||||
USER_GID=${USER_GID:-$DEFAULT_GID}
|
||||
fi
|
||||
|
||||
# Group Creation
|
||||
if getent group "$USER_GID" >/dev/null; then
|
||||
echo -e "${YELLOW}LOG: Group with GID $USER_GID already exists. Using it.${NC}"
|
||||
else
|
||||
@@ -84,39 +76,30 @@ else
|
||||
groupadd -g "$USER_GID" "$USERNAME"
|
||||
fi
|
||||
|
||||
# User Creation
|
||||
if id "$USERNAME" &>/dev/null; then
|
||||
echo -e "${YELLOW}LOG: User $USERNAME already exists. Skipping creation.${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}LOG: Creating user $USERNAME...${NC}"
|
||||
|
||||
# Create user with specific UID, GID, Groups, and Shell
|
||||
useradd -m -u "$USER_UID" -g "$USER_GID" -G "$SUDO_GROUP" -s "$ZSH_PATH" "$USERNAME"
|
||||
|
||||
echo -e "${GREEN}LOG: Setting password for $USERNAME...${NC}"
|
||||
|
||||
if [ -t 0 ]; then
|
||||
echo -e "${GREEN}LOG: Setting password for $USERNAME...${NC}"
|
||||
passwd "$USERNAME"
|
||||
else
|
||||
# Docker/Automated: Set password to be the same as username
|
||||
echo -e "${YELLOW}LOG: Non-interactive: Setting password to '$USERNAME'...${NC}"
|
||||
echo "$USERNAME:$USERNAME" | chpasswd
|
||||
fi
|
||||
fi
|
||||
|
||||
# Sudo Configuration (Passwordless)
|
||||
echo -e "${YELLOW}LOG: Configuring passwordless sudo...${NC}"
|
||||
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > "/etc/sudoers.d/90-$USERNAME"
|
||||
chmod 0440 "/etc/sudoers.d/90-$USERNAME"
|
||||
|
||||
# Arch Specific: Uncomment wheel in sudoers if not already active
|
||||
if [ "$OS" == "arch" ]; then
|
||||
# Ensure the 'wheel' group is actually enabled in the main config if drop-in fails
|
||||
sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers
|
||||
fi
|
||||
|
||||
# Cloning Dotfiles
|
||||
echo -e "${YELLOW}LOG: Cloning dotfiles for $USERNAME...${NC}"
|
||||
sudo -u "$USERNAME" git clone https://git.mangopig.tech/MangoPig/Dot-Zsh.git "/home/$USERNAME/Config/Dot-Zsh"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user