Skip to content

Instantly share code, notes, and snippets.

{
"semi": false,
"singleQuote": true,
"printWidth": 150,
"htmlWhitespaceSensitivity": "ignore"
}
- --serverstransport.insecureskipverify=true
- --entrypoints.websecure.http.tls=true
@adamhancock
adamhancock / k8s_evicted_pods.sh
Created September 21, 2020 15:27
Delete evicted pods from all namespaces in Kubernetes
kubectl get po -A --all-namespaces -o json | jq '.items[] | select(.status.reason!=null) | select(.status.reason | contains("Evicted")) | "kubectl delete po \(.metadata.name) -n \(.metadata.namespace)"' | xargs -n 1 bash -c
@adamhancock
adamhancock / install-docker-kube.sh
Last active August 13, 2020 15:40 — forked from chadmcrowell/install-docker-kube.sh
Installing the Kubernetes Cluster - From CKA Course - Linux Academy
# Get the Docker gpg key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# Add the Docker repository
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
# Get the Kubernetes gpg key
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
@adamhancock
adamhancock / delete-evicted-pods-all-namespaces.sh
Created January 19, 2020 22:42 — forked from 15below-adamhancock/delete-evicted-pods-all-namespaces.sh
Delete evicted pods from all namespaces (also ImagePullBackOff and ErrImagePull)
#!/bin/sh
# based on https://gist.github.com/ipedrazas/9c622404fb41f2343a0db85b3821275d
# delete all evicted pods from all namespaces
kubectl get pods --all-namespaces | grep Evicted | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod --namespace $1
# delete all containers in ImagePullBackOff state from all namespaces
kubectl get pods --all-namespaces | grep 'ImagePullBackOff' | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod
# delete all containers in ImagePullBackOff or ErrImagePull or Evicted state from all namespaces
@adamhancock
adamhancock / transmission_remove_finished.sh
Created January 19, 2020 08:12 — forked from pawelszydlo/transmission_remove_finished.sh
Script to clear finished torrents from transmission-daemon
#!/bin/bash
# port, username, password
SERVER="localhost:9091 --auth user:pass"
# use transmission-remote to get torrent list from transmission-remote list
TORRENTLIST=`transmission-remote $SERVER --list | sed -e '1d' -e '$d' | awk '{print $1}' | sed -e 's/[^0-9]*//g'`
# for each torrent in the list
for TORRENTID in $TORRENTLIST
#!/bin/sh
# https://dl.ubnt.com/unifi/5.11.46/unifi_sh_api
#username=ubnt
#password=ubnt
#baseurl=https://unifi:8443
#site=default
#[ -f ./unifi_sh_env ] && . ./unifi_sh_env
cookie=$(mktemp)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$From = "EmailAddress@gmail.com"
$To = "SomeOtherAddress@whatever.com"
$Cc = "AThirdUser@somewhere.com"
$Subject = "Here's the Email Subject"
$Body = "This is what I want to say"
$SMTPServer = "smtp.gmail.com"
$SMTPPort = "587"
Send-MailMessage -From $From -to $To -Cc $Cc -Subject $Subject -Body $Body -SmtpServer $SMTPServer -port $SMTPPort -UseSsl -Credential (Get-Credential) –DeliveryNotificationOption OnSuccess
# Adam Hancock
if(Get-Module MSOnline){
write-host "Module already installed."
}else{
Install-Module -Force MSOnline
}
if(!$Cred){
$Cred = Get-Credential
}
## Adam Hancock
rm -f output.csv
echo "Domain, IP, MX IP, Nameservers" >> output.csv
while read d; do
p=`echo $d | sed -e 's/www.//g'`
website=`dig @8.8.8.8 +short $p | head -n1`
mx=`dig @8.8.8.8 +short mx $p | cut -d " " -f 2 | head -n1`
nameservers=`dig ns $p +short`
nameserver1=`echo $nameservers | head -n1`
mx1=`dig +short $p mx | sort -n | awk '{print $2; exit}' | dig +short -f - | head -n1`