# Copyright 2006-2009 by Mike Bailey. All rights reserved. Capistrano::Configuration.instance(:must_exist).load do namespace :deprec do namespace :collectd do # latest rrdtool # apt-get install intltool # wget http://oss.oetiker.ch/rrdtool/pub/rrdtool.tar.gz # tar zxf rrdtool.tar.gz # cd rrdtool # ./configure --prefix=/usr/local # make # sudo make install # # wget http://oss.oetiker.ch/rrdtool/pub/contrib/ruby-rrd-1.1.tar.gz # tar zxf ruby-rrd-1.1.tar.gz # cd ruby-rrd-1.1 # ruby extconf.rb # make # make install # Ruby bindings # RRD.so SRC_PACKAGES[:collectd] = { :url => "http://collectd.org/files/collectd-4.7.1.tar.gz", :md5sum => "9ec7f111e74dc55ad2aa9fcc11b8221c collectd-4.7.1.tar.gz", :configure => "./configure --prefix=/usr/local" } desc "Install collectd" task :install do install_deps deprec2.download_src(SRC_PACKAGES[:collectd], src_dir) deprec2.install_from_src(SRC_PACKAGES[:collectd], src_dir) end # install dependencies for nginx task :install_deps do apt.install( {:base => %w(liboping-dev libperl-dev libdbi0-dev libesmtp-dev libganglia1-dev libmemcache-dev libnet1-dev libnotify-dev libopenipmi-dev liboping-dev libpcap-dev libperl-dev librrd2-dev libsensors-dev libstatgrab-dev nut-dev libvirt-dev)}, :stable ) apt.install( {:base => %w(rrdtool librrd2-dev librrds-perl libconfig-general-perl libhtml-parser-perl libregexp-common-perl)}, :stable ) end # "Start git server in local directory" task :serve do cmd = "git-daemon --verbose --port=#{git_port} --base-path=#{Dir.pwd} --base-path-relaxed" puts cmd `#{cmd}` end desc "Create git repos for current dir" task :init do `git init` create_gitignore create_files_in_empty_dirs `git add . && git commit -m 'initial import'` end task :create_gitignore do system("echo '.DS_Store' >> .gitignore") # files sometimes created by OSX system("echo 'log/*' >> .gitignore") if File.directory?('log') system("echo 'tmp/**/*' >> .gitignore") if File.directory?('tmp') end task :create_files_in_empty_dirs do %w(log tmp).each { |dir| system("touch #{dir}/.gitignore") if File.directory?(dir) } end desc "Create remote origin for current dir" task :create_remote_origin do File.directory?('.git') || init # Push to remote git repo hostname = capture "echo $CAPISTRANO:HOST$" system "git remote add origin git@#{hostname.chomp}:#{application}" system "git push origin master:refs/heads/master" puts puts "New remote Git repo: #{git_user}@#{hostname.chomp}:#{application}" puts # File.open('.git/config', 'w') do |c| # c.write 'Add the following to .git/config' # c.write '[branch "master"]' # c.write ' remote = origin' # c.write ' merge = refs/heads/master' # end end # Create root dir for git repositories task :create_git_root do deprec2.mkdir(git_root, :mode => 02775, :owner => git_user, :group => git_group, :via => :sudo) sudo "chmod -R g+w #{git_root}" end # regenerate git authorized keys file from users file in same dir task :regenerate_authorized_keys do sudo "echo '' > #{git_keys_file}" sudo "for file in `ls #{git_keys_file}-*`; do cat $file >> #{git_keys_file}; echo \"\n\" >> #{git_keys_file} ; done" sudo "chown #{git_user}.#{git_group} #{git_keys_file}" sudo "chmod 0600 #{git_keys_file}" end end end end