Skip to content

Instantly share code, notes, and snippets.

View bmatthewshea's full-sized avatar

Brady Shea bmatthewshea

View GitHub Profile
@bmatthewshea
bmatthewshea / myip.bash
Last active June 16, 2024 19:50
Show public IP and other info from simple bash script or alias
#!/bin/bash
printf "Gateway:\n"; route | grep "^default" | cut -d " " -f 10
# captures ipv4 loopback/lo and primary lan interface, normally - adjust as needed:
printf "Private:\n"; ip -4 -o ad | grep "brd "| cut -d " " -f 7
# You do not need dig/nslookup for this to work (no dnsutils packages needed):
printf "Public:\n"; host -4 -t a myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has"| cut -d " " -f 4
# Instructions:
# Put this file in your path. (It does not need the ".bash" file extension.)
# Set permissions (example): `chmod 755 ~/scripts/myip`
# Run it.
@bmatthewshea
bmatthewshea / RPI-FullUpgrade.md
Last active March 9, 2024 16:34
Commands needed to upgrade RPI Raspbian/Debian System

Upgrade "Raspbian" Bullseye to Bookworm

(should work for any upgrade if you update release names)

Prep

sudo apt-get update
sudo apt-get upgrade
sudo apt-get full-upgrade
# Update the 2 individual files yourself, or run this:

sudo sed -i -e 's/bullseye/bookworm/g' /etc/apt/sources.list /etc/apt/sources.list.d/raspi.list

@bmatthewshea
bmatthewshea / APT-KEY-Deprecated_Fix_Debian_Ubuntu.md
Last active March 15, 2024 19:21
Add gpg key for Debian/Ubuntu repo - New format

apt-key add (key) is deprecated

On Debian Bookworm when running apt-key add.

NOTE: RSPAMD is only used as an example. This method should work for any deprecated install instructions for apt-key.

While executing:
wget -O- https://rspamd.com/apt-stable/gpg.key | apt-key add -

The following is observed:

"Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details."

@bmatthewshea
bmatthewshea / check_up.sh
Last active October 2, 2023 00:14
When Do I Go Back Online? (Capture a combined ping/grep reply in a variable)
#!/bin/bash
# WHEN DO I GO BACK ONLINE?
# Brady M. Shea - 23SEP2023
# For a StackOverflow answer (https://stackoverflow.com/a/77164885/503621)
# Original link: https://gist.github.com/bmatthewshea/87b70e3d75f8f8576cacdf1445daf4a6
# Variables/command subs
sleepy=60 # PING every SLEEPY seconds. 1 minute recommended.
hosttoping=google.com # can be google.com/etc. Should be a name based host. Not an IP.
@bmatthewshea
bmatthewshea / pflogsumm.sh
Last active August 7, 2023 14:28
pflogsumm cron.daily script
#!/bin/sh
# Save this script as:
# `/etc/cron.daily/pflogsumm`
# It should be owned by root.
# Then set permissions: `sudo chmod 755 /etc/cron.daily/pflogsumm`
# the script will also run directly if you wish to test it.
# Brady Shea 31Jul2023
test -x /usr/sbin/pflogsumm || exit 0
@bmatthewshea
bmatthewshea / get-product-key.ps1
Last active December 21, 2022 16:13
PowerShell script to calculate current "ProductKey"
### "get-product-key.ps1":
### (updated from https://superuser.com/a/1367165)
###
### To allow this script to run, execute one of these in admin PS:
###
### Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
### or
### Set-ExecutionPolicy RemoteSigned
###
### And then execute the following:
@bmatthewshea
bmatthewshea / check-restart-windows-service.ps1
Last active September 20, 2022 15:45
Query and restart a Windows service as needed. (PowerShell)
<#
Script: "check-restart-windows-service.ps1"
Query and restart service as needed.
Use task scheduler with this script.
Brady M. Shea - 16 Sep 2022
.Setting $ServiceName
.Find the service name to monitor by opening a PS command prompt and entering "GET-SERVICE"
@bmatthewshea
bmatthewshea / certbot_pip_install-debian_ubuntu.md
Last active October 22, 2024 20:39
Debian/Ubuntu - CERTBOT without SNAP/SNAPD

CERTBOT - Install using Python PIP

Install Certbot using Python PIP (Package Installer for Python) - without using SNAP, APT or SYSTEMD. (Debian/Ubuntu)


This guide will help you install LetsEncrypt / Certbot using venv PIP under Debian/Ubuntu.

  • This guide has been tested up to Debian 12 / Bookworm.
@bmatthewshea
bmatthewshea / Collatz_Conjecture_Example.py
Last active August 17, 2021 18:42
Collatz Conjecture (Python Example)
#!/usr/bin/python
#
# Collatz Conjecture:
# x → x/2 (if x is even)
# x → 3x + 1 (if x is odd)
import sys, time
# Default seed if no arguments given
seed = 27
@bmatthewshea
bmatthewshea / site_up_down.py
Last active August 5, 2021 02:55
Python script that does checks on apex domains from a text file. Checks status for bare apex / "www." subdomains and ssl / non-ssl. (4 checks on each domain). Outputs in CSV format.
#!/usr/bin/python
# -*- coding: utf-8 -*-
## Brady Shea - 04AUG2021 - (Python 3 script)
## This will read in a file list of plain APEX domains like:
## "example.com"
## If you want it in a file just pipe the script to a file.
## python3 -u ./sites-up-down.py | tee ./domain-check.csv
import requests