Skip to content

Instantly share code, notes, and snippets.

@opragel
opragel / enable_ard_access_for_one_user.sh
Created March 30, 2016 08:47
enable_ard_access_for_one_user.sh
#!/bin/bash
LOCAL_ADMIN_USERNAME="ladmin"
ARD_KICKSTART_PATH="/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart"
if [ -e "$ARD_KICKSTART_PATH" ]; then
"$ARD_KICKSTART_PATH" -configure -allowAccessFor -specifiedUsers
"$ARD_KICKSTART_PATH" -activate -configure -access -on -users "$LOCAL_ADMIN_USERNAME" -privs -all -restart -agent
else
printf "Error: ARD kickstart process inaccessible or not found at path"
@opragel
opragel / add_vpn_to_menu_and_enable_show_time.sh
Created March 28, 2016 04:42
add_vpn_to_menu_and_enable_show_time.sh
#!/bin/bash
# Script adds the VPN item to the menu bar and enables the 'show time
# connected' & 'show status while connecting' options. Last tested on 10.11
currentUser=$(python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')
currentUserHomeDirectory=$(dscl . -read "/users/$currentUser" NFSHomeDirectory | cut -d " " -f 2)
vpnMenuItemExists=$(defaults read "$currentUserHomeDirectory/Library/Preferences/com.apple.systemuiserver" menuExtras | grep -o VPN)
if [ "$vpnMenuItemExists" ]; then
printf "VPN menu item is already on the status bar!"
@opragel
opragel / dear_god_dont_use_this.sh
Created March 25, 2016 22:12
dear_god_dont_use_this.sh
#!/bin/bash
LAUNCH_AGENT_PATH="/Library/LaunchAgents/com.pritunl.client.plist"
currentUser=$(python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')
currentUserPID=$(pgrep WindowServer -m1)
currentUserUID=$(id -u "$currentUser")
osvers=$(sw_vers -productVersion | awk -F. '{print $2}')
if [[ $EUID -ne 0 ]]; then
@opragel
opragel / run_launchagent_as_user.sh
Last active April 5, 2016 18:48
Script to run LaunchAgent as the logged-in user from a script run with root privileges
#!/bin/bash
LAUNCH_AGENT_PATH="/Library/LaunchAgents/com.pritunl.client.plist"
currentUser=$(python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')
currentUserPID=$(pgrep WindowServer -m1)
currentUserUID=$(id -u "$currentUser")
osvers=$(sw_vers -productVersion | awk -F. '{print $2}')
if [[ $EUID -ne 0 ]]; then
@opragel
opragel / ea_microsoft_outlook2016_versioncheck.py
Last active November 8, 2016 03:16
ea_microsoft_outlook2016_versioncheck.py
#!/usr/bin/python
"""
This script checks whether the installed version of Microsoft Outlook 2016 is
equal, less, or more than the target version defined by APP_TARGET_VERSION
and reports the result in Casper Suite extension attribute style.
T = Local app version is equal to provided target version
N = Local app version is newer than provided target version
F = Local app version is less than provided target version
N/A = Local app plist was not found or accesible at specified path
"""
@opragel
opragel / get_ringcentral_status.py
Last active March 21, 2016 01:32
get_ringcentral_status.py
#!/usr/bin/python
import requests
import json
# Username = phone number you use for RC
# Example: 555-123-5555 becomes 15551235555
RC_USERNAME = "YOUR_RC_USERNAME"
RC_PASSWORD = "YOUR_RC_PASSWORD"
# Leave extension blank if you don't use one
@opragel
opragel / get_ringcentral_status.sh
Created March 20, 2016 23:44
get_ringcentral_status.sh
#!/bin/bash
# Username = phone number you use for RC
# Example: 555-123-5555 becomes 15551235555
RC_USERNAME="YOUR_RC_USERNAME"
RC_PASSWORD="YOUR_RC_PASSWORD"
# Leave extension blank if you don't use one
RC_EXTENSION=""
rcStatusResult=$(curl 'https://servicestatus.ringcentral.com/services/PODHealth?RCPlStep=login' \
@opragel
opragel / set_stencylworks_globalworkdir_sh.sh
Created March 19, 2016 02:58
set_stencylworks_globalworkdir_sh.sh
#!/bin/bash
currentUser=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')
currentUserHomeDirectory=$(dscl . -read "/users/$currentUser" NFSHomeDirectory | cut -d " " -f 2)
if [ -f "$currentUserHomeDirectory/StencylWorks.prefs" ]; then
sed -i "" -e "/global.workdir=/d" "$currentUserHomeDirectory/StencylWorks.prefs"
fi
printf "global.workdir=%s" "$currentUserHomeDirectory" >> "$currentUserHomeDirectory/StencylWorks.prefs"
@opragel
opragel / ea_get_chrome_extensions.py
Last active January 11, 2018 22:38
ea_get_chrome_extensions.py
#!/usr/bin/python
## Script: get_chrome_extensions.py
## Author: Christopher Collins ([email protected])
# also, owen wuz here. minor corrections (utf-8)
###########################################
##Description: This script searches the last logged in user's installed extensions and submits it to Casper during an inventory report.
###########################################
import os
@opragel
opragel / cycle-iperf3
Created March 12, 2016 21:21
cycle-iperf3
#!/bin/bash
# This script runs iperf3 multiple times, storing the results in a csv file
# Then, it uses gnuplot to create a chart illustrating the results
#
# V Who When What
# ---------------------------------------------------------------------------
# 2.0.0? opragel 2016-03-13
# 1.5.2 skendric 2014-11-22 Remove -o output option
# 1.5.1 asundstr 2014-11-04 Use double-quotes with sed
# 1.5.0 skendric 2014-10-25 Add Chart Title to CLI options