├── .gitignore ├── make_backup.sh ├── README.md ├── dev_env_mac.sh └── dev_env_deb_linux.sh /.gitignore: -------------------------------------------------------------------------------- 1 | tmp.sh 2 | clear_var_log.sh 3 | -------------------------------------------------------------------------------- /make_backup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Path: make_backup.sh 4 | # Execute this script as root 5 | # For executing run: sudo ./make_backup.sh 6 | 7 | # make sure the script is running as root 8 | 9 | if [[ $EUID -ne 0 ]]; then 10 | echo "This script must be run as root." 11 | exit 1 12 | fi 13 | 14 | DIR_ARRAY=( "/etc" "/home" "/var/www" "/var/lib/mysql" ) 15 | BACKUP_DIR="/home/backup" 16 | 17 | # create backup directory if it doesn't exist 18 | if [ ! -d "$BACKUP_DIR" ]; then 19 | mkdir -p $BACKUP_DIR 20 | fi 21 | 22 | if [ ! -d "$BACKUP_DIR" ]; then 23 | echo "Backup directory $BACKUP_DIR doesn't exist and couldn't be created." 24 | exit 1 25 | fi 26 | 27 | # create backup file 28 | BACKUP_FILE="$BACKUP_DIR/backup_$(date +%Y%m%d_%H%M%S).tar.gz" 29 | 30 | # create tar.gz archive 31 | tar -cpzf $BACKUP_FILE ${DIR_ARRAY[*]} 32 | 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Environment-setup-scripts 2 | 3 | This repo contains script files for easy handling of your linux system. 4 | 5 | ### [Development Environment setup - Debian Linux](./dev_env_deb_linux.sh) 6 | This script updates all packages and then installs build-essential, python, python-is-python3, git, npm along with angular-cli and express generator for setting up the angular development environment 7 | 8 | 9 | ### [Development Environment setup - Macintosh](./dev_env_mac.sh) 10 | This script is for setting up the development environment in macintosh by installing homebrew and multiple packages, namely files for C++, openjdk, python3 and cakebrew , configuring git and installing angular-cli and express generator for setting up the angular development environment 11 | 12 | 13 | 14 | #### Steps for running the scripts 15 | 1. Clone the repo 16 | ``` 17 | git clone https://github.com/KartikAroraOfficial/Environment-setup-scripts.git 18 | ``` 19 | 2. Give the script file executable permission 20 | ``` 21 | chmod +x 22 | ``` 23 | 3. Run the script file 24 | ``` 25 | ./ 26 | ``` 27 | 4. Follow the instructions on the terminal. 28 | 29 | 30 | Note: You may be asked to enter a password for sudo commands in the script for the first time and then it's all rainbows and sunshine from there. Enter the password and the script will run automatically and will ask for occassional prompts like your name and email for git configuration. 31 | 32 | **NB** : The script files are tested on Debian Linux and Macintosh. The script files are not tested on other operating systems. Please create an issue if you find any bug or error in the script files. 33 | -------------------------------------------------------------------------------- /dev_env_mac.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### This script is for a Mac environment ### 4 | 5 | # Check if Xcode tools are already installed 6 | if ! command -v xcode-select &>/dev/null; then 7 | echo "Installing Xcode tools..." 8 | xcode-select --install 9 | else 10 | echo "Xcode tools are already installed." 11 | fi 12 | 13 | # Check if Homebrew is already installed 14 | if ! command -v brew &>/dev/null; then 15 | echo "Installing Homebrew..." 16 | curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh 17 | else 18 | echo "Homebrew is already installed." 19 | fi 20 | 21 | # Setup git if not configured 22 | if [[ -z $(git config --global user.name) ]]; then 23 | read -p "Enter the Name for the GitHub account: " git_name 24 | git config --global user.name "$git_name" 25 | fi 26 | 27 | if [[ -z $(git config --global user.email) ]]; then 28 | read -p "Enter the email address for the GitHub account: " git_email 29 | git config --global user.email "$git_email" 30 | ssh-keygen -t ed25519 -C "$git_email" 31 | eval "$(ssh-agent -s)" 32 | ssh-add ~/.ssh/id_ed25519 33 | echo "Public key:" 34 | cat ~/.ssh/id_ed25519.pub | pbcopy 35 | echo "Public key copied to clipboard." 36 | fi 37 | 38 | # Check if nvm is already installed 39 | if ! command -v nvm &>/dev/null; then 40 | echo "Installing nvm..." 41 | curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash 42 | source ~/.nvm/nvm.sh 43 | else 44 | echo "nvm is already installed." 45 | fi 46 | 47 | # Check if Node.js is already installed 48 | if ! command -v node &>/dev/null; then 49 | echo "Installing Node.js..." 50 | nvm install node --lts 51 | nvm use node --lts 52 | else 53 | echo "Node.js is already installed." 54 | fi 55 | 56 | # Install required packages using Homebrew 57 | echo "Installing packages via Homebrew..." 58 | brew_packages=("python@3.9" "openjdk" "cakebrew" "gcc" "g++" "make" "cmake" "gdb" "valgrind" "clang-format" "clang-tidy" "clang") 59 | for package in "${brew_packages[@]}"; do 60 | if ! brew list "$package" &>/dev/null; then 61 | echo "Installing $package..." 62 | sudo brew install "$package" 63 | else 64 | echo "$package is already installed." 65 | fi 66 | done 67 | 68 | echo "Setup complete!" -------------------------------------------------------------------------------- /dev_env_deb_linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check if the script is running as root 4 | if [[ $EUID -eq 0 ]]; then 5 | echo "This script must not be run as root." 6 | exit 87 7 | fi 8 | 9 | # Prompt the user to update sources.list 10 | read -p "Would you like to update sources.list with recommended contents? (y/n): " update_sources 11 | if [[ $update_sources == "y" ]]; then 12 | # Determine the Debian version codename 13 | debian_version=$(lsb_release -cs) 14 | sources_content="deb https://ftp.debian.org/debian/ $debian_version contrib main non-free non-free-firmware 15 | # deb-src https://ftp.debian.org/debian/ $debian_version contrib main non-free non-free-firmware 16 | 17 | deb https://ftp.debian.org/debian/ $debian_version-updates contrib main non-free non-free-firmware 18 | # deb-src https://ftp.debian.org/debian/ $debian_version-updates contrib main non-free non-free-firmware 19 | 20 | deb https://ftp.debian.org/debian/ $debian_version-proposed-updates contrib main non-free non-free-firmware 21 | # deb-src https://ftp.debian.org/debian/ $debian_version-proposed-updates contrib main non-free non-free-firmware 22 | 23 | deb https://ftp.debian.org/debian/ $debian_version-backports contrib main non-free non-free-firmware 24 | # deb-src https://ftp.debian.org/debian/ $debian_version-backports contrib main non-free non-free-firmware 25 | 26 | deb https://security.debian.org/debian-security/ $debian_version-security contrib main non-free non-free-firmware 27 | # deb-src https://security.debian.org/debian-security/ $debian_version-security contrib main non-free non-free-firmware" 28 | echo "$sources_content" | sudo tee /etc/apt/sources.list > /dev/null 29 | echo "Updated sources.list with recommended contents." 30 | fi 31 | 32 | # Update and upgrade 33 | read -p "Would you like to update the package list? (y/n): " update_packages 34 | if [[ $update_packages == "y" ]]; then 35 | sudo apt update 36 | fi 37 | 38 | sudo apt full-upgrade -y 39 | 40 | # Check if Google Chrome is installed 41 | if ! command -v google-chrome &>/dev/null; then 42 | read -p "Google Chrome is not installed. Would you like to install it? (y/n): " install_chrome 43 | if [[ $install_chrome == "y" ]]; then 44 | wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb 45 | sudo apt install ./google-chrome-stable_current_amd64.deb -y 46 | else 47 | echo "Skipping Google Chrome installation." 48 | fi 49 | else 50 | echo "Google Chrome is already installed." 51 | fi 52 | 53 | # Check if Docker is installed 54 | if ! command -v docker &>/dev/null; then 55 | read -p "Docker is not installed. Would you like to install it? (y/n): " install_docker 56 | if [[ $install_docker == "y" ]]; then 57 | # Install Docker 58 | sudo systemctl start docker 59 | sudo systemctl enable docker 60 | sudo usermod -aG docker $USER 61 | else 62 | echo "Skipping Docker installation." 63 | fi 64 | else 65 | echo "Docker is already installed." 66 | fi 67 | 68 | # Install NVM and Node.js 69 | curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash 70 | nvm install --lts 71 | nvm use --lts 72 | 73 | # Define APT packages 74 | APT_PACKAGES=("build-essential" "python-is-python3" "python3" "python3-pip" "mongodb" "mysql" "postgresql" "git" "npm" "snapd") 75 | 76 | # Prompt user to install build-essential 77 | read -p "Would you like to install build-essential? (y/n): " install_build_essential 78 | if [[ $install_build_essential == "y" ]]; then 79 | APT_PACKAGES+=("build-essential") 80 | fi 81 | 82 | # Install APT packages 83 | for PACKAGE in "${APT_PACKAGES[@]}"; do 84 | if ! command -v "$PACKAGE" &>/dev/null; then 85 | echo "Installing $PACKAGE..." 86 | sudo apt install "$PACKAGE" -y 87 | else 88 | echo "$PACKAGE is already installed." 89 | fi 90 | done 91 | 92 | # Prompt the user to install Angular 93 | read -p "Would you like to install Angular CLI? (y/n): " install_angular 94 | if [[ $install_angular == "y" ]]; then 95 | npm i -g @angular/cli 96 | fi 97 | 98 | # Prompt the user to install Express app generator 99 | read -p "Would you like to install Express app generator? (y/n): " install_express_generator 100 | if [[ $install_express_generator == "y" ]]; then 101 | npm i -g express-generator 102 | fi 103 | 104 | # Prompt the user to set up Git 105 | read -p "Would you like to set up Git (name and email)? (y/n): " setup_git 106 | if [[ $setup_git == "y" ]]; then 107 | read -p "Enter name for git config: " Name 108 | git config --global user.name "${Name}" 109 | read -p "Enter email for ssh key: " Email 110 | git config --global user.email "${Email}" 111 | 112 | # Setup Git using SSH 113 | ssh-keygen -t ed25519 -C "${Email}" 114 | eval "$(ssh-agent -s)" 115 | ssh-add ~/.ssh/id_ed25519 116 | sudo apt install xclip 117 | xclip -selection clipboard < ~/.ssh/id_ed25519.pub 118 | cat ~/.ssh/id_ed25519.pub 119 | 120 | echo "Now go to github.com and add the SSH key to your account." 121 | fi 122 | 123 | # Create a log file 124 | log_file="installation_log.txt" 125 | echo "Script execution completed. You can find log details in $log_file." 126 | 127 | # Redirect stdout and stderr to the log file 128 | exec &> "$log_file" 129 | 130 | # Notify user of log location 131 | echo "Script execution completed. Log details are available in $log_file." 132 | --------------------------------------------------------------------------------