Skip to content

Instantly share code, notes, and snippets.

View cyberswat's full-sized avatar

Kevin Bridges cyberswat

View GitHub Profile
@cyberswat
cyberswat / puppetd-second-run.sh
Created February 28, 2012 05:14
First puppetd run after certificate signed on puppetmaster with puppetca
proot@li220-252:~] puppetd -t --server puppet.cyberswat.com
warning: peer certificate won't be verified in this SSL session
info: Caching certificate for li220-252.members.linode.com
pcilib: Cannot open /proc/bus/pci
lspci: Cannot find any working access method.
info: Caching certificate_revocation_list for ca
info: Caching catalog for li220-252.members.linode.com
info: Applying configuration version '1330405985'
info: Creating state file /var/lib/puppet/state/state.yaml
notice: Finished catalog run in 0.05 seconds
@cyberswat
cyberswat / ssh-keygen.sh
Created February 28, 2012 15:37
Create a pass-wordless ssh key
# switch to the jenkins user
[root@li220-252:~] su jenkins
jenkins@li220-252:/root$
# Generate the key
jenkins@li220-252:~$ ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
@cyberswat
cyberswat / cat-rsa-pub.sh
Created February 28, 2012 16:17
You can quickly display the contents of your public key with the cat command
jenkins@li220-252:~$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtqqYyeKldKj3lCh6sQ1sKHUNiKQigZx2kmT2+mRKvsZJdZHg/qmGKvhtJRf90DOPklvU1z1/x+ey0hCzP7qOfNNNZLadz9ZLAhR6Dk4jlerAMtS9zMoPZL/yEeQE24gUKAKrcXSpxUrCpAJw2Za1OdyEEoBiPSp+PIiYS/Hm4KrQC5Sj4KOr9cu6bWClmWNCXPFQDFBiEt1MxJ0P9lLTlejMrFlbc4iCeDXXT1P7WCtX/3UCcvsm92ZwgoNfBPqVADC1VytH0X6WsMLgdDiF67ZmDXxT4LTnl6ACbaMw6IZyafyQs4sWC4ecgDa2pDlFKzw9a2/yywtZME3V/6Qlsw== [email protected]
@cyberswat
cyberswat / git-init.sh
Created February 28, 2012 16:35
Initialize git repo and make first commit
# switch to the jenkins user
[root@li220-252:~] su jenkins
jenkins@li220-252:/root$
# Move into the jenkins directory
jenkins@li220-252:~$ cd /var/lib/jenkins/
# Intialize a git repository
jenkins@li220-252:~$ git init
Initialized empty Git repository in /var/lib/jenkins/.git/
@cyberswat
cyberswat / jenkins-auto-git.sh
Created February 28, 2012 16:41
Jenkins job to manage jenkins configs
# Move into the jenkins directory
cd /var/lib/jenkins
#Add all top level xml files.
git add *.xml
# Add all job config.xml files.
git add jobs/*/config.xml
# Add all user config.xml files.
# dirty ruby syslog
def log(msg)
Syslog.open($0, Syslog::LOG_PID | Syslog::LOG_CONS) { |s| s.warning "#{msg}" }
end
Drupal is a vivid and exciting community, creating and maintaining an ecosystem
of talent in many different areas of knowledge. When it comes to discussing and
embracing the future of Drupal, developers are the front line, making sure we
are capable of meeting our clients needs while delivering performant applications
more efficiently and securely.
The Coding and Development track for Drupalcon Sao Paoulo is dedicated to
the new options, capabilities and direction that will shape the future of Drupal.
We will offer many must-see sessions with a focus on the RESTful future of
Drupal and harnessing the power of the Symfony framework. We will introduce you
def clean_releases(vars)
directories = []
Dir.entries(vars[:directory]).each do |f|
directories.push f if (f=~/^#{vars[:app_name]}-[0-9]+/)
end
directories.sort.reverse.drop(vars[:quantity]).each do |i|
system "rm -rf #{vars[:directory]}/#{i}"
end
end
files_sorted_by_time = Dir["#{node[:drupal][:server][:base]}/#{site_name}/releases/*"].sort_by{ |f| File.mtime(f) }
previous_release = files_sorted_by_time.length > 1 ? files_sorted_by_time[1] : files_sorted_by_time[0]
command <<-EOF
cp #{files_sorted_by_time[file_index]}/#{site[:settings]} #{release_path}/#{site[:settings]}
EOF
only_if { ::File.exists?("#{files_sorted_by_time[-2]}/#{site[:settings]}") }
@cyberswat
cyberswat / gist:5678391
Created May 30, 2013 14:43
A sample LWRP per #drupal-colorado conversation
require 'fileutils'
require 'tempfile'
action :ensure do
t_file = Tempfile.new('/root/.profile_temp')
::File.open(new_resource.profile, 'r') do |f|
f.each_line do |line|
if line.match(/PATH=/)
if ::File.readlines(new_resource.profile).grep(/:#{new_resource.path.gsub('/','\/')}/).length > 0
t_file.puts line