Skip to content

Instantly share code, notes, and snippets.

Andy hongkongkiwi

Block or report user

Report or block hongkongkiwi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hongkongkiwi
hongkongkiwi / 99-zerotier-ddns
Last active Sep 8, 2019
networkd-dispatcher routable.d config for zerotier-ddns
View 99-zerotier-ddns
#!/bin/bash
command -v zerotier-cli >/dev/null 2>&1 || { echo >&2 "I require zerotier-cli but it's not installed. Aborting."; exit 1; }
command -v systemctl >/dev/null 2>&1 || { echo >&2 "I require systemctl but it's not installed. Aborting."; exit 1; }
# Vars for updating
export ZONE=domain.com
export HOST=zt.domain.com
export USE_DYNAMIC_HOSTNAME=true
export API=yourapikey
@hongkongkiwi
hongkongkiwi / cloudflare-ddns.service
Created Sep 8, 2019
Runs a cloudflare ddns script to update the zerotier network address via Systemd
View cloudflare-ddns.service
# /etc/systemd/system/cloudflare-ddns.service
[Unit]
Description=Zerotier DDNS Client
Wants=network-online.target
After=network.target
[Service]
Type=oneshot
Environment=ZONE=bla.com
@hongkongkiwi
hongkongkiwi / andy-motd-generator
Created May 8, 2019
Please this script into /etc/periodic/15m/motd to generate a message of the day every 15 mins
View andy-motd-generator
#!/bin/sh
UPTIME_DAYS=$(expr `cat /proc/uptime | cut -d '.' -f1` % 31556926 / 86400)
UPTIME_HOURS=$(expr `cat /proc/uptime | cut -d '.' -f1` % 31556926 % 86400 / 3600)
UPTIME_MINUTES=$(expr `cat /proc/uptime | cut -d '.' -f1` % 31556926 % 86400 % 3600 / 60)
FIRST=yes
for iface in $(ls -A /sys/class/net | grep eth)
do
INTERFACE="`echo "$iface" | sed 's/.*/\u&/'` Address: `ifconfig $iface | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'`"
if [ $FIRST == "no" ]; then
@hongkongkiwi
hongkongkiwi / renew-cert.sh
Created May 6, 2019
Rewnew LetsEncrypt Certificate using docker. I use this for a crontab script.
View renew-cert.sh
#!/bin/bash
DOMAIN="$1"
TYPE="$2"
if [[ "$DOMAIN" == "" ]]; then
echo "No domain passed e.g. example.com"
exit 1
fi
@hongkongkiwi
hongkongkiwi / ykman-setup
Created Mar 4, 2019
Script to setup Yubikey to our desired configuration.
View ykman-setup
#!/bin/bash
YKMAN_BIN="ykman"
USE_PIV="NO"
USE_OPENPGP="YES"
YUBKEY_LIST=("")
NFC_ENABLED=""
@hongkongkiwi
hongkongkiwi / install-docker-compose.sh
Created Oct 24, 2018
Easily install or upgrade docker-compose on any system!
View install-docker-compose.sh
#!/bin/sh
COMPOSE_PATH="/usr/local/bin/docker-compose"
if `command -v "docker-compose" >/dev/null 2>&1`; then
CURRENT_VERSION=`docker-compose -v | sed 's|.*version \([0-9\.]*\).*|\1|'`
if [[ ! -f "$COMPOSE_PATH" ]]; then
echo "WARNING"
echo "Looks like docker-compose is not residing in $COMPOSE_PATH"
echo "This is OK, but make sure that your path variable has /usr/local/bin first to make sure you are running the latest"
@hongkongkiwi
hongkongkiwi / get-total-docker-images-sizes
Created May 19, 2018
One Liner to Get Docker Images Total Filesize
View get-total-docker-images-sizes
docker images --format "{{.Size}}" | sed -e 's/t/kg/i;s/g/km/i;s/m/kk/i;s/k/*1000/ig;s/b//i' | bc | paste -sd+ | bc | numfmt --to=iec-i --suffix=B --padding=7 | tr -d ' '
@hongkongkiwi
hongkongkiwi / zk-docker-compose-sync
Created May 16, 2018
Sync a Docker-Compose file to a Zookeeper
View zk-docker-compose-sync
#!/bin/bash
DOCKER_COMPOSE_FILE="$2"
ACTION="$1"
SERVER=${3:-"localhost:2181"}
USAGE="$0 action 'docker-compose.yml' ['localhost:2181']"
if [[ "$ACTION" == "" ]]; then
echo "$USAGE"
@hongkongkiwi
hongkongkiwi / Zookeeper-Kafka-Tools.md
Last active May 16, 2018
Get Zookeeper info from Bash
View Zookeeper-Kafka-Tools.md

Useful Zookeeper & Kafka CLI tools

Install Zeke pip install zeke

Install JQ brew install jq

Install Kefkacat brew install kefkacat

@hongkongkiwi
hongkongkiwi / Kafka-Docker-Compose.yml
Last active May 16, 2018
Zookeeper+Kafka+Kafka-Rest-Proxy+Kafka-Topic-UI
View Kafka-Docker-Compose.yml
version: '3.5'
services:
zookeeper:
image: zookeeper:3.4.9
hostname: zookeeper
ports:
- "2181:2181"
environment:
ZOO_MY_ID: 1
You can’t perform that action at this time.