65 lines
1.6 KiB
Bash
65 lines
1.6 KiB
Bash
!#/bin/bash
|
|
|
|
read -p "Do you want to create a new sudo user? (yes/no): " response
|
|
|
|
response=$(echo "$response" | tr '[:upper:]' '[:lower:]')
|
|
|
|
if [[ "$response" == "yes" || "$response" == "y" ]]; then
|
|
read -p "Enter the username for the new sudo user: " username
|
|
|
|
# Check if the username already exists
|
|
if id "$username" &>/dev/null; then
|
|
echo "User '$username' already exists."
|
|
exit 1
|
|
fi
|
|
|
|
# Create the new user using adduser
|
|
sudo adduser "$username"
|
|
if [[ $? -ne 0 ]]; then
|
|
echo "Failed to create user '$username'."
|
|
exit 1
|
|
fi
|
|
|
|
# Add the user to the sudo group
|
|
sudo usermod -aG sudo "$username"
|
|
if [[ $? -eq 0 ]]; then
|
|
echo "User '$username' has been added to the sudo group."
|
|
else
|
|
echo "Failed to add '$username' to the sudo group."
|
|
exit 1
|
|
fi
|
|
|
|
echo "New sudo user '$username' has been created successfully."
|
|
else
|
|
echo "No user was created."
|
|
fi
|
|
|
|
echo "Intalling nix and home-manager"
|
|
|
|
sh <(curl -L https://nixos.org/nix/install) --no-daemon
|
|
|
|
mkdir -p ~/.config/nix
|
|
echo "experimental-features = nix-command flakes" >>~/.config/nix/nix.conf
|
|
|
|
. ~/.nix-profile/etc/profile.d/nix.sh
|
|
|
|
nix-channel --add https://nixos.org/channels/nixos-24.11 nixpkgs
|
|
nix-channel --add https://github.com/nix-community/home-manager/archive/release-24.11.tar.gz home-manager
|
|
nix-channel --update
|
|
|
|
nix-shell '<home-manager>' -A install
|
|
|
|
cp -r home-manager/ ~/.config/
|
|
|
|
home-manager switch
|
|
|
|
sudo echo "/home/$USER/.nix-profile/bin/zsh" | sudo tee -a /etc/shells
|
|
|
|
chsh -s /home/$USER/.nix-profile/bin/zsh $USER
|
|
|
|
source ~/.zshrc
|
|
|
|
#sudo echo ". ~/.nix-profile/etc/profile.d/nix.sh" | sudo tee -a ~/.bashrc
|
|
|
|
#sudo echo "zsh" | sudo tee -a ~/.bashrc
|