Skip to content

Instantly share code, notes, and snippets.

@rdark
rdark / keybase.md
Created September 22, 2014 19:06
keybase.md

Keybase proof

I hereby claim:

  • I am rdark on github.
  • I am rdark (https://keybase.io/rdark) on keybase.
  • I have a public key whose fingerprint is CF92 BB4E ABDF 0368 2828 2C1C F17D 4E75 ED47 71E0

To claim this, I am signing this object:

@rdark
rdark / wsus_cleanup.ps1
Created September 2, 2014 14:57
automate clean up of WSUS
# Script to clean up WSUS database
[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | out-null
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer();
$cleanupScope = new-object Microsoft.UpdateServices.Administration.CleanupScope;
$cleanupScope.DeclineSupersededUpdates = $true
$cleanupScope.DeclineExpiredUpdates = $true
$cleanupScope.CleanupObsoleteUpdates = $true
$cleanupScope.CompressUpdates = $true
$cleanupScope.CleanupObsoleteComputers = $true
$cleanupScope.CleanupUnneededContentFiles = $true
%{?scl:%scl_package perl-App-FatPacker}
%{!?scl:%global pkg_name %{name}}
Name: %{?scl_prefix}perl-App-FatPacker
Version: 0.010001
Release: 2%{?dist}
Summary: Pack dependencies onto a script file
License: GPL+ or Artistic
Group: Development/Libraries
URL: http://search.cpan.org/dist/App-FatPacker/
:POSTROUTING ACCEPT [0:0]
-A PREROUTING -p tcp --dport 53 -m comment --comment "MNS: Redirect TCP 53 to 10053" -j REDIRECT --to-port 10053
-A PREROUTING -p udp --dport 53 -m comment --comment "MNS: Redirect UDP 53 to 10053" -j REDIRECT --to-port 10053
[rdark@g2-2119-test ~]$ sudo iptables -t nat --list -v
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 REDIRECT tcp -- any any anywhere anywhere tcp dpt:domain /* MNS: Redirect TCP 53 to 10053 */ redir ports 10053
0 0 REDIRECT udp -- any any anywhere anywhere udp dpt:domain /* MNS: Redirect UDP 53 to 10053 */ redir ports 10053
Process.fork do
# drop privileges to uid/gid
Process.initgroups(u.name, gid)
Process::UID.change_privilege(u.uid)
Process::GID.change_privilege(gid) # HERE we have Errno::EPERM
puts "In BLOCK with uid: #{u.uid} and group #{gid}"
# Invoke the caller's block of code.
block.call #(user)
end
#!/usr/bin/env ruby
#
mock_dist = {
:arch => "i386",
:distribution => "epel",
:release => "6",
}
mock_arch = mock_dist[:arch]
mock_dist = mock_dist[:distribution]
require 'rspec/core/rake_task'
DEFAULT_SUITE = [
{ :id => :lib_rimbaud, :title => 'Default test', :files => %w(spec/rimbaud/*_spec.rb) },
]
DELUXE_SUITE = [
{ :id => :ssh, :title => 'SSH tests', :dirs => %w(spec/suite/ssh) }
]
rclark@mercury:~$ ./tmp/test_yaml.rb ./tmp/test_yaml.yml
yaml is a Hash
{"ulimit"=>{"user"=>nil, "ulimit_config"=>[{"domain"=>"a", "type"=>"a", "item"=>"a", "value"=>0}, {"domain"=>"b", "type"=>"b", "item"=>"b", "value"=>1}]}}
rclark@mercury:~$ cat tmp/test_yaml.rb
#!/usr/bin/env ruby
require 'yaml'
yaml = YAML::load(File.open(ARGV[0]))
puts "yaml is a #{yaml.class.name}"
# ALERT LOGS:
March 02, 2014 17:00
Host Up[03-02-2014 17:23:01] HOST ALERT: a0.webproxy.domain.com;UP;HARD;1;HTTP OK: Status line output matched "HTTP/1.1 200" - 1633 bytes in 4.398 second response time
Host Down[03-02-2014 17:22:31] HOST ALERT: a0.webproxy.domain.com;DOWN;HARD;2;CRITICAL - Socket timeout after 10 seconds
March 02, 2014 16:00
Host stopped flapping[03-02-2014 16:55:51] HOST FLAPPING ALERT: a0.webproxy.domain.com;STOPPED; Host appears to have stopped flapping (3.8% change < 5.0% threshold)
@rdark
rdark / def sign
Last active August 29, 2015 13:57
def sign(gpg_passphrase="")
rpm_cmd = "rpm --resign " + self.filename
rpm_cmd += " 2> /dev/null"
PTY.spawn(rpm_cmd) do |r,w,pid|
prompt = r.read(19)
# match the expected prompt exactly, since that's the only way we know if
# something went wrong.
unless prompt == "Enter pass phrase: "