Skip to content

Instantly share code, notes, and snippets.

View keithchambers's full-sized avatar

Keith Chambers keithchambers

View GitHub Profile
@keithchambers
keithchambers / grinder.sh
Last active July 10, 2022 20:06
Yum remo mirror with snapshots
#!/bin/bash -ex
URL="$1"
LABEL="$2"
BASEDIR="/vagrant/mirror"
MIRRORDIR="${BASEDIR}/${LABEL}"
SNAPSHOTDIR="${MIRRORDIR}/$(date +%Y%m%d)"
if [[ $(command -v grinder >/dev/null 2>&1) -ne 0 ]]
then
@keithchambers
keithchambers / yum-package-deps-downloader.sh
Last active December 22, 2021 23:59
Download RPM packages and all dependencies from Yum repo.
#!/bin/bash -e
BASEDIR="$PWD"
OUTDIR="$BASEDIR/repo"
INSTALLROOTDIR="$BASEDIR/installroot"
REPOSDIR="$INSTALLROOTDIR/etc/yum.repos.d"
CACHEDIR="$INSTALLROOTDIR/var/cache/yum"
CONFIGFILE="$INSTALLROOTDIR/yum.conf"
LOGFILE="$OUTDIR/yum.log"
@keithchambers
keithchambers / rpm-verify.sh
Last active December 22, 2021 23:59
Verify RPMs with rpm and yum-verify.
#!/bin/bash -e
IFS=$'\n'
function rpm_verify()
{
RPMS="$(rpm -qa)"
for RPM in $RPMS ; do
RESULT="$(nice -n +19 rpm -V "$RPM" | awk '$2 != "c" {print $1, $NF}')"
if [[ "$RESULT" ]] ; then
@keithchambers
keithchambers / generate-system-load.sh
Last active August 29, 2015 14:05
Generate system load.
#!/bin/bash -e
TIMEOUT=${1:-120}
CPU_UNITS=$(cat /proc/cpuinfo | grep processor | wc -l)
until [[ ${COUNT} -eq ${CPU_UNITS} ]]
do
timeout ${TIMEOUT} dd if=/dev/zero bs=10 | gzip | gzip -d > /dev/null &
COUNT=$((COUNT+1))
done
@keithchambers
keithchambers / rinse.spec
Created September 7, 2014 22:14
RPM spec file for rinse
%define debug_package %{nil}
Name: rinse
Version: 3.0.2
Release: 1%{?dist}
Summary: Carry out the installation of a new RPM-based distribution.
Group: Development/Tools
License: Artistic
URL: http://collab-maint.alioth.debian.org/rinse/
Source0: http://collab-maint.alioth.debian.org/rinse/download/rinse_%{version}.tar.gz
@keithchambers
keithchambers / build-centos7-docker-image.sh
Last active December 22, 2021 23:59
Build a CentOS 7 docker image.
#!/bin/bash -e
DIST="centos7"
TAG="$(date +%Y%m%d)"
IMG_DIR="${PWD}/buildroot-${DIST}"
REPO_DIR="${IMG_DIR}/etc/yum.repos.d"
RPMS=(
bind-utils
bash
@keithchambers
keithchambers / local-yum-repo-to-s3.sh
Last active August 29, 2015 14:06
Sync s3 backed yum repo
#/bin/bash -e
readonly REPO_DIR="$1"
readonly S3_BUCKET="$2"
if [[ -z "$2" ]] ; then
echo "Usage: "$0" <repo-dir> <s3-bucket>"
exit 1
fi
{
"Version": "2008-10-17",
"Id": "public-yum",
"Statement": [
{
"Sid": "@@REPO@@-anon-get",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
var http = require('http');
var port = 8080;
var args = process.argv.splice(2);
if (args.length > 0) {
port = args[0];
}
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain', 'Cache-Control': 'no-cache'});
res.end('Hello, world.');
}).listen(port, "");
@keithchambers
keithchambers / block-io.stp
Last active August 29, 2015 14:07
systemtap block-io
#!/usr/bin/stap
global block_size=512
global devices
global cmd_start
global writes_time
global reads_time
global writes_size
global reads_size
global cmd_size