Skip to content

Instantly share code, notes, and snippets.

@dmc5179
dmc5179 / clair_export_import.sh
Created November 12, 2020 02:49
Clair export import
#!/bin/bash -x
QUAY_NAMESPACE='quay-enterprise'
CLAIR_POSTGRES_POD=$(oc get -n ${QUAY_NAMESPACE} pods | grep clair-postgres | awk -F\ '{print $1}')
echo "POD: ${CLAIR_POSTGRES_POD}"
oc rsh -n ${QUAY_NAMESPACE} ${CLAIR_POSTGRES_POD} /bin/sh -c "pg_dump -U postgres -a -t feature -t keyvalue -t namespace -t schema_migrations -t vulnerability -t vulnerability_fixedin_feature clair" > clair_vulnerability.sql
@dmc5179
dmc5179 / quay_fips_deploy.sh
Last active November 11, 2020 22:32
Quay upstream on a FIPS enabled OpenShift 4.6 cluster
#!/bin/bash
WORKING_DIR=/tmp/
QUAY_NAMESPACE='quay-enterprise'
S3BUCKET=''
ACCESS_KEY=''
SECRET_KEY=''
mkdir -p "${WORKING_DIR}"
pushd "${WORKING_DIR}"
@dmc5179
dmc5179 / icsp.sh
Created September 29, 2020 18:24
Image Content Source Policy Machine Config
#!/bin/bash -xe
REGISTRY="registry.caas.cia.ic.gov:5000"
# Read in the new chrony.conf file
ICSP_B64=$(cat ./icsp.conf | sed "s|registry.example.com|${REGISTRY}|g" | base64 -w 0)
# Create a machine config to set the private registry for master nodes
rm -f ./99_master-private-registry-configuration.yaml
cat << EOF > ./99_master-private-registry-configuration.yaml
@dmc5179
dmc5179 / rhcos_ami.sh
Created September 2, 2020 00:55
Importing RedHat CoreOS RAW Disk image into AWS to create an AMI
#!/bin/bash -xe
RHCOS_VERSION="4.5.6"
RHCOS_TMP="/tmp"
S3_BUCKET="mybucket"
# Change to the temporary directory
pushd "${RHCOS_TMP}"
# NOTE: Uncomment the curl command if you need to download the disk
@dmc5179
dmc5179 / openshift4-mirror.sh
Last active September 24, 2020 11:26
Mirroring OpenShift 4 Required Images and RedHat Operator Hub Images
#!/bin/bash -xe
export OCP_RELEASE="4.5.4"
export ARCHITECTURE="x86_64"
export LOCAL_REG='localhost:5000'
export LOCAL_REPO='ocp4/openshift4'
export LOCAL_REG_INSEC='true'
export UPSTREAM_REPO='openshift-release-dev'
export OCP_ARCH="x86_64"
# Directory where OCP images are written to or read from
# When mirroring to disk
@dmc5179
dmc5179 / Dockerfile.rhel
Last active October 7, 2022 14:31
Dockerfile to build Docker registry on RHEL UBI Images
FROM registry.redhat.io/ubi8/go-toolset:latest AS build
ENV DISTRIBUTION_DIR /opt/app-root/src/go/src/github.com/docker/distribution
ENV BUILDTAGS include_oss include_gcs
ENV GOPATH /opt/app-root/src/go
ENV GOBIN /usr/lib/golang/bin
ARG GOOS=linux
ARG GOARCH=s390x
@dmc5179
dmc5179 / aws-ec2-stale-instances
Created April 21, 2020 13:31
Locate AWS EC2 instances that have been stopped for more than a defined number of days
#!/bin/bash
# Locate stale AWS EC2 Instances
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@dmc5179
dmc5179 / aws-ec2-dead-snapshots.sh
Last active April 21, 2020 13:30
Script to find AWS EC2 Snapshots created for AMIs that no longer exist
#!/bin/bash
# Locate dead AWS EC2 Snapshots
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@dmc5179
dmc5179 / fahclient.spec
Created April 9, 2020 20:28
RPM Spec file for the Folding @ Home Client
Name: fahclient
Version: 7.5.1
Release: 1%{?dist}
Summary: Folding @ Home Client
Group: Applications/Internet
License: Restricted
URL: https://foldingathome.org/
Source: https://download.foldingathome.org/releases/public/release/fahclient/centos-6.7-64bit/v7.5/fahclient_7.5.1-64bit-release.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@dmc5179
dmc5179 / docker-ce-rhel8.sh
Last active March 20, 2021 16:55
Docker CE on RHEL 8 with IPTables
#!/bin/bash
# Add Docker CE Repo
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
# Configure Docker CE Repo
sudo sed -i '/^gpgkey=https:\/\/download.docker.com\/linux\/centos\/gpg/a module_hotfixes=True' /etc/yum.repos.d/docker-ce.repo
# Install Docker CE
sudo dnf install -y docker-ce