This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first argument to scritpt is directory, for example /etc/apt/sources.list.d | |
# output looks like: | |
# cat > /etc/apt/sources.list.d/trivy.sources <<EOF | |
#Types: deb | |
#URIs: https://aquasecurity.github.io/trivy-repo/deb | |
#Suites: jammy | |
#Components: main | |
#Aarch: amd64 | |
#Signed-By: -----BEGIN PGP PUBLIC KEY BLOCK----- | |
# . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for pdb in $(kubectl get pdb --all-namespaces -o json | \ | |
jq -r '.items[] | select(.status.disruptionsAllowed<1) | [.metadata.namespace,.metadata.name] | join("/")'); \ | |
do kubectl -n "${pdb%%/*}" delete pdb/"${pdb##*/}"; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
i=0 | |
done=0 | |
url="https://management.azure.com/providers/Microsoft.PolicyInsights/policyMetadata?api-version=2019-10-01" | |
while [ $done -ne 1 ] | |
do | |
echo az rest --output-file "pm-${i}.json" --url "$url" | |
az rest --output-file "pm-${i}.json" --url "$url" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# courtesy of Szymon Stepniak | |
# See https://e.printstacktrace.blog/merging-json-files-recursively-in-the-command-line/ | |
jq -s 'def deepmerge(a;b): | |
reduce b[] as $item (a; | |
reduce ($item | keys_unsorted[]) as $key (.; | |
$item[$key] as $val | ($val | type) as $type | .[$key] = if ($type == "object") then | |
deepmerge({}; [if .[$key] == null then {} else .[$key] end, $val]) | |
elif ($type == "array") then | |
(.[$key] + $val | unique) | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this only works on Linux if your $HOME/.docker/config.json has no "credsStore" entry | |
az acr login -n <registry> --expose-token --output tsv --query accessToken 2>/dev/null \ | |
| docker login <registry-fqdn> --username 00000000-0000-0000-0000-000000000000 --password-stdin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
email=<corp-email-address> | |
always-auth=true | |
cafile=/usr/share/ca-certificates/corp-certs/corp-ca.crt | |
registry=https://artifactory.local/artifactory/api/npm/corp-npm-agg/ | |
//artifactory.local/artifactory/api/npm/corp-npm-agg/:_authToken=<artifactory-api-token> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat private-pkcs8.pem | openssl pkey -pubout -in - | openssl md5 | |
(stdin)= 3b6b231d32d76732b76d04b1bcb53270 | |
$ cat website.cer | openssl x509 -pubkey -noout -in - | openssl md5 # got the cer by copying from browser | |
(stdin)= 3b6b231d32d76732b76d04b1bcb53270 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
AZURE_RESOURCE_GROUP=$1 | |
CLUSTER_NAME=$2 | |
LOCATION=$3 | |
AZURE_NODEGROUP=$(az aks show -n ${CLUSTER_NAME} -g ${AZURE_RESOURCE_GROUP} -o tsv --query nodeResourceGroup) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# backup | |
pg_dump -v -Fd -U $USER -f $DUMP_DIR $DB | |
# restore, doing required drops beforehand to avoid most constraint errors | |
pg_restore --verbose --clean --no-acl --no-owner -Fd -U $USER -d $DB $DUMP_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
RG=$1 | |
AKS=$2 | |
POOL=$3 | |
SUB=$(az account show -o tsv --query id) |
NewerOlder