Update: System Setup scripts

Add: dotfiles-setup.sh
This commit is contained in:
Rodolfo 2024-06-27 15:24:32 +08:00
parent de714d18e6
commit 5b1c384051
5 changed files with 96 additions and 24 deletions

View file

@ -0,0 +1,19 @@
#!/bin/bash
home_dir="/home/""$(ls /home/)"
if [[ -d $home_dir ]]; then
echo "Has valid home directory"
while [[ true ]]; do
if [[ -d $home_dir/Repos ]]; then
echo "Has valid Repos directory"
read -p "Enter your dotfiles repo: " repo
echo "git clone $repo $home_dir/Repos"
break
else
mkdir $home_dir/Repos
fi
done
else
echo "no valid home directory"
fi

View file

@ -1,3 +1,24 @@
#!/bin/bash #!/bin/bash
echo "git-setup" if [[ $1 == "Debian" ]]; then
echo "$1 git-setup"
echo "apt-get install git"
elif [[ $1 == "Arch" ]]; then
echo "$1 git-setup"
echo "pacman -S git"
while [[ true ]]; do
read -p "Git Setup: Enter your full name: " name
read -p "Git Setup: Enter your email address: " email
if [[ ! -z $name && ! -z $email ]]; then
break
else
echo "Invalid name or address, Please re-enter"
fi
done
echo "git config --global user.name $name"
echo "git config --global user.email $email"
fi

View file

@ -1,19 +1,15 @@
#!/bin/bash #!/bin/bash
APT_CMD=$(which apt-get) if [[ $1 == "Debian" ]]; then
PACMAN_CMD=$(which pacman)
if [[ ! -z $APT_CMD ]]; then echo "$1 Sources Setup"
echo "System Identified: Debian"
echo "apt-get update && apt-get -y upgrade" echo "apt-get update && apt-get -y upgrade"
while true;do while true;do
read -rp "Would you like to use Debian Unstable? (y/n): " answer read -rp "Would you like to use Debian Unstable? (y/n): " answer
answer="${answer,,}" answer="${answer,,}"
if [[ "$answer" = "y" ]]; then if [[ "$answer" = "y" ]]; then
echo "Change apt sources" echo "Changing apt sources"
echo "cp -v ./debian-assets/debian-sid-sources.list /etc/sources.list" echo "cp -v ./debian-assets/debian-sid-sources.list /etc/apt/sources.list"
echo "apt-get update && apt-get -y dist-upgrade" echo "apt-get update && apt-get -y dist-upgrade"
break break
elif [[ "$answer" = "n" ]]; then elif [[ "$answer" = "n" ]]; then
@ -23,7 +19,7 @@ if [[ ! -z $APT_CMD ]]; then
echo "Invalid Input. Please enter 'y' or 'n'." echo "Invalid Input. Please enter 'y' or 'n'."
fi fi
done done
elif [[ ! -z $PACMAN_CMD ]]; then elif [[ $1 == "Arch" ]]; then
echo "Arch" echo "$1 Sources Setup"
fi fi

View file

@ -1,3 +1,39 @@
#!/bin/bash #!/bin/bash
echo "sudo setup" read -p "Enter the user to add to Sudo: " username
if [[ $1 == "Debian" ]]; then
echo "$1 Sudo Setup"
while [[ true ]]; do
if [[ ! -z $(grep $username /etc/passwd) ]]; then
echo "usermod -aG sudo $username"
if [[ -f /home/$username/ ]]; then
echo "Home exists"
else
echo "Home doesn't Exist"
fi
break
else
read -p "Invalid Username. Use an valid existing username." username
fi
done
elif [[ $1 == "Arch" ]]; then
echo "$1 Sudo Setup"
while [[ true ]]; do
if [[ ! -z $(grep $username /etc/passwd) ]]; then
echo "usermod -aG wheel $username"
if [[ -f /home/$username/ ]]; then
echo "Home exists"
else
echo "Home doesn't Exist"
fi
break
else
read -p "Invalid Username. Use a valid existing username:" username
fi
done
fi

View file

@ -2,24 +2,24 @@
# Parent installer for all System Setup Scripts. # Parent installer for all System Setup Scripts.
APT_CMD=$(which apt-get) if [[ ! -z $(which apt-get) ]]; then
PACMAN_CMD=$(which pacman)
if [[ -z $APT_CMD ]]; then
system=Debian system=Debian
echo "System Identified: Debian" echo "System Identified: $system"
elif [[ -z $PACMAN_CMD ]]; then elif [[ ! -z $(which pacman) ]]; then
system=Arch system=Arch
echo "System Identified: Arch" echo "System Identified: $system"
else else
echo "System Misconfigured" echo "System Misconfigured"
break break
fi fi
systemsetup="./scripts/" systemsetup="./scripts/system-setup"
bash $systemsetup/sources-setup.sh $system for FILE in "$systemsetup"/*
bash $systemsetup/sudo-setup.sh $system do
bash $systemsetup/git-setup.sh $system if [[ -f "$FILE" ]]; then
bash $FILE $system
fi
done
echo "done" echo "done"