Skip to content

Instantly share code, notes, and snippets.

View mbierman's full-sized avatar

Michael Bierman mbierman

View GitHub Profile
#!/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 / 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
@mbierman
mbierman / batcheck.sh
Last active July 7, 2023 21:41
Checks battery level for Magic Mouse, Magic Trackpad and Magic Keyboard on macOS.
#!/bin/bash
# Script that checks the battery level of connected Magic Keyboard, Magic Trackpad, and Magic Mouse and displays a notification if it is below a threshold (default 15%).
# Optionally set threshold as a parameter. ex: ./check_kb_battery.sh 10
COMPARE=${1:-15}
check_battery_level() {
device_name=$1
battery_level=$2
#!/bin/bash
diskusage=$(df -H | grep -vE '^Filesystem|mmcblk0p3' | awk '{ print $6 }')
name=$(printf "$(redis-cli get groupName)")
log=/data/logs/fwcheckspace.log
mydate=$(date +"%a %b %d %H:%M %P")
dir=$(dirname "$0")
IFTTTKEY="$(cat $dir/IFTTT.data | grep IFTTTKEY | cut -f2 -d "=" )"
IFTTTrigger="FWGReboot"
IMAGE="https://avatars2.githubusercontent.com/u/21322342?s=200&v=4"
URL="firewalla://" # opens the firewalla app on iOS
@mbierman
mbierman / flotest.sh
Last active January 20, 2023 10:20
grabs the token stored in homebridge for flo and sees if it needs updating. See also reboot.sh
#!/bin/sh
# v 1.2
# https://gist.github.com/mbierman/dd45821b53d5d22147cef217f0c0fe95
# Variables
docker="/.dockerenv"
dir=$(dirname "$0")
IFTTTKEY="$(cat $dir/rebootdata.txt | grep IFTTTKEY | cut -f2 -d "=" )"
IFTTTTrigger="$(cat $dir/rebootdata.txt | grep IFTTTTrigger | cut -f2 -d "=" )"
@mbierman
mbierman / info.sh
Last active September 15, 2022 18:01
Info for your Firewalla box
#!/bin/bash
# Michael Bierman
# v1.0
# https://gist.github.com/mbierman/a84c8ad4b2b4617ccc8d16f66df10197
version=$(cat ~/firewalla/net2/config.json | jq '.version')
version=${version:=Not Found}
OS=$(lsb_release -r | cut -f2)
@mbierman
mbierman / epocdate.sh
Last active September 8, 2022 00:09
Gets epoc dates for some number of minutes and hours you select before now. Mostly created for plaing with Firewalla MSP API
#!/bin/bash
# v 1.0.1
# https://gist.github.com/mbierman/f81b591fd27638b9f4221e9525229eca
echo -e "How many minutes before now?"
read minutes
# min=$(date -v-${minutes}M +%s)
minutes=${minutes:=0}
echo -e "You entered $minutes minutes\n\n"
@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 / backup.sh
Last active August 2, 2022 08:39
pihole stuff
#!/bin/bash
retain=30
# This script will create a Teleport backup to a directory that it is run in.
# Change to mapped directory
cd /home/ubuntu/backups
# Run Backup
pihole -a -t &
# Record the process id and wait
@mbierman
mbierman / install_FWUtilities.sh
Last active April 12, 2023 16:27
installation of various tools on Firewalla
#!/bin/bash
# v 1.01
# https://gist.githubusercontent.com/mbierman/ced69a41181637995f61323e7ac97cba/raw/214028a0430b5a54788ca727849aca84f0aed594/install_FWToys.sh
dir="/home/pi/.firewalla/config/post_main.d/"
app="install_sshpass.sh"
cd $dir