Skip to content

Instantly share code, notes, and snippets.

@acidprime
acidprime / labadd.scpt
Created January 9, 2012 01:54
Apple Script to help New Admins add computer to OD groups
-- Values that are site specific
property labAdmin : "labadmin"
-- Commands used by this script
property awk : "/usr/bin/awk"
property dscl : "/usr/bin/dscl"
property idcmd : "/usr/bin/id"
property scutil : "/usr/sbin/scutil"
property ping : "/sbin/ping"
property ifconfig : "/sbin/ifconfig"
@acidprime
acidprime / afpsync.sh
Created January 9, 2012 01:55
AFP Rsync Migration Example
#!/bin/bash
# set -xv
export BUILDVERSION="2009051"
# Email settings for the sendEmailNow Function
export EMAIL_SERVER="172.16.15.27"
export EMAIL_TO="[email protected]"
export EMAIL_FROM="`/bin/hostname`@example.com"
# User Configuration
@acidprime
acidprime / mountexample.sh
Created January 9, 2012 01:57
Mount AFP Shares to Test Authentication Example
#!/bin/bash
# Required commands
declare -x awk="/usr/bin/awk"
declare -x dscl="/usr/bin/dscl"
declare -x defaults="/usr/bin/defaults"
declare -x du="/usr/bin/du"
declare -x id="/usr/bin/id"
declare -x ntpdate="ntpdate"
declare -x scutil="/usr/sbin/scutil"
declare -x perl="/usr/bin/perl"
@acidprime
acidprime / adtimeout.sh
Created January 9, 2012 01:58
Set AD Timeout on Laptops
#!/bin/bash
# Configure the value here for the timeout value
declare -xi AD_TIME_OUT_VALUE="10"
declare -x defaults="/usr/bin/defaults"
declare -x plutil="/usr/bin/plutil"
[ "$EUID" != 0 ] &&
printf "%s\n" "This script requires root access! (try sudo \"$0\")" && exit 1
# See how this function is used in script code below
@acidprime
acidprime / createstructure.sh
Created January 9, 2012 01:59
Create Folder Structure Example
#!/bin/bash
declare -xi IS_DS="`hostname | grep -o ds01 -c`"
# FS Config
setupFSPromise(){
IFS=" "
declare -x VOL_NAME="Storage"
declare -x DRIVE_SIZE="1.9T"
diskutil partitionDisk "$BSD_DISK" 1 APM HFS+ "$VOL_NAME" "$DRIVE_SIZE"
if [ -d "/Volumes/$VOL_NAME" ] ; then
mkdir -p "/Volumes/$VOL_NAME/APPS"
@acidprime
acidprime / tracklogin.sh
Created January 9, 2012 02:00
Track Login Time to Hidden Windows Share
#!/bin/bash
declare -x USER_NAME="$1"
# Commands
declare -x awk="/usr/bin/awk"
declare -x date="/bin/date"
declare -x ping="/sbin/ping"
declare -x scutil="/usr/sbin/scutil"
declare -x sed="/usr/bin/sed"
declare -x grep="/usr/bin/grep"
declare -x netstat="/usr/sbin/netstat"
@acidprime
acidprime / testADuser.scpt
Created January 9, 2012 02:01
Apple Script to Test AD User Auth for silly Level 1 Help Desk folks
(* A Script written to assist with Narrowing down User Authentication Issues *)
property idcmd : "/usr/bin/id"
property theDirNode : (quoted form of "/Active Directory/All Domains")
property theDirNodeSuffix : "All Domains"
property userNameResult : "User Lookup Failure"
global userName
on promptForUserName()
-- Prompt for username
set askForUserName to display dialog "Please enter the username in: " & return & space & theDirNode & return & space & "to test authentication with:" buttons {"Cancel", "Continue"} default button "Continue" default answer "adusername" with icon 1
@acidprime
acidprime / checkUIDs.sh
Created January 9, 2012 02:05
Check UIDs against Remote Server
#!/bin/bash
#set -xv
declare -x DIRECTORY_ADMIN="diradmin"
declare -x DIRECTORY_PASS="foobar"
declare -x REMOTE_LDAP_SERVER="server.example.com"
declare -x REMOTE_SEARCH_BASE="dc=server,dc=example,dc=com"
[ "$EUID" != 0 ] &&
printf "%s\n" "This script requires root access!" && exit 1
@acidprime
acidprime / odmigrate.sh
Created January 9, 2012 02:08
10.6 OD to OD migration script
#!/bin/bash
# BEGIN Configuration Options:
declare -x BUILD_VERSION="20110608"
declare -x DIRADMIN_UID="1000"
# The following should not contain the users or groups container
# The NEW Open Directory Master information
declare -x DIRADMIN_IMPORT="diradmin"
declare -x DIRADMIN_PASS_IMPORT='foo'
declare -x SEARCH_BASE_IMPORT="dc=new,dc=example,dc=com"
declare -x SERVER_HOSTNAME_IMPORT="new.server.example.com"
@acidprime
acidprime / checkdefaultpassword.sh
Created January 9, 2012 02:09
Check Default Passwords
#!/bin/bash
for USER_NAME in `dscl /LDAPv3/127.0.0.1 -list /Users` ; do
if dscl /Search -authonly "$USER_NAME" 'defaultpass' &>/dev/null ; then
echo "Found user $USER_NAME with default password"
fi
done