Skip to content

Instantly share code, notes, and snippets.

View brunerd's full-sized avatar

Joel Bruner brunerd

View GitHub Profile
#!/bin/bash
#macOS - returns 0 or 1 depending on if we are a running in a VM or not
grep -c VMM <<< $(sysctl -n machdep.cpu.features)
@brunerd
brunerd / removeSpawnOfZoomOpenerAllUsers.sh
Last active August 8, 2019 23:07
Removes all the ZoomOpener variants for all users
#!/bin/bash
#Joel Bruner - removes all ZoomOpener variants for all users
#############
# VARIABLES #
#############
#folder names where lurking webservers live
folderNames=".ringcentralopener
.zoomus
@brunerd
brunerd / shell_vers.sh
Last active October 25, 2019 15:15
Quickly get versions of items in /etc/shells
#!/bin/sh
#brunerd - shell_vers
#a simple version checker of available shells
#not guaranteed to always work (I'm looking at YOU dash!)
#specify another volume to test
target="$1"
#loop through /etc/shells either locally or on specified target volume
for shell in $(grep -v ^\# "${1}"/etc/shells); do
@brunerd
brunerd / repackPKGs.command
Created October 28, 2019 17:28
Repack expired packages and strip off certs
#!/bin/bash
#Joel "brunerd" Bruner - repack and expired pkg, stripping off all certs
#we can specify a target as an argument
target="$1"
#if target not specified we ask
while [ ! -d "${target}" -a ! -f "${target}" ]; do
read -p "Please provide a target file or folder: " target
done
@brunerd
brunerd / nothing
Last active February 10, 2020 03:56
Uses of : (no effect)
#to officially do nothing
:
#there you go, this could be used when writing or troubleshooting a script and you have only a single item in an if clause
if [ "${this}" = "that" ]; then
#actually not sure what to do here, let's do nothing
:
else
echo "This else, I'll do"
@brunerd
brunerd / BTSharingStates
Last active November 7, 2020 04:35
Report the states of Bluetooth Sharing services in macOS using jpt to parse JSON output from system_profiler
#!/bin/bash
#Joel Bruner
#BTSharingStateas - report bluetooth sharing states from system_profiler using jpt to parse output
#if jpt is not installed locally, embed function from jpt.min into this script: https://github.com/brunerd/jpt
#get all the data once
SPBluetooth=$(system_profiler -json SPBluetoothDataType 2>/dev/null)
#get the paths related to service state
statePaths=$(jpt -jd '$..service_state' <<< "${SPBluetooth}")
#!/bin/bash
#fixJSON-TrailersComments - fix JSON with trailing commas and comments (JS, Shell and * style)
: <<-LICENSE_BLOCK
Copyright (c) 2020 Joel Bruner (https://github.com/brunerd)
Licensed under the MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HO
@brunerd
brunerd / certChecker.command
Last active November 24, 2020 13:24
Check the signing certificates on pkg packages and apps
#!/bin/bash
#certChecker - gets the certificate expiration(s) from a pkg or an app and outputs as CSV
: <<-EOL
MIT License
Copyright (c) 2020 Joel Bruner (brunerd.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
#malformed JSON (according to json_pp) by macOS version
#jpt (https://github.com/brunerd/jpt) can parse all of these now
## NOTES on the Files ##
# USD generated JSON contains # comments
# /private/var/db/ionodecache.json - has a single *** COMMENT *** line at the top
# /System/Library/PrivateFrameworks/CoreAnalytics.framework/Versions/A/Resources/defaultConfig.json i - is "JSON Lines" aka "concatenated JSON"
# Most of the others have trailing commas after the final member of arrays and objects
## SPECIAL Note ##
@brunerd
brunerd / Malformed-macOS-10.15.csv
Last active December 16, 2020 23:20
macOS JSON files that fail to parse with json_pp (but jpt can parse them)
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 4 columns, instead of 3. in line 5.
Status,Issue Notes,Path,Error Output
ERROR,"""JSON Lines""/Concatenated",/System/Library/PrivateFrameworks/CoreAnalytics.framework/Versions/A/Resources/defaultConfig.json,"garbage after JSON object, at character offset 143 (before """"addTransform"":{""uui..."") at /usr/bin/json_pp5.18 line 45."
ERROR,Trailing Comma,/Library/Developer/CommandLineTools/usr/lib/swift/migrator/overlay4.json,"malformed JSON string, neither array, object, number, string or atom, at character offset 41290 (before ""]\n"") at /usr/bin/json_pp5.18 line 45."
ERROR,Trailing Comma,/Library/Developer/CommandLineTools/usr/lib/swift/migrator/overlay42.json,"malformed JSON string, neither array, object, number, string or atom, at character offset 608 (before ""]\n"") at /usr/bin/json_pp5.18 line 45."
ERROR,*** Comment ***,/private/var/db/ionodecache.json,"malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before ""*** Device Tree ***\n..."") at /usr/bin/json_pp5.18 line 45."
ERROR,Trailing Commas,/S