Skip to content

Instantly share code, notes, and snippets.

@ToroNZ
ToroNZ / locktest.c
Created January 23, 2019 01:54
Lockfile test to see NFS CB_NOTIFY_LOCK behaviour between Linux/BSD NFS server implementations.
/*
* locktest.c
*
* Lock a file (block until we have a lock), write a message to the file, and
* sleep for a while. If we run multiple of these at once in a loop, we can show
* that file system locking is working correctly.
*
* USAGE:
* locktest.exe FILENAME SECONDS MESSAGE NUMRUNS
*
Request# Activate Forms REST API Endpoint Activate Openshift role Observations Example
1 Create/Delete Project POST /apis/project.openshift.io/v1/projectrequests
DELETE /apis/project.openshift.io/v1/projects
activate-project JSON schema defined here Create
curl -XPOST -H "Authorization: Bearer $TOKEN" -H "Accept: application/json" -H "Content-Type: application/json" https://$API_URL:8443/apis/project.openshift.io/v1/projectrequests -d {JSON}
Delete
curl -XDELETE -H "Authorization: Bearer $TOKEN" -H 'Accept: application/json' https://$API_URL/apis/project.openshift.io/v1/projects/$PROJECT_NAME
2 Sync groups POST /apis/user.openshift.io/v1/groups activate-groups-sync Syncs AD groups with Openshift ones.
JSON schema defined here
TBC - Tomas to define exactly how we are going to do this.
3 Bind Role `POST /apis/rbac.authorization.k8s.io/v1beta1/namespaces/$PROJECT_NAME/rolebin
#!/bin/bash
# Help.
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
echo 'Usage: teams-chat-post.sh "<webhook_url>" "<title>" "<color>" "<message>"'
exit 0
fi
# Webhook or Token.
WEBHOOK_URL=$1
if [[ "${WEBHOOK_URL}" == "" ]]
@ToroNZ
ToroNZ / env-to-json.py
Last active August 24, 2020 06:02
(python3) Get all ENV variables into JSON
#!/usr/bin/env python3
import os
import json
ENV_LIST = dict(os.environ.items())
VALUES = [{"key": k, "value": v, "secured": "true"} for k, v in ENV_LIST.items()]
LOCAL_VARS = json.dumps(VALUES, indent=4)
# Meant to be invoked in shell as '$ python3 env-to-json.py > local_vars.json'
@ToroNZ
ToroNZ / errata-report-to-html.sh
Last active June 14, 2021 02:42
Katello-content-host-report-HTML
#!/bin/bash
# Get list of hosts and outstanding errata from Satellite
hammer --csv content-hosts --export --columns "Name,OS,Security Errata,Bug Fix Errata,Enhancement Errata" --file /var/www/html/pub/errata.all.csv.txt
# Now create an html file from the CSV file
html_file=/var/www/html/pub/errata.html
( echo "<html>
<head><title>Contents Hosts Outstanding Errata</title>
</head>
vmaccepteula
install --firstdisk --overwritevmfs --novmfsondisk
network --bootproto=dhcp
rootpw Password123!!
keyboard English
reboot
%firstboot --interpreter=busybox
@font-face {
font-family: "";
/* Add other properties here, as needed. For example: */
/*
font-weight: 100 900;
font-style: normal italic;
*/
src: url(data:application/octet-stream;base64,d09GMgABAAAAAIkEABEAAAABZMwAAIifAAEFYAAAAAAAAAAAAAAAAAAAAAAAAAAAGoEWG4GHIhyoDAZgAIlkCGwJnBURCAqDqiCC9HEBNgIkA5FUC4hsAAQgBYcfB6BZDIE9W4REcYRc91sVOei5balkI7jSUiObOzXM9NzGrxiNVraKsc2i2e0A09W/V8r+//9PPioyZhpI221DABHxihdighyybiQTgiOMmwxTwtQomSSMIDikaBD6ZHsMraI3EZcglpOTsHWewixaJTiW3HRHRW27SMdEHtwhEZmd+MSPJY2E9hTV6ajmlRBTY7s71eC/A5vMe3HzsY4WtLM1qcZ0lBnNLKwYJxpyMI3XHH7Ejs9VrZDtXMp3w4yONTVPt2JKYs1p+68m+7e2jvIwny9W9J+ePtCNrKxk3rgQ/DfyyV7QCNfIvsynP2wMSZkN4j+kSIqE0eD5qztx3CB7uZKKxRGBNz2Gz+S+sgtiHUK1cQRvT5LjmzCdVPovjc/WGLsGhKRUk2GPflJB38XzH1m9h/cJ8peJ+Xl+bn/OfW/jLdnIGD1AqWi7wYrZWMVHPnZjkVNSidQm2sBqYoB08x8cZMIuhJGEBEgY2fsyN1lAJuwwZKoMRVmKRZzVtlgcY4Q6imt3W59dv7V2bD/W96rgZoQFlPOXzMJtfy2tVCCkgQ/VYT7p1DLMnn/8aeIy/TJlGX72/dhK4zshpclOQojcObk0uTQZjAyiS0dz/5mXnWRpdrIUoA9Iyp4VxJZIncKWVVVZVTUAjnTm/0iWSSatgL2CBZHNZ3OSCcE9xKZ79ceuD9r//
@ToroNZ
ToroNZ / Get-Certificate.ps1
Created July 12, 2022 10:01
Powershell - Check/Get SSL/TLS Certificate
using namespace System.Net.Sockets
using namespace System.Net.Security
using namespace System.Security.Cryptography.X509Certificates
function Test-ServerSSLSupport {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[ValidateNotNullOrEmpty()]
[string]$HostName,
@ToroNZ
ToroNZ / http-get.js
Last active July 13, 2022 06:06
JS HTTP Call Example
const https = require('https');
const options = {
hostname: 'portal-uat-v5.australiansuper.com',
port: 443,
path: '/',
method: 'GET'
};
const req = https.request(options, (res) => {
@ToroNZ
ToroNZ / az_aks_blob_helpers.sh
Created July 14, 2022 23:32
Access Azure resources from managed identities
#Get Token using Azure scope
curl -s 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fmanagement.azure.com%2F' -H Metadata:true
#Get Token using storage scope
curl 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fstorage.azure.com%2F' -H Metadata:true -s
#^Could use jq if/when available
# Store the token in variable
ACCESS_TOKEN="RESPONSE_TOKEN"