Skip to content

Instantly share code, notes, and snippets.

@juanxhos
Forked from fnichol/README.md
Last active February 20, 2017 15:20
Show Gist options
  • Save juanxhos/b182771187d67da12431002ba714a968 to your computer and use it in GitHub Desktop.
Save juanxhos/b182771187d67da12431002ba714a968 to your computer and use it in GitHub Desktop.
Chef Bootstrapper For SuSE/SLES
#!/usr/bin/env bash
# __pkgs=( gcc-c++ zlib zlib-devel libffi-devel sqlite3-devel libxml2-devel libxslt-devel libreadline5 readline-devel libopenssl-devel )
__pkgs=( gcc automake gdbm-devel libffi-devel libyaml-devel openssl-devel ncurses-devel readline-devel zlib-devel make )
log() { printf "===> $*\n" ; return $? ; }
fail() { log "\nERROR: $*\n" ; exit 1 ; }
install_prerequisites() {
log "Waiting for zypper..."
sleep 30
while [ $(pgrep -x zypper) ]; do echo "Waiting for zypper... PID $(pgrep zypper)"; sleep 10; done
log "Installing pre-requisite packages..."
sudo zypper --non-interactive install -l "${__pkgs[@]}"
}
install_chefdk() {
curl -L https://omnitruck.chef.io/install.sh | sudo bash -s -- -P chefdk
}
compile_sqlite() {
local tar="sqlite-autoconf-3070500.tar.gz"
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 $dl_dir && 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) -gt 3 ]] ; then
need_upgrade=0
elif [[ $(echo $current_version | cut -d\. -f1) -eq 3 ]] ; 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
need_upgrade=0
fi
fi
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
}
installation_complete() {
printf "
Installation is complete.
"
}
# Perform the actual installation
install_prerequisites
ensure_current_sqlite
install_chefdk
installation_complete
exit 0
$ChocoInstallPathOld = "$env:SystemDrive\Chocolatey\bin"
$ChocoInstallPath = "$env:SystemDrive\ProgramData\chocolatey\bin"
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$ChocoInstallPath", [EnvironmentVariableTarget]::Machine)
$env:Path += ";$ChocoInstallPath"
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install -y mingw
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\tools\mingw64\bin", [EnvironmentVariableTarget]::Machine)
$env:Path += ";C:\tools\mingw64\bin"
$omniUrl = "https://omnitruck.chef.io/install.ps1"
$installScript = Invoke-WebRequest -UseBasicParsing $omniUrl
$installScript | Invoke-Expression
install -channel stable -project chefdk
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\opscode\chefdk\bin", [EnvironmentVariableTarget]::Machine)
$env:Path += ";C:\opscode\chefdk\bin"
[Environment]::SetEnvironmentVariable("Path", $env:Path + "c:\users\administrator\appdata\local\chefdk\gem\ruby\2.3.0\bin", [EnvironmentVariableTarget]::Machine)
$env:Path += ";c:\users\administrator\appdata\local\chefdk\gem\ruby\2.3.0\bin"
gem install train
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment