Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
To all that makes us unique

Jacob Salmela jacobsalmela

:octocat:
To all that makes us unique
View GitHub Profile
@jacobsalmela
jacobsalmela / single-user-mode-ids-geeklet
Last active Aug 29, 2015
Sounds a klaxon whenever a computer on the network boots to single-user mode.
View single-user-mode-ids-geeklet
#!/bin/bash
# Pings the IP address that any computer gets when booted to Single-User Mode
# Works best to set it to ping every 2 seconds (set refresh rate in Geektool)
ping -c 1 10.x.x.x &> /dev/null
# If that address is pingable,
if [ $? = 0 ];then
# Sound the "red alert" klaxon for speakers connected to this computer
afplay /Users/Shared/klaxon.mp3
@jacobsalmela
jacobsalmela / .profile
Last active Aug 29, 2015
single-user-mode-ids
View .profile
#!/bin/bash
#----------VARIABLES---------
# Manually set ethernet device ID
ethernetID="en0"
# Put static IPv4 with subnet mask here
ethernetIP="10.x.x.x 255.x.x.x"
# Organization name (reverse-domain plist format)
orgName="org.enterprise.casper"
@jacobsalmela
jacobsalmela / change-users-icon.sh
Last active Aug 29, 2015
Changes the /Users folder icon when it is on a separate partition
View change-users-icon.sh
#!/bin/bash
#An icon file needs to exist in /usr/local/imaging
# Copy the users.icns file to the root of the the Users folder.
# Since it is a volume, if you name the file .VolumeIcon.icns, it will change the icon from the default hard drisk
# This is mostly to help the end users so they feel like it is a folder and not a hard drive
# The icon should also have a small badge to let the tech staff know that it is not a normal folder and that the workflow was successful
cp /usr/local/imaging/users.icns /Users/.VolumeIcon.icns
@jacobsalmela
jacobsalmela / gravity.sh
Created Jun 8, 2014
Pi-hole: Pulls List of Ad Servers Into the event horizio
View gravity.sh
#!/bin/bash
# URL to pull list of known ad servers from
adListURL="http://pgl.yoyo.org/adservers/serverlist.php?hostformat=dnsmasq&showintro=0&mimetype=plaintext"
# Address to send ads to
piholeIP="127.0.0.1"
# Where the list of ad servers are stored once downloaded
# Any file in /etc/dnsmasq.d is loaded automatically when the service starts
@jacobsalmela
jacobsalmela / set-wallpaper-universal.py
Last active Aug 29, 2015 — forked from gregneagle/gist:6957826
(OS X) Universal script for setting the wallpaper. Works on 10.6-10.9
View set-wallpaper-universal.py
#!/usr/bin/python
# Universal wallpaper script for 10.6 and up
from AppKit import NSWorkspace, NSScreen
from Foundation import NSURL
from platform import mac_ver
from subprocess import call
from os import system
# Set path here for 10.9
picture_path = "/Library/Desktop Pictures/Custom.jpg"
@jacobsalmela
jacobsalmela / fixMultipleRecoveryHDs.sh
Created Jul 11, 2014
(OS X) Merges multiple Recovery HDs back into Macintosh HD (JAMF Casper Suite Defect D-007146)
View fixMultipleRecoveryHDs.sh
#!/bin/bash
# Jacob Salmela
# 2014-07-11
# Fix multiple Recovery HDs created by Casper Imaging from Defect D-007146
# Get last extra Recovery HD by parsing out the bootable Recovery HD, leaving only the extra partitions
lastExtraRecovery=$(diskutil list | awk "/Recovery HD/" | grep -v "Apple_Boot" | awk '{print $7}' | tail -n1)
# Get Macintosh disk ID
systemVolume=$(diskutil list | awk "/Macintosh HD/" | grep -v "Apple_Boot" | awk '{print $7}')
@jacobsalmela
jacobsalmela / EA-MacintoshHD.sh
Created Aug 6, 2014
Extension Attribute to check if the root volume is named Macintosh HD
View EA-MacintoshHD.sh
#!/bin/bash
volumeName=$(diskutil info / | awk '/Volume Name/ {print substr ($0, index ($0,$3))}')
if [ "$volumeName" != "Macintosh HD" ];then
echo "<result>Incorrect</result>"
else
echo "<result>Correct</result>"
fi
View script-performance-test.sh
#!/bin/bash
#----------AUTHOR------------
# Jacob Salmela
# 27 March 2014
# https://github.com/jakesalmela/
#---------DESCRIPTION--------
# Tests the performance of a script
#-----------USAGE------------
@jacobsalmela
jacobsalmela / speak-copy-serial.sh
Created Aug 12, 2014
(OS X) Speak and copy the serial number
View speak-copy-serial.sh
#!/bin/bash
#----------AUTHOR------------
# Jacob Salmela
# 3 December 2013
#----------RESOURCES---------
# http://stackoverflow.com/questions/12230762/insert-characters-into-a-string-in-bash
#---------DESCRIPTION--------
# Copies the computers serial number into the clipboard and then speaks it aloud so you can write it down
@jacobsalmela
jacobsalmela / ssh-histmon.sh
Created Aug 12, 2014
Real-time SSH history monitor
View ssh-histmon.sh
#!/bin/bash
#----------AUTHOR------------
# Jacob Salmela
# 15 November 2013
# https://github.com/jakesalmela/
#----------RESOURCES---------
# http://askubuntu.com/questions/80371/bash-history-handling-with-multiple-terminals
# http://www.csgnetwork.com/epochtime.html