From e980a47993a174e700f6db66088ef43747b24441 Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Wed, 17 May 2017 11:43:04 +0200 Subject: [PATCH] scripts for userid and magic hash --- lib/facter/eypconf_magic_hash.rb | 6 +++++- lib/facter/eypconf_userid.rb | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/facter/eypconf_magic_hash.rb b/lib/facter/eypconf_magic_hash.rb index 8377f60..6935bc0 100644 --- a/lib/facter/eypconf_magic_hash.rb +++ b/lib/facter/eypconf_magic_hash.rb @@ -1,4 +1,8 @@ -magichash = Facter::Util::Resolution.exec('bash -c \'if [ -f /opt/eypconf/id/.magic ]; then cat /opt/eypconf/id/.magic | paste -sd,; else echo "deadbeef"; fi\'').to_s +if File.exists?('/opt/eypconf/id/magic.sh') then + magichash = Facter::Util::Resolution.exec('bash /opt/eypconf/id/magic.sh').to_s +else + magichash = Facter::Util::Resolution.exec('bash -c \'if [ -f /opt/eypconf/id/.magic ]; then cat /opt/eypconf/id/.magic | paste -sd,; else echo "deadbeef"; fi\'').to_s +end unless magichash.nil? or magichash.empty? Facter.add('eypconf_magic_hash') do diff --git a/lib/facter/eypconf_userid.rb b/lib/facter/eypconf_userid.rb index c884896..97c3e71 100644 --- a/lib/facter/eypconf_userid.rb +++ b/lib/facter/eypconf_userid.rb @@ -1,4 +1,8 @@ -userid = Facter::Util::Resolution.exec('bash -c \'if [ -f /opt/eypconf/id/customer ]; then cat /opt/eypconf/id/customer | paste -sd,; else echo "defaultcustomer"; fi\'').to_s +if File.exists?('/opt/eypconf/id/userid.sh') then + userid = Facter::Util::Resolution.exec('bash /opt/eypconf/id/userid.sh').to_s +else + userid = Facter::Util::Resolution.exec('bash -c \'if [ -f /opt/eypconf/id/userid ]; then cat /opt/eypconf/id/userid | paste -sd,; fi\'').to_s +end unless userid.nil? or userid.empty? Facter.add('eypconf_userid') do