-
-
Save danielsdeleo/233320 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this is the error I get. | |
/srv/chef/cookbooks/system/libraries/add_env_var.rb:1:in `system': wrong number of arguments (ArgumentError) | |
Module system | |
def add_env_var(variable, path) | |
envfile = "/etc/profile.d/99generic.sh" | |
foundvar = false | |
arr = IO.readlines( envfile ) if File::exists?( envfile ) | |
length = arr.length - 1 | |
for i in 0..length | |
if arr[i][variable] then | |
line = arr[i].chomp.split( '=' ) | |
paths = line[1].split( ':' ) << path | |
arr[i] = line[0] + "=" + paths.uniq.join( ':' ) + "\n" | |
foundvar = true | |
break | |
end | |
end | |
if !foundvar then | |
arr << "export #{variable}=#{path}" | |
end | |
aFile = File.new( envfile, "w" ) | |
aFile.syswrite( "#{arr.flatten}" ) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment