Skip to content

Instantly share code, notes, and snippets.

@frizbee
Last active July 9, 2020 07:14
Show Gist options
  • Save frizbee/d6dca6ade96e66a2cae11ffb7e52e79d to your computer and use it in GitHub Desktop.
Save frizbee/d6dca6ade96e66a2cae11ffb7e52e79d to your computer and use it in GitHub Desktop.

Revisions

  1. frizbee revised this gist Jul 9, 2020. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions centos7.setup.sh
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,8 @@ red=`tput setaf 1`
    green=`tput setaf 2`
    reset=`tput sgr0`
    VIMREPO="https://gist.github.com/frizbee/8174f50d6863666efb217615bc1ecfac/raw/42db6ec0527de01e1215ca29689ea7ef10b7d51d/vimrc"
    GITNAME="Name"
    GITEMAIL="[email protected]"

    beginDeploy() {
    echo
    @@ -173,9 +175,9 @@ rbenv rehash

    beginDeploy "############# Setup GIT ##############"
    git config --global color.ui true
    git config --global user.name "Name"
    git config --global user.email "[email protected]"
    # ssh-keygen -t rsa -b 4096 -C "[email protected]"
    git config --global user.name "$GITNAME"
    git config --global user.email "$GITEMAIL"
    # ssh-keygen -t rsa -b 4096 -C "$GITEMAIL"

    if [ ! -d "$HOME/tig" ]; then
    echo "${green}Setup Tig${reset}"
  2. frizbee revised this gist Jul 9, 2020. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions centos7.setup.sh
    Original file line number Diff line number Diff line change
    @@ -177,3 +177,10 @@ git config --global user.name "Name"
    git config --global user.email "[email protected]"
    # ssh-keygen -t rsa -b 4096 -C "[email protected]"

    if [ ! -d "$HOME/tig" ]; then
    echo "${green}Setup Tig${reset}"
    git clone https://github.com/jonas/tig.git ~/tig
    cd ~/tig
    make
    make install
    fi
  3. frizbee revised this gist Jul 9, 2020. 1 changed file with 8 additions and 3 deletions.
    11 changes: 8 additions & 3 deletions centos7.setup.sh
    Original file line number Diff line number Diff line change
    @@ -15,6 +15,7 @@ beginDeploy() {
    }

    sudo yum update
    sudo yum -y install guake # setup Guake terminal, beter that builtin

    beginDeploy "######### ZSH ##########"
    # Setup ZSH
    @@ -144,7 +145,7 @@ if [ ! -d "$HOME/.rbenv" ]; then
    echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
    echo 'eval "$(rbenv init -)"' >> ~/.zshrc
    else
    echo "${green}Upgrading ruby-build${reset}"
    echo "${green}Upgrading rbenv${reset}"
    git -C "$(rbenv root)" pull
    fi
    #exec $SHELL
    @@ -158,9 +159,13 @@ else
    git -C "$(rbenv root)"/plugins/ruby-build pull
    fi

    rbenv install 2.7.1
    rbenv global 2.7.1
    if [ ! -d "$HOME/.rbenv/versions/2.7.1" ]; then
    rbenv install 2.7.1
    rbenv global 2.7.1
    fi
    echo -n "${green}Current ruby: ${reset}"
    ruby -v

    echo "gem: --no-document" > ~/.gemrc
    gem install bundler
    gem install rails
  4. frizbee created this gist Jul 9, 2020.
    174 changes: 174 additions & 0 deletions centos7.setup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,174 @@
    #!/bin/bash

    # Default settings
    start=`date +%s`
    bold=$(tput bold)
    normal=$(tput sgr0)
    red=`tput setaf 1`
    green=`tput setaf 2`
    reset=`tput sgr0`
    VIMREPO="https://gist.github.com/frizbee/8174f50d6863666efb217615bc1ecfac/raw/42db6ec0527de01e1215ca29689ea7ef10b7d51d/vimrc"

    beginDeploy() {
    echo
    echo "${bold}$1${normal}"
    }

    sudo yum update

    beginDeploy "######### ZSH ##########"
    # Setup ZSH
    if [ ! -x "/usr/bin/zsh" ]; then
    sudo yum update && sudo yum -y install zsh
    sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    else
    echo "${green}ZSH already installed!${reset}"
    fi
    # source ~/.zshrc
    # Use this command if shell not changed: chsh -s /bin/zsh

    beginDeploy "######### edit ZSH ##########"
    zshrc="$HOME/.zshrc"
    echo -n "Do you want to edit zshrc? [y/n] > "
    editzshrc=
    read editzshrc
    if [ "$editzshrc" != "n" ]; then
    if [ -f "$zshrc" ]; then
    echo "$zshrc found"
    sed -i -e 's/(git)/(git ruby git-flow bundler)/g' $zshrc
    echo "alias update='sudo yum -y update'" >> $zshrc
    echo "alias gsweep='git branch --merged master | command grep -vE \"^(\*|\s*staging\s*|\s*develop\s*|\s*master\s*$)\" | command xargs -n 1 git branch -d'" >> $zshrc
    echo "alias gb=\"git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) | %(authorname) | (%(color:green)%(committerdate:relative)%(color:reset))| %(contents:subject) ' | column -t -s '|'"\" >> $zshrc
    else
    echo "$zshrc not found"
    echo "${red}Exit program!${reset}"
    exit 1
    fi
    else
    echo "${green}Skipping edit ZSHRC...${reset}"
    fi

    beginDeploy "######### Python ##########"
    if ! python3 -c 'import sys; print(sys.version_info[:])'; then
    sudo yum install -y python3
    python3 --version
    else
    echo "${green}Python already installed!${reset}"
    fi

    beginDeploy "######### Golang #########"
    # For CentOS 7 only
    # https://gist.github.com/RaviTezu/848dc4dee712d162503a0d9207728d34
    if [ -f "/bin/go" ]; then
    echo "${green}Go installed!${reset}"
    else
    sudo rpm --import https://mirror.go-repo.io/centos/RPM-GPG-KEY-GO-REPO
    curl -s https://mirror.go-repo.io/centos/go-repo.repo | sudo tee /etc/yum.repos.d/go-repo.repo
    sudo yum install golang
    mkdir ~/go
    which go
    fi

    beginDeploy "########## Intall RipGrep ############"
    if [ ! -x "/usr/bin/rg" ]; then
    sudo yum-config-manager --add-repo=https://copr.fedorainfracloud.org/coprs/carlwgeorge/ripgrep/repo/epel-7/carlwgeorge-ripgrep-epel-7.repo
    sudo yum install -y ripgrep
    else
    echo "${green}RipGrep already installed${reset}"
    fi

    beginDeploy "########### Install Plug and clone .vimrc ############"
    if [ -f "$HOME/.vim/autoload/plug.vim" ]; then
    echo "${green}Plug already installed${reset}"
    else
    curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
    fi

    if [ ! -d "$HOME/.vim" ]; then
    echo "${red}Vim not installed${reset}"
    # yum install gcc make ncurses ncurses-devel
    # yum install ctags git tcl-devel ruby-devel python-devel
    fi

    if [ -f ~/.vimrc ] || [ -h ~/.vimrc ]; then
    echo "${green}.vimrc already exists${reset}"
    echo -n "Do you want to rewreite it? [y/n] > "
    vimrc=
    read vimrc
    if [ "$vimrc" != "n" ]; then
    echo "${green}Removing old .vimrc${reset}"
    rm -f "$HOME/.vimrc"
    echo "${green}Cloning .vimrc${reset}"
    sh -c "curl -s $VIMREPO >> ~/.vimrc"
    else
    echo "${green}Skipping cloning .vimrc${reset}"
    fi
    else
    echo "${green}Cloning .vimrc${reset}"
    if [ -d "$HOME/.vim" ]; then
    sh -c "curl -s $VIMREPO >> ~/.vimrc"
    else
    echo "${red}Please install VIM first${reset}"
    echo "${red}Exit program{$reset}"
    exit 1
    fi
    fi

    beginDeploy "############# Setup Ruby with libraries ##############"

    sudo yum install -y git-core \
    zlib \
    zlib-devel \
    gcc-c++ \
    patch \
    readline \
    readline-devel \
    libyaml-devel \
    libffi-devel \
    openssl-devel \
    make \
    bzip2 \
    autoconf \
    automake \
    libtool \
    bison \
    curl \
    sqlite-devel \
    nodejs \
    yarn

    cd ~
    if [ ! -d "$HOME/.rbenv" ]; then
    git clone git://github.com/sstephenson/rbenv.git .rbenv
    echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
    echo 'eval "$(rbenv init -)"' >> ~/.zshrc
    else
    echo "${green}Upgrading ruby-build${reset}"
    git -C "$(rbenv root)" pull
    fi
    #exec $SHELL

    if [ ! -d "$HOME/.rbenv/plugins/ruby-build" ]; then
    git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
    echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.zshrc
    #exec $SHELL
    else
    echo "${green}Upgrading ruby-build${reset}"
    git -C "$(rbenv root)"/plugins/ruby-build pull
    fi

    rbenv install 2.7.1
    rbenv global 2.7.1
    ruby -v
    echo "gem: --no-document" > ~/.gemrc
    gem install bundler
    gem install rails
    rbenv rehash

    beginDeploy "############# Setup GIT ##############"
    git config --global color.ui true
    git config --global user.name "Name"
    git config --global user.email "[email protected]"
    # ssh-keygen -t rsa -b 4096 -C "[email protected]"