This commit is contained in:
MangoPig 2025-12-03 05:52:28 +00:00
parent 056a59a07b
commit 4ac11a8dd4

View File

@ -7,20 +7,20 @@ YELLOW='\033[1;33m'
RED='\033[1;31m'
NC='\033[0m'
# 1. Root Check
# Root Check
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}Please run this script as root.${NC}"
exit 1
fi
# 2. OS Detection
# OS Detection
echo -e "${YELLOW}LOG: Detecting OS...${NC}"
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$ID
fi
# 3. Install Prerequisites (Git, Make, Zsh, Sudo)
# Install Prerequisites (Git, Make, Zsh, Sudo)
echo -e "${YELLOW}LOG: Updating system and installing base tools...${NC}"
if [ "$OS" == "arch" ] || [ "$OS" == "manjaro" ]; then
@ -35,7 +35,7 @@ else
exit 1
fi
# 4. Interactive Prompts
# Interactive Prompts
echo -e "${GREEN}---------------------------------------${NC}"
echo -e "${GREEN} USER PROVISIONING WIZARD ${NC}"
echo -e "${GREEN}---------------------------------------${NC}"
@ -49,7 +49,7 @@ USER_UID=${USER_UID:-1000}
read -p "Enter GID (default: 1000): " USER_GID
USER_GID=${USER_GID:-1000}
# 5. Group Creation
# 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
@ -57,7 +57,7 @@ else
groupadd -g "$USER_GID" "$USERNAME"
fi
# 6. User Creation
# User Creation
if id "$USERNAME" &>/dev/null; then
echo -e "${YELLOW}LOG: User $USERNAME already exists. Skipping creation.${NC}"
else
@ -73,15 +73,20 @@ else
passwd "$USERNAME"
fi
# 7. Sudo Configuration (Passwordless)
# 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"
# 8. Arch Specific: Uncomment wheel in sudoers if not already active
# 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"
echo -e "${GREEN}✅ Server Provisioned! Log out and SSH as $USERNAME.${NC}"