Skip to content

Instantly share code, notes, and snippets.

@krispayne
krispayne / ToggleWiFi.md
Last active July 25, 2016 17:19 — forked from markaltmann/Toggle WiFi
Automatically disable Wifi when an Ethernet connection (cable) is plugged in on a Mac.

Overview

This is a bash script that will automatically turn your wifi off if you connect your computer to an ethernet connection and turn wifi back on when you unplug your ethernet cable/adapter. If you decide to turn wifi on for whatever reason, it will remember that choice. This was improvised from this mac hint to work with Yosemite, and without hard-coding the adapter names. It's supposed to support growl, but I didn't check that part. I did, however, add OSX notification center support. Feel free to fork and fix any issues you encounter.

Most the credit for these changes go to Dave Holland and Albert Bori

Requirements

  • Mac OSX 10+
  • Administrator privileges
#!/bin/bash
# Displays a dialog for the user prompting them to restart after a software update
# Variables
# CocoaDialog location
CD="/Applications/Utilities/cocoaDialog.app/Contents/MacOS/CocoaDialog"
# Get the logged in user
loggedInUser=$(ls -l /dev/console|cut -d' ' -f4)
#!/bin/bash
# Unlock that account, you sly computer
# Path to CocoaDialog
CD="/Applications/Utilities/cocoaDialog.app/Contents/MacOS/cocoaDialog"
# Quick sanity check to make sure cocoaDialog is installed in the path specified
if [ ! -e "$CD" ]; then
echo "cocoaDialog was not found in the path specified. It may not be installed, or the path is wrong. Exiting..."
exit 1
#!/bin/bash
# Extension attribute to find if bad network is on device
# Modified from:
# Lauren Caliolio 8/22/2014
# Contact me: laurendc@gmail.com, twitter @laurendc or JAMFNation: laurendc
# Wireless network to hunt
HUNT="old-public-ssid"
# Find device on hardware irregardless of model
#!/bin/bash
# check for a printer driver
# utilizes Casper parameters
PRINTER_DRIVER="${4}"
TRIGGER="${5}"
BASEPPD="/Library/Printers/PPDs/Contents/Resources"
if [[ ! -e "${BASEPPD}/${PRINTER_DRIVER}" ]]; then
echo "Installing driver from Casper..."
#!/bin/bash
# Mount a network time machine sparsebunble who's claimed to have gotten corrupt and no longer backs up.
# I do this from a different mac than the one doing the backups.
if [[ $(whoami) != 'root' ]]; then
echo "Must be run as root, dude."
exit 1
fi
read -p 'Enter path of TimeMachine Server (i.e. 123.45.6.7/TimeMachine): ' TM_PATH

to enable: sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -users ADMIN_USER_HERE -privs -all -restart -agent -menu

to disable: sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -deactivate -configure -access -off

@krispayne
krispayne / addPrinter-hp.sh
Last active April 26, 2017 10:19
Bash script to deploy printer via JAMF Casper
#!/bin/bash
# Original: https://jamfnation.jamfsoftware.com/discussion.html?id=14467
# Useful script for deploying printers in a Casper Environment
# Originally by Lwindram on JAMF Nation forums
# https://jamfnation.jamfsoftware.com/viewProfile.html?userID=11026
# Edited to use JSS Script Parameters to make the script portable to all Models. Define $vars in JSS Policy.
## Translations
# man lpadmin
@krispayne
krispayne / bring_the_payne.py
Last active May 4, 2017 21:13 — forked from sheagcraig/bring_the_payne.py
Get IP Address for all computers in the JSS
#!/usr/bin/env python
"""https://twitter.com/krispayne/status/859833552078225408:
@shea_craig is possible with python-jss to generate a list of IP addresses for
computers in the JSS?
"""
from operator import itemgetter
# This example uses python-jss 2.0.0+
@krispayne
krispayne / get_printer_driver_version.sh
Last active May 9, 2017 23:17
Extension attribute to determine the installed printer driver version for a given Xerox printer model.
#!/bin/bash
# Determine the printer driver version using lpinfo
# I got the printer information by running:
# [kris@Kris-MacBook-Pro ~]$ lpinfo --make-and-model "7225" -m
# Library/Printers/PPDs/Contents/Resources/Xerox WorkCentre 7225.gz Xerox WorkCentre 7225, 3.123.0
# [kris@Kris-MacBook-Pro ~]$
#
# for an HP I have I used:
# [kris@Kris-MacBook-Pro ~]$ lpinfo --make-and-model "hp laserjet p4010" -m