Skip to content

Instantly share code, notes, and snippets.

@ruzickap
ruzickap / aws_route53_subdomain.sh
Created May 6, 2020
AWS Route53 subdomain delegation
View aws_route53_subdomain.sh
# You have defined the "cna.example.cloud" zone in Route53
# You want to create subdomain "${USER}-k8s.cna.example.cloud" and configure proper delegation form parrent zone
echo "* Create DNS zone ${USER}-k8s.cna.example.cloud"
aws route53 create-hosted-zone --output json \
--name ${USER}-k8s.cna.example.cloud \
--caller-reference "$(date)" \
--hosted-zone-config="{\"Comment\": \"Created by ${USER}@example.com\", \"PrivateZone\": false}" | jq
@ruzickap
ruzickap / Deploy public ssh key from GutHub user
Last active Mar 26, 2020
deploy-public-ssh-key-github.sh
View Deploy public ssh key from GutHub user
GITHUB_USERNAME="${GITHUB_USERNAME:-ruzickap}"
DESTINATION_DIRECTORY="${DESTINATION_DIRECTORY:-/root/.ssh}"
[[ ! -d "${DESTINATION_DIRECTORY}" ]] && mkdir -v --mode=0700 "${DESTINATION_DIRECTORY}"
wget "https://github.com/${GITHUB_USERNAME}.keys" -O "${DESTINATION_DIRECTORY}/authorized_keys"
chmod 0600 "${DESTINATION_DIRECTORY}/authorized_keys"
@ruzickap
ruzickap / k8s-debug.sh
Created Mar 21, 2020
Kubernetes debug notes
View k8s-debug.sh
kubectl get events --sort-by=.metadata.creationTimestamp
kubectl logs -n monitoring prometheus-prometheus-operator-prometheus-0 --all-containers
@ruzickap
ruzickap / check_urls.sh
Last active Feb 2, 2020
Automatically check links on web pages
View check_urls.sh
git clone git@github.com:ruzickap/check_urls.git
cd check_urls
mkdir -p .github/workflows
cat > .github/workflows/periodic-broken-link-checks.yml << \EOF
name: periodic-broken-link-checks
on:
schedule:
- cron: '0 0 * * *'
@ruzickap
ruzickap / git-repository-gpg-crypt
Created Nov 1, 2019
Make git repository encrypted with generated GPG key which can be used by CI/CD to access the git repo when using GitHub Actions
View git-repository-gpg-crypt
# Make sure you are using gpg2
git config --global gpg.program gpg2
# Clone empty repository
git clone git@github.com:ruzickap/terraform-gitops.git
# Configure a repository to use git-crypt
cd terraform-gitops
git-crypt init
View kubernetes_notes.sh
# Connect to PostgreSQL database internally
kubectl run -i --tty --rm psql --image=postgres --env "PGPASSWORD=user_password" --command -- \
psql -U myuser -h patroni.patroni.svc.cluster.local my_database
# Port forwarding to service
kubectl port-forward -n harbor service/harbor 8080:443
@ruzickap
ruzickap / benchmark_disk.sh
Created Jul 10, 2019
This script is trying to produce the same stats as CrystalDiskMark for Windows using fio.
View benchmark_disk.sh
#!/bin/bash -eu
# This script is trying to produce the same stats as CrystalDiskMark for Windows
# using fio.
# If you specify the raw disk (like /dev/sdc) the all it's content will be removed!
# The script should not run longer than 20 minutes
TMP_FILE=${TMP_FILE:-/tmp/$(basename $0).tmp}
UNATTENDED=${UNATTENDED:-0}
@ruzickap
ruzickap / debug_ddns_service.sh
Created Jun 4, 2019
Debug service on OpenWrt
View debug_ddns_service.sh
sed -r -i 's%^(#!.*)%\1\nset -x -v\nexec \&>/tmp/ddns-init.log%' /etc/init.d/ddns
sed -r -i 's%^(#!.*)%\1\nset -x -v\nexec \&>/tmp/ddns-hotplug.log%' /etc/hotplug.d/iface/95-ddns
sed -r -i 's%^(#!.*)%\1\nset -x -v\nexec \&>/tmp/ddns-updater.log%' /usr/lib/ddns/dynamic_dns_updater.sh
# $ head -5 /etc/init.d/ddns
# #!/bin/sh /etc/rc.common
# set -x -v
# exec &>/tmp/ddns-init.log
# START=95
# STOP=10
@ruzickap
ruzickap / delete_remove_virtualbox_vm.sh
Last active May 23, 2019
Delete and remove VM in Virtualbox
View delete_remove_virtualbox_vm.sh
VBoxManage list vms
VBoxManage controlvm 6d3e674d-7626-4142-969f-8017b679fbd0 poweroff
VBoxManage unregistervm --delete 6d3e674d-7626-4142-969f-8017b679fbd0
@ruzickap
ruzickap / latest_vagrant_install.sh
Created May 21, 2018
Install latest Vagrant using command line
View latest_vagrant_install.sh
#!/bin/bash
apt-get install -y --no-install-recommends ca-certificates curl jq
VAGRANT_LATEST_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/vagrant | jq -r -M '.current_version')
curl https://releases.hashicorp.com/vagrant/${VAGRANT_LATEST_VERSION}/vagrant_${VAGRANT_LATEST_VERSION}_x86_64.deb --output /tmp/vagrant_x86_64.deb
apt install -y /tmp/vagrant_x86_64.deb
rm /tmp/vagrant_x86_64.deb
You can’t perform that action at this time.