This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# jamflog - Copyright (c) 2021 Joel Bruner, Licensed under the MIT License | |
# a way to log to stdout and /var/log/jamf.log (or elsewhere) and have it match Jamf's log style | |
function jamflog(){ | |
[ -n "${-//[^x]/}" ] && { local xTrace=1; set +x; } &>/dev/null | |
local logFile="${2:-/var/log/jamf.log}" | |
#if it exists but we cannot write to the log or it does not exist, unset and tee simply echoes | |
[ -e "${logFile}" -a ! -w "${logFile}" ] && unset logFile | |
#this will tee to jamf.log in the jamf log format: <Day> <Month> DD HH:MM:SS <Computer Name> ProcessName[PID]: <Message> | |
builtin echo "$(/bin/date +'%a %b %d %H:%M:%S') ${jamflog_myComputerName:="$(/usr/sbin/scutil --get ComputerName)"} ${jamflog_myName:="$(/usr/bin/basename "${0%.*}")"}[${myPID:=$$}]: ${1}" | /usr/bin/tee -a "${logFile}" 2>/dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#inZoomMeeting (20220214) Copyright (c) 2021 Joel Bruner (https://github.com/brunerd) | |
#Licensed under the MIT License | |
function inZoomMeeting { | |
#if this process exists, there is a meeting, return 0 (sucess), otherwise 1 (fail) | |
pgrep "CptHost" &>/dev/null && return 0 || return 1 | |
} | |
if inZoomMeeting; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#kcpasswordDecode (20220729) Copyright (c) 2021 Joel Bruner (https://github.com/brunerd) | |
#Licensed under the MIT License | |
#specify file as input | |
#kcpasswordDecode.sh /etc/kcpassword | |
#given a filepath XOR to the it back and truncate padding | |
function kcpasswordDecode() ( | |
filepath="${1}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#kcpasswordEncode (20220610) Copyright (c) 2021 Joel Bruner (https://github.com/brunerd) | |
#Licensed under the MIT License | |
#given a string creates data for /etc/kcpassword | |
function kcpasswordEncode () ( | |
#ascii string | |
thisString="${1}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function kcpasswordEncode_perl { | |
local PASSWORD="${1}"; | |
#one-liner variation of Gavin Brock's kcpassword.pl | |
perl -ne 'sub kcpassword_xor { my ($pass)=@_; my @key=qw( 125 137 82 35 210 188 221 234 163 185 31 ); my $key=pack "C*", @key; my $key_len=length $key; for (my $n=0; $n<length($pass); $n+=$key_len) { substr($pass,$n,$key_len) ^= $key; }; return $pass; }; $userinput = $_; chomp ($userinput); print(kcpassword_xor($userinput));' <<< "${PASSWORD}" | |
} | |
kcpasswordEncode_perl "${1}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#work with CFAbsoluteTime in shell | |
#https://developer.apple.com/documentation/corefoundation/cfabsolutetime | |
#https://developer.apple.com/documentation/corefoundation/1543542-cfabsolutetimegetcurrent | |
#get epoch time for CFAbsoluteTime 0 (978307200) | |
#same as the constant kCFAbsoluteTimeIntervalSince1970 in https://github.com/opensource-apple/CF/blob/master/CFDate.c | |
/bin/date -j -f "%b %d %T %Z %Y" "Jan 1 00:00:00 GMT 2001" "+%s" | |
#Now in CFAbsoluteTime | |
echo $(( $(date +"%s") - 978307200 )) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#Joel Bruner (https://github.com/brunerd) | |
function screenIsLocked { [ "$(/usr/libexec/PlistBuddy -c "print :IOConsoleUsers:0:CGSSessionScreenIsLocked" /dev/stdin 2>/dev/null <<< "$(ioreg -n Root -d1 -a)")" = "true" ] && return 0 || return 1; } | |
function screenIsUnlocked { [ "$(/usr/libexec/PlistBuddy -c "print :IOConsoleUsers:0:CGSSessionScreenIsLocked" /dev/stdin 2>/dev/null <<< "$(ioreg -n Root -d1 -a)")" != "true" ] && return 0 || return 1; } | |
if screenIsLocked; then | |
echo "Screen locked" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ModelID | 10.4 | 10.5 | 10.6 | 10.7 | 10.8 | 10.9 | 10.10 | 10.11 | 10.12 | 10.13 | 10.14 | 10.15 | 11 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
iMac4,1 | 10.4 | 10.5 | 10.6 | |||||||||||
iMac4,2 | 10.4 | 10.5 | 10.6 | |||||||||||
iMac5,1 | 10.4 | 10.5 | 10.6 | 10.7 | ||||||||||
iMac5,2 | 10.4 | 10.5 | 10.6 | 10.7 | ||||||||||
iMac6,1 | 10.4 | 10.5 | 10.6 | 10.7 | ||||||||||
iMac7,1 | 10.4 | 10.5 | 10.6 | 10.7 | 10.8 | 10.9 | 10.10 | 10.11 | ||||||
iMac8,1 | 10.5 | 10.6 | 10.7 | 10.8 | 10.9 | 10.10 | 10.11 | |||||||
iMac9,1 | 10.5 | 10.6 | 10.7 | 10.8 | 10.9 | 10.10 | 10.11 | |||||||
iMac10,1 | 10.6 | 10.7 | 10.8 | 10.9 | 10.10 | 10.11 | 10.12 | 10.13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# csv2csv.function.min.no_help | |
# csv2csv by Lorance Stinson, 2007 | |
# This file is in the public domain. | |
# For more information email LoranceStinson+csv@gmail.com. | |
# Or see http://lorance.freeshell.org/csvutils/ | |
# Additions by Joel Bruner, 2020 (https://github.com/brunerd) | |
#csv2csv function minified | |
function csv2csv { IFS=$' \t\n'; local NL=$'\n'; local TAB=$'\t';local CSV_ESCAPE=${CSV_ESCAPE:='"'}; local CSV_SEPARATOR=${CSV_SEPARATOR:=","}; local CSV_QUOTE=${CSV_QUOTE:='"'}; local OCSV_ESCAPE=${CSV_ESCAPE:='"'}; local OCSV_SEPARATOR=${CSV_SEPARATOR:=","}; local OCSV_QUOTE=${CSV_QUOTE:='"'}; local FILE="-"; local NL_TEXT=""; local NUM_COLS=""; local OUTPUT=""; local QUOTE_LEVEL="0"; local SKIP_ROWS="0"; local TAB_TEXT=""; while [ "$#" -gt 0 ] ; do case "$1" in -c) [ "$2" ] && local COL_LIST="$2" || usage="$1 requires an argument."; shift 2;; -e) [ "$2" ] && CSV_ESCAPE="$2" || usage="$1 requires an argument."; shift 2;; -E) [ "$2" ] && OCSV_ESCAPE="$2" || usage="$1 requires an argument."; shift 2;; -h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# csv2csv.function.min | |
# csv2csv by Lorance Stinson, 2007 | |
# This file is in the public domain. | |
# For more information email LoranceStinson+csv@gmail.com. | |
# Or see http://lorance.freeshell.org/csvutils/ | |
# Additions by Joel Bruner, 2020 (https://github.com/brunerd) | |
#csv2csv function minified | |
function csv2csv { IFS=$' \t\n'; local NL=$'\n'; local TAB=$'\t';local CSV_ESCAPE=${CSV_ESCAPE:='"'}; local CSV_SEPARATOR=${CSV_SEPARATOR:=","}; local CSV_QUOTE=${CSV_QUOTE:='"'}; local OCSV_ESCAPE=${CSV_ESCAPE:='"'}; local OCSV_SEPARATOR=${CSV_SEPARATOR:=","}; local OCSV_QUOTE=${CSV_QUOTE:='"'}; local FILE="-"; local NL_TEXT=""; local NUM_COLS=""; local OUTPUT=""; local QUOTE_LEVEL="0"; local SKIP_ROWS="0"; local TAB_TEXT=""; while [ "$#" -gt 0 ] ; do case "$1" in -c) [ "$2" ] && local COL_LIST="$2" || usage="$1 requires an argument."; shift 2;; -e) [ "$2" ] && CSV_ESCAPE="$2" || usage="$1 requires an argument."; shift 2;; -E) [ "$2" ] && OCSV_ESCAPE="$2" || usage="$1 requires an argument."; shift 2;; -h) usage= |
NewerOlder