Skip to content

Instantly share code, notes, and snippets.

View grahampugh's full-sized avatar

Graham Pugh grahampugh

View GitHub Profile
@grahampugh
grahampugh / manifest-find.sh
Last active August 29, 2015 14:19
Munki Manifest Find
#!/bin/bash
### A script to find which manifests contain references to a package or other manifest via included_manifests
### Your Munki repository must be mounted as a volume
### Syntax:
### $ ./manifest-find.sh -f <package or manifest name>
### Examples:
### $ ./manifest-find.sh -f Xcode
### $ ./manifest-find.sh -f _regular_users
@grahampugh
grahampugh / enroll.php
Last active August 29, 2015 14:23
Variant of munki-enroll's enrol.php script to allow leveraging of DeployStudio's Computer Information Fields to influence Munki Included Manifests
<?php
require_once( 'cfpropertylist-1.1.2/CFPropertyList.php' );
// Default catalog
$catalog = 'standard';
// Get the varibles passed by the enroll script
$identifier1 = $_POST["identifier1"];
$identifier2 = $_POST["identifier2"];
@grahampugh
grahampugh / matlab-mable-ubuntu14.sh
Last active August 29, 2015 14:23
Installs Matlab and Maple from packages.bris.ac.uk to UoB Ubuntu 14.04 LTS desktops. Will only work within the University.
#!/bin/bash
# uncomment these to force a reinstall
# dpkg -r opt-maple-18 opt-maple-18-modules
# rm -rf /opt/matlab-R2014a
# matlab
if [ ! -f /opt/matlab-R2014a/bin/matlab ]; then
wget -O /opt-matlab-R2014a--plus-module.tar.bz2 http://packages.bris.ac.uk/unpackaged/zone_d/opt-matlab-R2014a--plus-module.tar.bz2
tar xvjf /opt-matlab-R2014a--plus-module.tar.bz2 -C /
#!/bin/sh
SCRIPT_NAME=`basename "${0}"`
SCRIPT_PATH=`dirname "${0}"`
echo "${SCRIPT_NAME} - v1.0 ("`date`")"
if [ ${#} -ne 1 ]
then
echo "Command: ${SCRIPT_NAME} ${*}"
@grahampugh
grahampugh / postinstall
Last active August 29, 2015 14:23
Munki installer postinstall - checks against CSV
#!/bin/bash
# This postinstall script runs all the scripts that the package placed into the target
# Library, and then deletes the folder that was previously created to remove the cruft
log() {
echo "${@}" 2>&1
logger -t Munki installer "${@}"
}
@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 / 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 / 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"