Skip to content

Instantly share code, notes, and snippets.

View mbierman's full-sized avatar

Michael Bierman mbierman

View GitHub Profile
@mbierman
mbierman / randommac.sh
Last active April 29, 2024 16:22
This allows you to create and assign any MAC address you like for macOS Wi-Fi or Ethernet connections. If you don’t supply one a random mac will be created for you.
#!/bin/bash
# v 1.0.2
# https://gist.github.com/mbierman/03b2a962ac04963ef5bbc8354d0ed5d1
# 2022 mbierman
sleep="${1:-5}"
regex="^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$"
getmac () {
rnd=$(openssl rand -hex 6 | sed 's/\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)/\1:\2:\3:\4:\5:\6/')
@mbierman
mbierman / updateIPCloudflare.sh
Last active April 26, 2024 00:33
DDNS update for Cloudflare with dual WAN support
#!/usr/bin/env bash
zoneID=""
ID=""
APIToken="-"
name="."
days=2020
result=""
# */5 * * * * /home/pi/.firewalla/config/post_main.d/updateIPCloudflare.sh >/dev/null 2>&1walla" ]; then
#!/bin/bash
#v 1.0.2
URL=$1
# Function to get the description for the certificate result
get_certificate_description() {
case $certificate_result in
0) echo "The certificate verification was successful." ;;
1) echo "The certificate could not be found." ;;
@mbierman
mbierman / reboot.sh
Last active March 6, 2024 06:31
Restart Homebridge
#!/bin/bash
# v 2.7
# https://gist.github.com/mbierman/dd45821b53d5d22147cef217f0c0fe95
# Variables
update="false"
reboot="false"
hostname=$(hostname)
docker="/.dockerenv"
@mbierman
mbierman / addremotesyslog.sh
Last active February 28, 2024 21:55
Add a remote syslog server to Firewalla
#!/bin/bash
# v 2.1.0
syslog=/etc/rsyslog.d/09-externalserver.conf
# this logs notice and above. use *.* log everything.
filter=*.notice
server=192.168.0.19 # Change the server to the IP of your syslog server.
port=514
hostname=firewalla
valid=$(grep "$server:$port" $syslog 2>/dev/null)
@mbierman
mbierman / logspeed.sh
Last active January 25, 2024 14:26
Log speedtest results on Firewalla
#!/bin/bash
# https://gist.github.com/mbierman/6a32df2909202c373a6a39063181dc40
# v 0.4.1
BASEDIR=$(dirname $0)
IFTTTKEY="$(cat $BASEDIR/IFTTT.data | grep IFTTTKEY| cut -f2 -d "=" )"
EVENT="FWspeedtest"
log=/data/logs/logspeed.log
@mbierman
mbierman / Readme.txt
Last active December 8, 2023 15:11
start homebridge on Fireawlla
Save this to ~/.firewalla/config/post_main.d inorder to make sure homebridge restarts automatically every time Firewalla does. That directory may not exist so just create it if that's the case.
@mbierman
mbierman / lights.sh
Last active November 13, 2023 16:27
Turn on/off lights on Unifi APs
#!/bin/bash
# Variables
result=""
count=0
log=/data/logs/lights.log
private=/home/pi/.firewalla/config/post_main.d/pass.txt
dir=$(dirname "$0")
user=$(cat $dir/lights.txt | grep user | cut -f2 -d "=" )
baseIP=192.168.0
@mbierman
mbierman / updatedocker.sh
Last active November 5, 2023 01:20
Update Docker containers
#i!/bin/bash
# version 3.1.2
# https://gist.github.com/mbierman/6cf22430ca0c2ddb699ac8780ef281ef
DOCKER=$(which docker)
wait=1
image=$1
if [ "$1" = "homebridge" ]; then
@mbierman
mbierman / mount_usb.sh
Last active September 26, 2023 17:56
Mount/unmount USB on Firewalla
#!/bin/bash
# V 1.0
# Copyright Michael Bierman
# https://gist.github.com/mbierman/85c9672d212bdda09d9d4f5d27574d1f
mount_point=/mnt/usb-stick/
mounted=$(mount -l | grep -c "/mnt/usb-stick")
if [ "$1" = "u" ] && [ "$mounted" -eq "1" ] ; then
read -p "Want to Unmount the drive. Please press 'Y' to continue or any key to stop: " -n1 now