Skip to content

Instantly share code, notes, and snippets.

@toamitkumar
Forked from fnichol/README.md
Created July 17, 2011 01:33
Show Gist options
  • Select an option

  • Save toamitkumar/1087010 to your computer and use it in GitHub Desktop.

Select an option

Save toamitkumar/1087010 to your computer and use it in GitHub Desktop.

Revisions

  1. @fnichol fnichol revised this gist Mar 31, 2011. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions suse_chef_bootstrap.sh
    Original file line number Diff line number Diff line change
    @@ -104,6 +104,7 @@ ensure_current_sqlite() {
    }

    install_chef_gem() {
    log "Installing chef gem..."
    rvm $__rvm_ruby gem install chef --no-ri --no-rdoc
    }

    @@ -112,6 +113,7 @@ clone_chef_repo() {
    __cookbooks_path="$__cookbooks_path_default"
    fi

    log "Cloning chef repo into $__cookbooks_path..."
    mkdir -p $(dirname $__cookbooks_path)
    git clone git://github.com/fnichol/chef-repo.git $__cookbooks_path
    }
    @@ -179,4 +181,6 @@ install_chef_gem

    clone_chef_repo

    installation_complete

    exit 0
  2. @fnichol fnichol revised this gist Mar 31, 2011. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion suse_chef_bootstrap.sh
    Original file line number Diff line number Diff line change
    @@ -108,8 +108,12 @@ install_chef_gem() {
    }

    clone_chef_repo() {
    if [[ -z "$__cookbooks_path" ]] ; then
    __cookbooks_path="$__cookbooks_path_default"
    fi

    mkdir -p $(dirname $__cookbooks_path)
    git clone git://github.com/fnichol/chef-repo.git /var/chef-solo
    git clone git://github.com/fnichol/chef-repo.git $__cookbooks_path
    }

    installation_complete() {
  3. @fnichol fnichol revised this gist Mar 31, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion suse_chef_bootstrap.sh
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ __rvm_ruby_default="ruby-1.9.2-p180"

    __cookbooks_path_default="/var/chef-solo"

    log() { printf "$*\n" ; return $? ; }
    log() { printf "===> $*\n" ; return $? ; }

    fail() { log "\nERROR: $*\n" ; exit 1 ; }

  4. @fnichol fnichol revised this gist Mar 31, 2011. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,11 @@

    *Note:* Run this script as the `root` user (no sudo calls are used in the script).

    You will need the *curl* package installed, though I would have no idea why
    it wouldn't be installed by default:

    zypper --non-interactive install curl

    To perform a default prep:

    bash <(curl -LB https://gist.github.com/raw/895325/suse_chef_bootstrap.sh)
  5. @fnichol fnichol revised this gist Mar 31, 2011. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -10,11 +10,13 @@ To perform a default prep:

    You can specify an RVM version (`[head|latest|x.y.z]`):

    bash <(curl -LB https://gist.github.com/raw/895325/suse_chef_bootstrap.sh) --rvm-version 1.5.3
    bash <(curl -LB https://gist.github.com/raw/895325/suse_chef_bootstrap.sh) \
    --rvm-version 1.5.3

    You can also override the default ruby (currently `ruby-1.9.2-p180`):

    bash <(curl -LB https://gist.github.com/raw/895325/suse_chef_bootstrap.sh) --rvm-ruby ree-1.8.7-2010.03
    bash <(curl -LB https://gist.github.com/raw/895325/suse_chef_bootstrap.sh) \
    --rvm-ruby ree-1.8.7-2010.03

    ## What Is Going On

  6. @fnichol fnichol revised this gist Mar 31, 2011. 1 changed file with 22 additions and 0 deletions.
    22 changes: 22 additions & 0 deletions suse_chef_bootstrap.sh
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,8 @@ __mri_pkgs=( gcc-c++ patch zlib zlib-devel libffi-devel sqlite3-devel libxml2-de

    __rvm_ruby_default="ruby-1.9.2-p180"

    __cookbooks_path_default="/var/chef-solo"

    log() { printf "$*\n" ; return $? ; }

    fail() { log "\nERROR: $*\n" ; exit 1 ; }
    @@ -101,6 +103,22 @@ ensure_current_sqlite() {
    fi
    }

    install_chef_gem() {
    rvm $__rvm_ruby gem install chef --no-ri --no-rdoc
    }

    clone_chef_repo() {
    mkdir -p $(dirname $__cookbooks_path)
    git clone git://github.com/fnichol/chef-repo.git /var/chef-solo
    }

    installation_complete() {
    printf "
    Installation is complete.
    "
    }

    # Parse CLI arguments
    while [[ $# -gt 0 ]] ; do
    token="$1" ; shift
    @@ -153,4 +171,8 @@ ensure_current_sqlite

    install_rvm_ruby

    install_chef_gem

    clone_chef_repo

    exit 0
  7. @fnichol fnichol revised this gist Mar 31, 2011. 1 changed file with 29 additions and 0 deletions.
    29 changes: 29 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    # Chef Bootstrapper For SuSE/SLES

    ## Installation

    *Note:* Run this script as the `root` user (no sudo calls are used in the script).

    To perform a default prep:

    bash <(curl -LB https://gist.github.com/raw/895325/suse_chef_bootstrap.sh)

    You can specify an RVM version (`[head|latest|x.y.z]`):

    bash <(curl -LB https://gist.github.com/raw/895325/suse_chef_bootstrap.sh) --rvm-version 1.5.3

    You can also override the default ruby (currently `ruby-1.9.2-p180`):

    bash <(curl -LB https://gist.github.com/raw/895325/suse_chef_bootstrap.sh) --rvm-ruby ree-1.8.7-2010.03

    ## What Is Going On

    1. Install package pre-requisites needed for RVM
    2. Install RVM system-wide (gets installed into `/usr/local/rvm`)
    3. Install package pre-requisites needed to build MRI/REE rubies
    4. Ensure that Sqlite is current and build a version if it is not
    5. Install the RVM ruby and set it as the default
    6. Install the Chef gem
    7. Pull down the Chef cookbook repository from <http://github.com/fnichol/chef-repo> (gets installed to `/var/chef-solo`)

    The rest is up to you...
  8. @fnichol fnichol revised this gist Mar 31, 2011. 1 changed file with 7 additions and 2 deletions.
    9 changes: 7 additions & 2 deletions suse_chef_bootstrap.sh
    Original file line number Diff line number Diff line change
    @@ -51,9 +51,14 @@ install_rvm() {
    }

    install_rvm_ruby() {
    log "Install RVM ruby ${__rvm_ruby}..."
    if [[ -z "$__rvm_ruby" ]] ; then __rvm_ruby="$__rvm_ruby_default" ; fi
    rvm install $__rvm_ruby

    if rvm list strings | grep -q "^ruby-1.9.2-p180" >/dev/null ; then
    log "RVM ruby $__rvm_ruby is already installed, so skipping."
    else
    log "Install RVM ruby ${__rvm_ruby}..."
    rvm install $__rvm_ruby
    fi
    rvm $__rvm_ruby --default
    }

  9. @fnichol fnichol revised this gist Mar 30, 2011. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion suse_chef_bootstrap.sh
    Original file line number Diff line number Diff line change
    @@ -62,9 +62,10 @@ compile_sqlite() {
    local dl_dir="/tmp/sqlite-$$"

    log "Downloading sqlite3...."
    mkdir -p $dl_dir
    curl -L "http://www.sqlite.org/$tar" -o "$dl_dir/$tar"
    log "Extracting sqlite3..."
    (cd /var/tmp && tar -zxf "$dl_dir/$tar")
    (cd $dl_dir && tar -zxf "$dl_dir/$tar")
    log "Configuring sqlite3..."
    (cd $dl_dir/${tar%.tar.gz} && ./configure)
    log "Compiling and installing sqlite3..."
  10. @fnichol fnichol revised this gist Mar 30, 2011. 1 changed file with 9 additions and 2 deletions.
    11 changes: 9 additions & 2 deletions suse_chef_bootstrap.sh
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,8 @@ __rvm_pkgs=( sed grep tar gzip bzip2 bash curl git-core )

    __mri_pkgs=( gcc-c++ patch zlib zlib-devel libffi-devel sqlite3-devel libxml2-devel libxslt-devel libreadline5 readline-devel libopenssl-devel )

    __rvm_ruby_default="ruby-1.9.2-p180"

    log() { printf "$*\n" ; return $? ; }

    fail() { log "\nERROR: $*\n" ; exit 1 ; }
    @@ -39,19 +41,24 @@ install_mri_prerequisites() {
    }

    install_rvm() {
    local flags=""
    if [[ -n "$__rvm_version" ]] ; then flags=" --version $__rvm_version" ; fi
    if [[ -n "$__rvm_branch" ]] ; then flags=" --branch $__rvm_branch" ; fi

    log "Installing RVM..."
    bash <(curl -LB "http://rvm.beginrescueend.com/install/rvm")
    bash <(curl -LB "http://rvm.beginrescueend.com/install/rvm") $flags
    source /etc/profile.d/rvm.sh
    }

    install_rvm_ruby() {
    log "Install RVM ruby ${__rvm_ruby}..."
    if [[ -z "$__rvm_ruby" ]] ; then __rvm_ruby="$__rvm_ruby_default" ; fi
    rvm install $__rvm_ruby
    rvm $__rvm_ruby --default
    }

    compile_sqlite() {
    local tar="sqlite-autoconf-xxx.tar.gz"
    local tar="sqlite-autoconf-3070500.tar.gz"
    local dl_dir="/tmp/sqlite-$$"

    log "Downloading sqlite3...."
  11. @fnichol fnichol revised this gist Mar 30, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions suse_chef_bootstrap.sh
    Original file line number Diff line number Diff line change
    @@ -68,10 +68,10 @@ ensure_current_sqlite() {
    local current_version=$(sqlite3 --version)
    local need_upgrade=1

    if [[ $(echo $current_version | cut -d\. -f1) -ge 3 ]] ; then
    if [[ $(echo $current_version | cut -d\. -f1) -gt 3 ]] ; then
    need_upgrade=0
    elif [[ $(echo $current_version | cut -d\. -f1) -eq 3 ]] ; then
    if [[ $(echo $current_version | cut -d\. -f2) -ge 6 ]] ; then
    if [[ $(echo $current_version | cut -d\. -f2) -gt 6 ]] ; then
    need_upgrade=0
    elif [[ $(echo $current_version | cut -d\. -f2) -eq 6 ]] ; then
    if [[ $(echo $current_version | cut -d\. -f3) -ge 16 ]] ; then
  12. @fnichol fnichol revised this gist Mar 30, 2011. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions suse_chef_bootstrap.sh
    Original file line number Diff line number Diff line change
    @@ -113,6 +113,7 @@ while [[ $# -gt 0 ]] ; do

    --rvm-ruby)
    __rvm_ruby="$1"
    ;;

    help|usage)
    usage
  13. @fnichol fnichol revised this gist Mar 30, 2011. 1 changed file with 34 additions and 10 deletions.
    44 changes: 34 additions & 10 deletions suse_chef_bootstrap.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    #!/usr/bin/env bash

    rvm_pkgs=( sed grep tar gzip bzip2 bash curl git-core )
    __rvm_pkgs=( sed grep tar gzip bzip2 bash curl git-core )

    mri_pkgs=( gcc-c++ patch zlib zlib-devel libffi-devel sqlite3-devel libxml2-devel libxslt-devel libreadline5 readline-devel libopenssl-devel )
    __mri_pkgs=( gcc-c++ patch zlib zlib-devel libffi-devel sqlite3-devel libxml2-devel libxslt-devel libreadline5 readline-devel libopenssl-devel )

    log() { printf "$*\n" ; return $? ; }

    @@ -17,25 +17,37 @@ Usage
    Options
    --rvm-version <head|latest|x.y.z> - Install RVM version [head|latest|x.y.z]
    --rvm-version <head|latest|x.y.z> - Install RVM version [head|latest|x.y.z]
    --rvm-ruby <ruby-xxx-pxx|ree-1.8.2-xxx> - Install a specific RVM ruby
    Actions
    help - Display CLS help (this output)
    help - Display CLI help (this output)
    "
    }

    install_rvm_prerequisites() {
    zypper --non-interactive install -l "${rvm_pkgs[@]}"
    log "Installing RVM pre-requisite packages..."
    zypper --non-interactive install -l "${__rvm_pkgs[@]}"
    }

    install_mri_prerequisites() {
    zypper --non-interactive install -l "${mri_pkgs[@]}"
    log "Installing RVM MRI ruby pre-requisite packages..."
    zypper --non-interactive install -l "${__mri_pkgs[@]}"
    }

    install_rvm() {
    log "Installing RVM..."
    bash <(curl -LB "http://rvm.beginrescueend.com/install/rvm")
    source /etc/profile.d/rvm.sh
    }

    install_rvm_ruby() {
    log "Install RVM ruby ${__rvm_ruby}..."
    rvm install $__rvm_ruby
    rvm $__rvm_ruby --default
    }

    compile_sqlite() {
    @@ -69,7 +81,10 @@ ensure_current_sqlite() {
    fi

    if [[ $need_upgrade -eq 1 ]] ; then
    log "Version of sqlite found was too old, so building one..."
    compile_sqlite
    else
    log "Version of sqlite is good."
    fi
    }

    @@ -81,21 +96,24 @@ while [[ $# -gt 0 ]] ; do
    --rvm-version)
    case "$1" in
    *.*.*)
    rvm_version="$1" ; shift
    __rvm_version="$1" ; shift
    ;;
    latest|stable)
    rvm_version="latest"
    __rvm_version="latest"
    ;;
    head|master)
    rvm_version="head"
    rvm_branch="master"
    __rvm_version="head"
    __rvm_branch="master"
    ;;
    *)
    fail "--version must be followed by a valid version number x.y.z"
    ;;
    esac
    ;;

    --rvm-ruby)
    __rvm_ruby="$1"

    help|usage)
    usage
    exit 0
    @@ -115,4 +133,10 @@ install_rvm_prerequisites

    install_rvm

    install_mri_prerequisites

    ensure_current_sqlite

    install_rvm_ruby

    exit 0
  14. @fnichol fnichol revised this gist Mar 30, 2011. 1 changed file with 117 additions and 0 deletions.
    117 changes: 117 additions & 0 deletions suse_chef_bootstrap.sh
    Original file line number Diff line number Diff line change
    @@ -1 +1,118 @@
    #!/usr/bin/env bash

    rvm_pkgs=( sed grep tar gzip bzip2 bash curl git-core )

    mri_pkgs=( gcc-c++ patch zlib zlib-devel libffi-devel sqlite3-devel libxml2-devel libxslt-devel libreadline5 readline-devel libopenssl-devel )

    log() { printf "$*\n" ; return $? ; }

    fail() { log "\nERROR: $*\n" ; exit 1 ; }

    usage() {
    printf "
    Usage
    suse_chef_bootstrap.sh [options] [action]
    Options
    --rvm-version <head|latest|x.y.z> - Install RVM version [head|latest|x.y.z]
    Actions
    help - Display CLS help (this output)
    "
    }

    install_rvm_prerequisites() {
    zypper --non-interactive install -l "${rvm_pkgs[@]}"
    }

    install_mri_prerequisites() {
    zypper --non-interactive install -l "${mri_pkgs[@]}"
    }

    install_rvm() {
    bash <(curl -LB "http://rvm.beginrescueend.com/install/rvm")
    }

    compile_sqlite() {
    local tar="sqlite-autoconf-xxx.tar.gz"
    local dl_dir="/tmp/sqlite-$$"

    log "Downloading sqlite3...."
    curl -L "http://www.sqlite.org/$tar" -o "$dl_dir/$tar"
    log "Extracting sqlite3..."
    (cd /var/tmp && tar -zxf "$dl_dir/$tar")
    log "Configuring sqlite3..."
    (cd $dl_dir/${tar%.tar.gz} && ./configure)
    log "Compiling and installing sqlite3..."
    (cd $dl_dir/${tar%.tar.gz} && make && make install)
    }

    ensure_current_sqlite() {
    local current_version=$(sqlite3 --version)
    local need_upgrade=1

    if [[ $(echo $current_version | cut -d\. -f1) -ge 3 ]] ; then
    need_upgrade=0
    elif [[ $(echo $current_version | cut -d\. -f1) -eq 3 ]] ; then
    if [[ $(echo $current_version | cut -d\. -f2) -ge 6 ]] ; then
    need_upgrade=0
    elif [[ $(echo $current_version | cut -d\. -f2) -eq 6 ]] ; then
    if [[ $(echo $current_version | cut -d\. -f3) -ge 16 ]] ; then
    need_upgrade=0
    fi
    fi
    fi

    if [[ $need_upgrade -eq 1 ]] ; then
    compile_sqlite
    fi
    }

    # Parse CLI arguments
    while [[ $# -gt 0 ]] ; do
    token="$1" ; shift
    case "$token" in

    --rvm-version)
    case "$1" in
    *.*.*)
    rvm_version="$1" ; shift
    ;;
    latest|stable)
    rvm_version="latest"
    ;;
    head|master)
    rvm_version="head"
    rvm_branch="master"
    ;;
    *)
    fail "--version must be followed by a valid version number x.y.z"
    ;;
    esac
    ;;

    help|usage)
    usage
    exit 0
    ;;

    *)
    usage
    exit 1
    ;;

    esac
    done

    # Perform the actual installation

    install_rvm_prerequisites

    install_rvm

    ensure_current_sqlite
  15. @fnichol fnichol revised this gist Mar 30, 2011. 1 changed file with 0 additions and 0 deletions.
    Empty file modified suse_chef_bootstrap.sh
    100644 → 100755
    Empty file.
  16. @fnichol fnichol created this gist Mar 30, 2011.
    1 change: 1 addition & 0 deletions suse_chef_bootstrap.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    #!/usr/bin/env bash