Skip to content

Instantly share code, notes, and snippets.

View johnsimcall's full-sized avatar

John Call johnsimcall

View GitHub Profile
@johnsimcall
johnsimcall / hotspot.md
Last active January 4, 2025 09:49
Use NetworkManager to create a WiFi hotspot

Option 1 - more control

nmcli con add type wifi  conn.id "John Hotspot" \
      conn.interface-name wlp0s20f0u1 \
      conn.autoconnect no \
      wifi.mode ap \
      wifi.band a \
      wifi.channel 32 \
 wifi.ssid "John Hotspot" \
@johnsimcall
johnsimcall / jwt_decode.sh
Created October 25, 2024 22:38
Decode JWT in bash (OpenShift authentication tokens)
# https://gist.github.com/thomasdarimont/46358bc8167fce059d83a1ebdb92b0e7?permalink_comment_id=5139846#gistcomment-5139846
function jwt_decode(){
jq -R 'split(".") | .[1] | @base64d | fromjson |
# you can replace the "localtime" with "gmttime" if that makes sense
if .exp then (.expStr = (.exp | localtime | strftime("%Y-%m-%dT%H:%M:%S %Z"))) else . end |
if .iat then (.iatStr = (.iat | localtime | strftime("%Y-%m-%dT%H:%M:%S %Z"))) else . end |
if .nbf then (.nbfStr = (.nbf | localtime | strftime("%Y-%m-%dT%H:%M:%S %Z"))) else . end |
.' <<< "$1"
}
@johnsimcall
johnsimcall / query-vm-memory.md
Last active October 23, 2024 20:51
Report Virtual Machine memory requests

This is hacky because there are at least three different ways to set the VM's memory.

  1. .spec.template.spec.domain.memory.guest
  2. .spec.instancetype.name
  3. .spec.template.spec.domain.resources.requests.memory
oc get vm -A -o go-template='{{range .items}}{{.metadata.name}}{{"\t"}} {{.status.printableStatus}}{{"\t"}} {{.spec.template.spec.domain.memory.guest}} {{.spec.instancetype.name}}{{"\t"}} {{.spec.template.spec.domain.resources.requests.memory}}{{"\n"}}{{end}}'

rhel-9-amber-limpet-47          	 Running	 <no value>  u1.medium	 <no value>
test103 Running   8Gi
@johnsimcall
johnsimcall / win2022-autounattend-configmap.yaml
Created September 20, 2024 23:57
OpenShift Virtualization - Automating Windows Server 2022 template creation
---
apiVersion: v1
kind: ConfigMap
metadata:
name: windows2k22-autounattend
data:
autounattend.xml: |
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
<servicing>
@johnsimcall
johnsimcall / apply-cockpit-certificate.sh
Last active September 19, 2024 05:18
Cockpit certificate
### This is a little script to help me install / rotate Cockpit certificates
#!/bin/bash
CERT_PKCS7=$(hostname -f).pkcs7
CERT_PEM=$(hostname -f).pem
KEY=$(hostname -f).key
DEST=/etc/cockpit/ws-certs.d/$(hostname -f).cert
[ -f $CERT_PKCS7 ] || echo "Certificate file not found: $CERT_PKCS7"
#!/bin/bash
shopt -s nullglob
for g in $(find /sys/kernel/iommu_groups/* -maxdepth 0 -type d | sort -V); do
echo "IOMMU Group ${g##*/}:"
for d in $g/devices/*; do
echo -e "\t$(lspci -nns ${d##*/})"
done;
done;
@johnsimcall
johnsimcall / imageset-config.yaml
Last active May 16, 2023 14:22
oc-mirror ImageSetConfiguration for NVIDIA GPU Operator
---
kind: ImageSetConfiguration
apiVersion: mirror.openshift.io/v1alpha2
storageConfig:
registry:
imageURL: jcall-testing.dota-lab.iad.redhat.com:8443/oc-mirror/oc-mirror-metadata
mirror:
platform:
graph: true # this requires a download from github.com
channels:
@johnsimcall
johnsimcall / rhel8.ks
Created November 10, 2022 22:55
RHEL8 kickstart with RAID for UEFI, boot, and root (via LVM)
# Kicstart created by John Call
# Installs RHEL8 via HTTP
url --url="http://rhdata6/rhel8/"
graphical
lang en_US.UTF-8
firstboot --disable
rootpw --plaintext My-Password-123
services --enabled="chronyd"
timezone America/New_York --isUtc
@johnsimcall
johnsimcall / nncp-node1.yaml
Last active October 26, 2022 03:08
NodeNetworkConfigurationPolicy (NNCP) example
# https://docs.openshift.com/container-platform/4.11/networking/k8s_nmstate/k8s-nmstate-updating-node-network-config.html
apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
name: node1
spec:
nodeSelector:
kubernetes.io/hostname: node1.example.com
desiredState:
@johnsimcall
johnsimcall / squid.conf
Last active January 23, 2025 08:44
squid behind squid - squid.conf
### ACL for Approved/Allowed sites, insert below this line in default config
#acl CONNECT method CONNECT
acl Approved_Sites dstdomain "/etc/squid/Approved_Sites.txt"
http_access deny !Approved_Sites
http_access allow Approved_Sites
### Force this proxy to use another proxy
#cache_peer hostname type http_port icp_port options