Skip to content

Instantly share code, notes, and snippets.

View trevor-vaughan's full-sized avatar

Trevor Vaughan trevor-vaughan

View GitHub Profile
@trevor-vaughan
trevor-vaughan / build_prep.rb
Last active February 10, 2018 22:00
SIMP Production Build Scripts
#!/usr/bin/ruby
TOP_DIR = Dir.pwd
def build
require 'fileutils'
require 'yaml'
['6', '7'].each do |ver|
@trevor-vaughan
trevor-vaughan / rpm_requires_to_metadata_requires.txt
Created December 18, 2017 17:11
VIM one liner to convert RPM requires statement to puppet metadata.json requires
%s/Require: pupmod-\(.\+\)-\(.\+\) >= \(.\+\),.*< \(.\+\)/{\r "name": "\1\/\2",\r "version_requirement": ">= \3 < \4"\r},/
@trevor-vaughan
trevor-vaughan / rpmsig.sh
Last active November 27, 2017 21:00
RPM signature query
#!/bin/sh
# Stolen from https://unix.stackexchange.com/questions/17368/how-do-i-tell-which-gpg-key-an-rpm-package-was-signed-with
rpm -qp --qf '%{NAME}-%{VERSION}-%{RELEASE} %{SIGPGP:pgpsig} %{SIGGPG:pgpsig}\n' *.rpm
@trevor-vaughan
trevor-vaughan / simp_aws_rhel_build.sh
Last active October 24, 2018 15:13
Script for building SIMP 6.1+ for RHEL in AWS
#!/bin/bash --login
# Script for building SIMP on AWS RHEL systems
# IMPORTANT!
#
# Be sure to rename the tarball to 'SIMP-<VERSION>.el7-RedHat-7-x86_64.tar.gz'
#
#
# Build tarballs can be downloaded from https://simp-project.com/ISO/SIMP/tar_bundles
@trevor-vaughan
trevor-vaughan / strace_cmds.rb
Created September 27, 2017 16:33
Print all commands run by a program
#!/usr/bin/env ruby
# Expects an input file generated using:
# strace -f -qq -o <output_file> -e trace=execve <command>
infile = ARGV.first
unless File.exists?(infile)
$stderr.puts("'#{infile}' is not a valid file")
end
@trevor-vaughan
trevor-vaughan / rsyslog_config_parse.rb
Created September 5, 2017 04:28
Output an entire Rsyslog configuration
#!/usr/bin/env ruby
base_config = '/etc/rsyslog.conf'
def process_config(config)
output = []
File.read(config).lines do |line|
if line =~ /IncludeConfig\s+(.*)/
Dir.glob($1).each do |subfile|
@trevor-vaughan
trevor-vaughan / story_point_bookmarklet.js
Created August 16, 2017 20:08
JS Bookmarklet to sum up Story Points in JIRA
javascript:var%20sp_field%20=%20'.customfield_10005';%20var%20sum%20=%20jQuery(sp_field).text().split(/\s+/).filter(function(n){%20return%20n%20!=%20''%20}).map(function(n){%20return%20parseInt(n)%20}).reduce(function(a,%20v){%20return%20a%20+%20v%20});%20alert('Total%20Story%20Points:%20'%20+%20sum);%20void(document.close());
@trevor-vaughan
trevor-vaughan / el7_aws_production_build.sh
Created August 9, 2017 01:42
Even more horribly stupid script for building a RHEL 7 SIMP on a RHEL 7 AWS host
#!/bin/bash --login
# Be sure to rename the tarball to 'SIMP-<VERSION>-el7-RedHat-7-x86_64.tar.gz'
set -e
# Put the RHEL ISO here
iso_dir='/home/ec2-user/ISO'
top_dir=`pwd`
@trevor-vaughan
trevor-vaughan / memmap_info.rb
Created June 20, 2017 19:04
Get the largest stack size and application size of running apps. Written to get info for setting limits for Stack Clash
#!/usr/bin/ruby
# Get application and stack size of an application in a form useful for using
# with pam_limits
require 'json'
PAGE_SIZE = %x(getconf PAGESIZE).to_i
UID = Process.uid
@trevor-vaughan
trevor-vaughan / package_cloud_simp_pull.rb
Created March 20, 2017 13:14
Pull Latest Files from Package Cloud for SIMP - Must be run in a directory with RPMs that you wish to overwrite
#!/usr/bin/env ruby
LOCK=true
#URL='https://packagecloud.io/simp-project/4_X/packages/el/6'
#URL='https://packagecloud.io/simp-project/4_X_Dependencies/packages/el/6'
#URL='https://packagecloud.io/simp-project/5_X/packages/el/7'
#URL='https://packagecloud.io/simp-project/5_X_Dependencies/packages/el/7'
#URL='https://packagecloud.io/simp-project/6_X_Alpha/packages/el/7'
#URL='https://packagecloud.io/simp-project/6_X_Alpha_Dependencies/packages/el/7'
#URL='https://packagecloud.io/simp-project/6_X/packages/el/7'