Created
May 8, 2012 10:03
-
-
Save ttscoff/2633967 to your computer and use it in GitHub Desktop.
Installer for gitlogger.rb
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
#!/usr/bin/ruby | |
require 'ftools' | |
puts "Installing GitLogger" | |
puts "This script will install the following files:" | |
puts | |
puts "/usr/local/bin/gitlogger.rb" | |
puts "~/Library/LaunchAgents/com.brettterpstra.gitlogger.plist" | |
puts "It will add the glog command to your bash_profile and" | |
puts "set up launchd to run the script at 11:50pm daily." | |
print "Getting gitlogger.rb... " | |
gitlogger=%x{/usr/bin/curl -fsSL https://raw.github.com/gist/2632346/1be9a54382c7639a817657b2b1300b919813a5a7/gitlogger.rb} | |
File.makedirs("/usr/local/bin") unless File.exists?("/usr/local/bin") | |
open('/usr/local/bin/gitlogger.rb','w') { |f| | |
f.puts gitlogger | |
} unless File.exists?('/usr/local/bin/gitlogger.rb') | |
%x{chmod a+x /usr/local/bin/gitlogger.rb} | |
puts "installed." | |
print "Setting up launchd... " | |
xml=<<LAUNCHCTLPLIST | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>com.brettterpstra.gitlogger</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/usr/bin/ruby</string> | |
<string>/usr/local/bin/gitlogger.rb</string> | |
</array> | |
<key>StartCalendarInterval</key> | |
<dict> | |
<key>Hour</key> | |
<integer>23</integer> | |
<key>Minute</key> | |
<integer>50</integer> | |
</dict> | |
</dict> | |
</plist> | |
LAUNCHCTLPLIST | |
File.makedirs(File.expand_path("~/Library/LaunchAgents")) unless File.exists?(File.expand_path("~/Library/LaunchAgents")) | |
open(File.expand_path("~/Library/LaunchAgents/com.brettterpstra.gitlogger.plist"),'w') { |f| | |
f.puts xml | |
} unless File.exists?(File.expand_path("~/Library/LaunchAgents/com.brettterpstra.gitlogger.plist")) | |
%x{launchctl load #{File.expand_path("~/Library/LaunchAgents/com.brettterpstra.gitlogger.plist")}} | |
puts "done." | |
print "Adding glog command to bash_profile... " | |
glog=%x{/usr/bin/curl -fsSL https://raw.github.com/gist/2632356/a846f08cb8d00719160f6ae29bc9a03a7adb6b00/glog.sh} | |
File.open(File.expand_path('~/.bash_profile'),'a') { |f| | |
f.puts | |
f.puts glog | |
} | |
%x{source ~/.bash_profile} | |
puts "done." | |
puts "----------------------" | |
puts "Installation complete." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment