Skip to content

Instantly share code, notes, and snippets.

View jacobsalmela's full-sized avatar
:octocat:
To all that makes us unique

Jacob Salmela jacobsalmela

:octocat:
To all that makes us unique
View GitHub Profile
@jacobsalmela
jacobsalmela / .profile
Last active August 29, 2015 14:01
single-user-mode-ids
#!/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 / single-user-mode-ids-geeklet
Last active August 29, 2015 14:01
Sounds a klaxon whenever a computer on the network boots to single-user mode.
#!/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 / ssh-in-single-user-mode.sh
Created May 13, 2014 17:51
Enables outbound SSH in Single-user Mode on OS X
#!/bin/bash
# https://github.com/jacobsalmela
# Enables outbound SSH in single-user mode on OS X
# Save this file as /var/root/.profile and boot into single-user mode
# Last tested on 10.9.2
#----------VARIABLES---------
# Manually set ethernet device ID
@jacobsalmela
jacobsalmela / partition-disk.sh
Created June 1, 2014 16:05
Partitions the disk for putting /Users on a separate partition
#!/bin/bash
#----------VARIABLES---------
echo "Checking hard disk ID..."
hardDiskID=$(diskutil list | awk '/GUID_partition_scheme/ {print $5}')
#----------------------------
#-----------SCRIPT-----------
#----------------------------
echo "Checking if Users partition exists..."
@jacobsalmela
jacobsalmela / create-fstab-change-icon.sh
Created June 1, 2014 16:13
Modifies /etc/fstab to mount /Users to the right partition and also creates the /Users/Shared folder
#!/bin/bash
#----------VARIABLES---------
usersUUID=$(diskutil info Users\ HD | grep Volume\ UUID: | awk '{print $3}')
# usershHD=$(diskutil list | grep Users | awk '{print $6}')
# macintoshHD=$(diskutil list | grep "Macintosh HD" | grep -v "Macintosh HD 1" | awk '{print $7}')
#----------FUNCTIONS---------
#####################
function createFstab()
@jacobsalmela
jacobsalmela / change-users-icon.sh
Last active August 20, 2022 13:56
Changes the /Users folder icon when it is on a separate partition
#!/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 / smasp.sh
Created June 1, 2014 20:12
Saves Mac App Store packages if they are paused before finished downloading.
#!/bin/bash
appStoreFolder=$(sudo find /private/var/folders -type f -name "*.pkg")
i=0
for package in $appStoreFolder
do
# Make a hard link of the package in the Downloads folder
sudo ln $package ~/Downloads/_MAS_$i.pkg
# Increment by one in case there are more .pkgs to save
@jacobsalmela
jacobsalmela / gravity.sh
Created June 8, 2014 15:07
Pi-hole: Pulls List of Ad Servers Into the event horizio
#!/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 / os-x-login-user-to-gui-via-script.sh
Created June 11, 2014 19:10
(OS X) Enters a user's credentials into the GUI login window fields and logs them in (access to assistive devices needs to be enabled for osascript to work)
osascript -e <<EOF 'tell application "System Events"
tell process "SecurityAgent"
set value of text field 2 of window "Login" to "username"
set value of text field 1 of window "Login" to "password"
end tell
tell application "system events" to keystroke return
tell application "system events" to keystroke return
end tell'
EOF
@jacobsalmela
jacobsalmela / set-wallpaper-universal.py
Last active August 29, 2015 14:03 — forked from gregneagle/gist:6957826
(OS X) Universal script for setting the wallpaper. Works on 10.6-10.9
#!/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"