Skip to content

Instantly share code, notes, and snippets.

View grahampugh's full-sized avatar

Graham Pugh grahampugh

View GitHub Profile
@grahampugh
grahampugh / msc-do.not-disturb.scpt
Last active July 17, 2016 03:42
munki-notification-suppressor application
(*
=========================================================
MSC-Do-Not-Disturb
A program to stop Munki update notifications for 24 hours
=========================================================
This version assumes you have MunkiReport-PHP installed. MunkiReport-PHP sets up
a /usr/local/munki/preflight file which calls any script in /usr/local/munki/preflight.d/
You can change pythonFilePath to /usr/local/munki/preflight if you don't have any other
preflight scripts, or you may need to adapt it to fit with your other preflight scripts.
=========================================================
@grahampugh
grahampugh / part of msc-do-not-disturb-1.0.plist
Last active August 29, 2015 14:24
Uninstall method for MSC Do Not Disturb
<key>uninstall_method</key>
<string>uninstall_script</string>
<key>uninstall_script</key>
<string>#!/bin/sh
/bin/rm -rf "/Applications/Managed Software Center Do Not Disturb.app" \
/usr/local/munki/preflight.d/msc-do-not-disturb.py
/usr/bin/defaults write /Library/Preferences/ManagedInstalls.plist SuppressUserNotification -bool FALSE
/usr/sbin/pkgutil --forget uk.ac.bris.MSC-Do-Not-Disturb</string>
<key>uninstallable</key>
<true/>
@grahampugh
grahampugh / printer-template.sh
Last active November 25, 2019 04:35
SMB Printer Install Script Template
#!/bin/bash
### Variables. Edit these.
printername="Choose-A-Printer-Name-with-no-spaces"
location="Choose a location"
gui_display_name="Choose a descriptive printer name"
address="smb://server/printqueue"
# leave this empty if you wish to use the generic PS PPD print driver
# or make sure the file exists in the ../drivers directory
#!/bin/bash
### ACTIVE DIRECTORY USER PERMISSIONS SCRIPT ###
### by Graham Pugh
### Props to Jeff Kelley, Graham Gilbert and various others for elements of script
### This script looks at the "Allow Administration By" field of the
### `dsconfigad -show` command and checks each of the Active Directory users
### with mobile accounts on the computer to check whether they should have
### local admin rights. It amends each user's membership of the local
@grahampugh
grahampugh / mail_profile.mobileconfig
Last active November 25, 2017 10:31
E-Mail IMAP configuration profile and outset script. Takes the long user name of the logged in user to populate the email field. User must supply only the password.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadIdentifier</key>
<string>
com.apple.mdm.server1.local.%first_uuid%.alacarte</string>
<key>PayloadRemovalDisallowed</key>
<false />
@grahampugh
grahampugh / archive-imap-email.py
Created September 18, 2016 17:46
Archive IMAP E-Mail to local computer
#!/usr/bin/env python
#
# Based on https://gist.github.com/robulouski/7442321
# Extended using code from https://ubuntuforums.org/showthread.php?t=993184
#
# A Python script to dump all emails from each IMAP folder in an account
# to files.
#
# Mail from each IMAP folder is outputted into a sub-folder of the same name.
#
@grahampugh
grahampugh / replaceslashes.sh
Created October 18, 2016 08:25
Replace slashes with underscores in folder- and filenames in a directory
#!/bin/bash
# change the folder to affect which subfolder / files have slashes replaced by underscores
# note that in UNIX, slashes are represented as colons
find "/path/to/folder" -depth -name \*:\* \
-execdir bash -c 'mv "$1" "${1//:/_}"' _ {} \;
@grahampugh
grahampugh / remove_old_lync.sh
Last active October 19, 2016 08:27
Removes Microsoft Lync and previous preview versions of Skype for Business, prior to installing the latest version
#!/bin/sh
# script written by Dave Fisher (fishd)
# Get the current logged in user
USERNAME=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
killall "Microsoft Lync"
killall "Skype for Business"
@grahampugh
grahampugh / com.github.ygini.hello-it.sleep.sh
Created October 19, 2016 10:24
Hello-IT CustomScript for a Lock Screen menu item
#!/bin/bash
# To perform a sleep action
# Requires "password after sleep or screen saver begins" to be set in Security preferences
. "$HELLO_IT_SCRIPT_FOLDER/com.github.ygini.hello-it.scriptlib.sh"
function goToSleep {
osascript -e 'tell application "Finder" to sleep'
title="Lock Screen"
@grahampugh
grahampugh / make_icns.zsh
Last active January 4, 2017 12:37
Create iconset from a PNG
#!/bin/zsh
## Makes an icon set from a PNG. A 512x512 or 1024X1024 PNG is best.
## Taken from http://stackoverflow.com/a/31150333
## Usage: ./make_icns.zsh </path/to/image.png>
NAME=$(basename $1 .png); DIR="$NAME.iconset"
mkdir -pv $DIR
for m r in 'n' '' '((n+1))' '@2x'; do
for n in $(seq 4 9 | grep -v 6); do