Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
b4ldr committed Oct 6, 2017
1 parent 8630f3e commit 1722dc5
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions facts/get_facts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ export PATH=/opt/puppetlabs/bin:$PATH
if test -f /usr/bin/apt-get; then
apt-get update
apt-get install -y lsb-release
lsbdistcodename=`lsb_release -sc`
operatingsystem=`lsb_release -si`
operatingsystemmajrelease=`lsb_release -sr`
lsbdistcodename=$(lsb_release -sc)
operatingsystem=$(lsb_release -si)
operatingsystemmajrelease=$(lsb_release -sr)
osfamily='Debian'
elif test -f /usr/bin/dnf; then
operatingsystemmajrelease=`awk '{print $3}' /etc/redhat-release`
operatingsystemmajrelease=$(awk '{print $3}' /etc/redhat-release)
osfamily='Fedora'
elif test -f /usr/bin/yum; then
operatingsystemmajrelease=`awk '{print $3}' /etc/redhat-release| cut -c1`
operatingsystemmajrelease=$(awk '{print $3}' /etc/redhat-release| cut -c1)
osfamily='RedHat'
else
osfamily=`uname`
osfamily=$(uname)
fi

case "${osfamily}" in
Expand All @@ -24,8 +24,8 @@ case "${osfamily}" in
rpm -ivh /tmp/puppetlabs-release-pc1.rpm
for puppet_agent_version in 1.5.3-1 1.6.0-1 1.6.1-1 1.6.2-1 1.7.0-1; do
dnf install -y "puppet-agent-${puppet_agent_version}.fedoraf${operatingsystemmajrelease}"
output_file="/vagrant/`facter --version | cut -c1-3`/`facter operatingsystem | tr '[:upper:]' '[:lower:]'`-`facter operatingsystemmajrelease`-`facter hardwaremodel`.facts"
mkdir -p `dirname ${output_file}`
output_file="/vagrant/$(facter --version | cut -c1-3)/$(facter operatingsystem | tr '[:upper:]' '[:lower:]')-$(facter operatingsystemmajrelease)-$(facter hardwaremodel).facts"
mkdir -p $(dirname ${output_file})
[ ! -f ${output_file} ] && facter --show-legacy -p -j | tee ${output_file}
done
;;
Expand All @@ -34,8 +34,8 @@ case "${osfamily}" in
rpm -ivh /tmp/puppetlabs-release-pc1.rpm
for puppet_agent_version in 1.2.2 1.4.2 1.5.3 1.10.4; do
yum install -y puppet-agent-${puppet_agent_version}
output_file="/vagrant/`facter --version | cut -c1-3`/`facter operatingsystem | tr '[:upper:]' '[:lower:]'`-`facter operatingsystemmajrelease`-`facter hardwaremodel`.facts"
mkdir -p `dirname ${output_file}`
output_file="/vagrant/$(facter --version | cut -c1-3)/$(facter operatingsystem | tr '[:upper:]' '[:lower:]')-$(facter operatingsystemmajrelease)-$(facter hardwaremodel).facts"
mkdir -p $(dirname ${output_file})
[ ! -f ${output_file} ] && facter --show-legacy -p -j | tee ${output_file}
done
;;
Expand All @@ -51,25 +51,25 @@ case "${osfamily}" in
apt-get update
for puppet_agent_version in 1.10.7 1.2.2 1.4.2 1.5.3 1.10.6; do
apt-get -y --force-yes install puppet-agent=${puppet_agent_version}*
output_file="/vagrant/`facter --version | cut -c1-3`/`facter operatingsystem | tr '[:upper:]' '[:lower:]'`-`facter operatingsystemmajrelease`-`facter hardwaremodel`.facts"
mkdir -p `dirname ${output_file}`
output_file="/vagrant/$(facter --version | cut -c1-3)/$(facter operatingsystem | tr '[:upper:]' '[:lower:]')-$(facter operatingsystemmajrelease)-$(facter hardwaremodel).facts"
mkdir -p $(dirname ${output_file})
[ ! -f ${output_file} ] && facter --show-legacy -p -j | tee ${output_file}
done
apt-get install -y make gcc libgmp-dev
;;
'FreeBSD')
pkg update -y
pkg update
pkg install -y sysutils/puppet5 sysutils/facter
output_file="/vagrant/`facter --version | cut -c1-3`/`facter operatingsystem | tr '[:upper:]' '[:lower:]'`-`facter operatingsystemmajrelease`-`facter hardwaremodel`.facts"
mkdir -p `dirname ${output_file}`
output_file="/vagrant/$(facter --version | cut -c1-3)/$(facter operatingsystem | tr '[:upper:]' '[:lower:]')-$(facter operatingsystemmajrelease)-$(facter hardwaremodel).facts"
mkdir -p $(dirname ${output_file})
[ ! -f ${output_file} ] && facter --show-legacy -p -j | tee ${output_file}
;;
esac

operatingsystem=`facter operatingsystem | tr '[:upper:]' '[:lower:]'`
operatingsystemrelease=`facter operatingsystemrelease`
operatingsystemmajrelease=`facter operatingsystemmajrelease`
hardwaremodel=`facter hardwaremodel`
operatingsystem=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
operatingsystemrelease=$(facter operatingsystemrelease)
operatingsystemmajrelease=$(facter operatingsystemmajrelease)
hardwaremodel=$(facter hardwaremodel)

[ "${hardwaremodel}" = 'amd64' ] && hardwaremodel=x86_64

Expand All @@ -81,14 +81,14 @@ for version in 1.6.0 1.7.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0; do
FACTER_GEM_VERSION="~> ${version}" bundle update
case "${operatingsystem}" in
openbsd)
output_file="/vagrant/`bundle exec facter --version | cut -c1-3`/${operatingsystem}-${operatingsystemrelease}-${hardwaremodel}.facts"
output_file="/vagrant/$(bundle exec facter --version | cut -c1-3)/${operatingsystem}-${operatingsystemrelease}-${hardwaremodel}.facts"
;;
*)
output_file="/vagrant/`bundle exec facter --version | cut -c1-3`/${operatingsystem}-${operatingsystemmajrelease}-${hardwaremodel}.facts"
output_file="/vagrant/$(bundle exec facter --version | cut -c1-3)/${operatingsystem}-${operatingsystemmajrelease}-${hardwaremodel}.facts"
;;
esac
[ -f ${output_file} ] && continue
mkdir -p `dirname $output_file`
mkdir -p $(dirname $output_file)
echo $version | grep -q -E '^1\.' &&
FACTER_GEM_VERSION="~> ${version}" bundle exec facter -j | bundle exec ruby -e 'require "json"; jj JSON.parse gets' | tee $output_file ||
FACTER_GEM_VERSION="~> ${version}" bundle exec facter -j | tee $output_file
Expand Down

0 comments on commit 1722dc5

Please sign in to comment.