Skip to content

Instantly share code, notes, and snippets.

@copy-and-paste
Created August 27, 2020 15:07
Show Gist options
  • Save copy-and-paste/11b5147541f39ba8d1d1e8c516f04340 to your computer and use it in GitHub Desktop.
Save copy-and-paste/11b5147541f39ba8d1d1e8c516f04340 to your computer and use it in GitHub Desktop.

Revisions

  1. copy-and-paste created this gist Aug 27, 2020.
    67 changes: 67 additions & 0 deletions setup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,67 @@
    #!/bin/bash

    RED=`tput setaf 1`
    RESET=`tput sgr0`

    echo "${RED}[+] Installing the latest version of Go...${RESET}"
    LATEST_GO=$(wget -qO- https://golang.org/dl/ | grep -oP 'go([0-9\.]+)\.linux-amd64\.tar\.gz' | head -n 1 | grep -oP 'go[0-9\.]+' | grep -oP '[0-9\.]+' | head -c -2)
    wget https://dl.google.com/go/go$LATEST_GO.linux-amd64.tar.gz
    sudo tar -C /usr/local -xzf go$LATEST_GO.linux-amd64.tar.gz
    echo 'export GOROOT=/usr/local/go
    export GOPATH=$HOME/go
    export PATH=$GOPATH/bin:$GOROOT/bin:$PATH' >> ~/.profile
    rm -rf go$LATEST_GO*
    echo "${RED}[+] Testing Golang...${RESET}"
    . $HOME/.profile
    go version

    echo "${RED}[+] Setting up Ubuntu Box...${RESET}"
    echo "${RED}[+]\tGeting updates...${RESET}"
    sudo apt-get update -qq >> /dev/null 2>&1
    echo "${RED}[+]\tGeting upgrades...${RESET}"
    sudo apt-get upgrade -y -qq >> /dev/null 2>&1
    echo "${RED}[+]\tInstalling tools...${RESET}"
    sudo apt-get -y -qq install git postgresql python3-pip libldns-dev gcc g++ make libpcap-dev xsltproc curl nmap jq ruby-full chromium-chromedriver firefox-geckodriver parallel >> /dev/null 2>&1
    echo "${RED}[+]\tInstalling python2...${RESET}"
    sudo add-apt-repository universe >> /dev/null 2>&1
    sudo apt update -qq >> /dev/null 2>&1
    sudo apt install python2 -y -qq >> /dev/null 2>&1
    curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py >> /dev/null 2>&1
    sudo python2 get-pip.py >> /dev/null 2>&1

    echo "${RED}[+] Installing zsh...${RESET}"
    sudo apt-get install zsh -y -qq >> /dev/null 2>&1
    echo | sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" --yes >> /dev/null 2>&1
    sudo usermod -s $(which zsh) $(whoami) >> /dev/null 2>&1
    git clone https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k >> /dev/null 2>&1
    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting >> /dev/null 2>&1
    git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-completions >> /dev/null 2>&1
    git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search >> /dev/null 2>&1
    git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions >> /dev/null 2>&1

    sed -i 's/robbyrussell/powerlevel10k\/powerlevel10k/g' $HOME/.zshrc
    sed -i 's/plugins=(git)/plugins=(\n git\n zsh-syntax-highlighting\n zsh-autosuggestions\n history-substring-search\n)/g' $HOME/.zshrc
    echo "autoload -U compinit && compinit" >> $HOME/.zshrc
    touch $HOME/.bash_aliases
    echo "source ~/.bash_aliases
    source ~/.profile" >> $HOME/.zshrc

    echo "${RED}[*] Install nodejs [*]${RESET}"
    curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - >> /dev/null 2>&1
    sudo apt-get install -y nodejs -qq >> /dev/null 2>&1

    echo "${RED}[+] Installing the tmux-config...${RESET}"
    git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm >> /dev/null 2>&1
    wget https://gist.github.com/copy-and-paste/7d03471f1306e829accdaef75285867e/raw/ac3ce935d18060080422129d70dea7a6a059f664/.tmux.conf >> /dev/null 2>&1

    echo "${RED}[+] Setting swap...${RESET}"
    sudo fallocate -l 4G /swapfile
    sudo chmod 600 /swapfile
    sudo mkswap /swapfile
    sudo swapon /swapfile
    sudo cp /etc/fstab /etc/fstab.bak
    echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
    echo "vm.swappiness=10
    vm.vfs_cache_pressure=50" | sudo tee -a /etc/sysctl.conf

    echo "${RED}[+] Done\nReboot the server...${RESET}"