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 | |
# This section uses python to get the current console user. You can | |
# usually just use the built-in $USER variable, but this is more | |
# robust. | |
USER=$(/usr/bin/python -c \ | |
'from SystemConfiguration import SCDynamicStoreCopyConsoleUser;\ | |
print SCDynamicStoreCopyConsoleUser(None, None, None)[0]') | |
# This looks up the password expiration date from AD. It's stored |
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
tell application "System Events" | |
tell appearance preferences to set dark mode to not dark mode | |
keystroke "d" using {command down, option down, control down, shift down} | |
end tell | |
set curVolume to get volume settings | |
if output muted of curVolume is false then | |
set volume with output muted | |
else | |
set volume without output muted |
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 | |
# set the input for lazy convenience | |
IFS=$' ' | |
localadmins=$(/usr/bin/dscl localhost -read /Local/Default/Groups/admin GroupMembership | awk -F': ' '{print $2}') | |
for account in `echo $localadmins`; do | |
# add additional blocks like >> && ! [ "$account" == "username" ] << for additional exclusions | |
if ! [ "$account" == "root" ] && ! [ "$account" == "itstech" ]; 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 | |
myLDAP=$(scutil --dns | awk '/nameserver\[0\]/{print $3}' | head -1) | |
mySearchBase=$(ldapsearch -LLL -Q -s base -H ldap://${myLDAP} defaultNamingContext | awk '/defaultNamingContext/{print $2}') | |
uAC=$(dscl localhost read /Search/Users/$USER userAccountControl | awk '/:userAccountControl:/{print $2}') | |
if [[ $uAC =~ ^6 ]]; then | |
passExpires="no" | |
else |
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 | |
for log in $(/bin/ls -r /var/log/install.log*); do | |
bzgrep 'Writing receipt' $log | awk '{print $1,$2,$3,$10}' | |
done |
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
#!/usr/bin/env python | |
# | |
# Pass any number of short hostnames to run cmd on all | |
# hosts in parallel and display the results nicely. | |
import sys | |
import subprocess | |
import multiprocessing | |
PROCESSES = 8 |
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
try | |
-- test for Kerberos ticket presence and attempt to renew | |
do shell script "/usr/bin/klist | /usr/bin/grep krbtgt" | |
do shell script "/usr/bin/kinit -R" | |
on error | |
-- offer to renew Kerberos ticket | |
set response to (display dialog "No Kerberos ticket was found. Do you want to renew it?" with icon 2 buttons {"No", "Yes"} default button "Yes") | |
if button returned of response is "Yes" then | |
try | |
set thePassword to text returned of (display dialog "Enter your password:" default answer "" with hidden answer) |
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
#!/usr/bin/env python | |
from re import findall | |
from subprocess import check_output | |
def getOrderedInterfaces(): | |
"""Returns all ethernet interfaces in service order.""" | |
interfaces = check_output(['networksetup', '-listnetworkserviceorder']) | |
matches = findall(r' en[\d]+', interfaces) | |
return [ i.lstrip(' ') for i in matches ] |
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
on open location this_URL | |
-- passed paths should be "finder://[/path/to/directory] | |
-- spaces in path names should be replaced with a url-friendly '%20' | |
set x to the offset of ":" in this_URL | |
set passed_path to text from (x + 3) to -1 of this_URL | |
set my_path to do shell script "echo \"" & passed_path & "\" | awk '{gsub(\"%20\",\"\\\\ \"); print}'" | |
do shell script "open " & my_path | |
end open location |
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
on open location this_URL | |
-- passed urls should be "syspref://[PaneName] | |
-- or "syspref://[Pane_Name]" -- no spaces | |
set x to the offset of ":" in this_URL | |
set sp to text from (x + 3) to -1 of this_URL | |
set pane to do shell script "echo \"" & sp & "\" | awk '{gsub(\"_\",\"\\\\ \"); print}'" | |
set h to path to home folder | |
set home to POSIX path of h | |
set path_heads to {"/System/", "/", home} | |
set pref_pane to text from (x + 3) to -1 of this_URL |
NewerOlder