Skip to content

Instantly share code, notes, and snippets.

:atom:
Thinking

Jacob Salmela jacobsalmela

:atom:
Thinking
Block or report user

Report or block jacobsalmela

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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 / 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 / ssh-in-single-user-mode.sh
Created May 13, 2014
Enables outbound SSH in Single-user Mode on OS X
View ssh-in-single-user-mode.sh
#!/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 Jun 1, 2014
Partitions the disk for putting /Users on a separate partition
View partition-disk.sh
#!/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 Jun 1, 2014
Modifies /etc/fstab to mount /Users to the right partition and also creates the /Users/Shared folder
View create-fstab-change-icon.sh
#!/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 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 / smasp.sh
Created Jun 1, 2014
Saves Mac App Store packages if they are paused before finished downloading.
View smasp.sh
#!/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 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 / os-x-login-user-to-gui-via-script.sh
Created Jun 11, 2014
(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)
View os-x-login-user-to-gui-via-script.sh
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 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"
You can’t perform that action at this time.