Skip to content

Instantly share code, notes, and snippets.

@madAndroid
Created July 24, 2013 08:33
Show Gist options
  • Save madAndroid/6068920 to your computer and use it in GitHub Desktop.
Save madAndroid/6068920 to your computer and use it in GitHub Desktop.
diff --git a/sf-bootstrap b/sf-bootstrap
index f39cb77..b9e0343 100755
--- a/sf-bootstrap
+++ b/sf-bootstrap
@@ -452,10 +452,14 @@ class BootstrapBase
def add_automation_to_path
log_info( "Writing default path to /etc/environment" )
- File.open( '/etc/environment', 'a' ) { |f|
- f.puts "# Written by sf-bootstrap"
- f.puts "PATH=/opt/automation/usr/bin:/usr/local/bin:/bin:/usr/bin"
- }
+ env_contents = []
+ File.open( '/etc/environment', 'r').each_line { |line| env_contents.push line }
+ if ! env_contents.include? /sf-bootstrap/
+ File.open( '/etc/environment', 'a' ) { |f|
+ f.puts "# Written by sf-bootstrap"
+ f.puts "PATH=/opt/automation/usr/bin:/usr/local/bin:/bin:/usr/bin"
+ }
+ end
log_info( "Writing conditional path appender to /etc/profiles.d/sf_automation.sh" )
File.open( '/etc/profile.d/sf_automation.sh', 'w' ) { |f|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment