Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
args=("$@")
jssAPIUsername=''
jssAPIPassword=''
jssAddress=""
file="${args[0]}"
#Verify we can read the file
data=`cat $file`
if [[ "$data" == "" ]]; then
@stevewood-tx
stevewood-tx / gist:fa638783ff6f751ebbddfc54c5708e81
Created August 9, 2022 19:42
Secure Token Users Extension Attribute
#!/bin/bash
# originally written by @franton
osvers_major=$(/usr/bin/sw_vers -productVersion | awk -F. '{print $1}')
osvers_minor=$(/usr/bin/sw_vers -productVersion | awk -F. '{print $2}')
osvers_dot_version=$(/usr/bin/sw_vers -productVersion | awk -F. '{print $3}')
if [[ "$osvers_major" -eq 10 && "$osvers_minor" -lt 13 ]]; then
echo "<result>Older macOS version</result>"
@stevewood-tx
stevewood-tx / gist:461ac4d7db4f52e9b7e3df603f897cd3
Created August 31, 2021 14:41
Package Build Script - Signed Distribution Package
#!/bin/bash
args=("$@")
pkgName="${args[0]}"
echo "Supply the package name and version: build.sh <pkgname> <version>"
# get date for package name
myDate=`date +%Y%m%d`
# Name of the package.
NAME="${pkgName}"
@stevewood-tx
stevewood-tx / gist:caf2de88462dfb7716310573f4284280
Created August 31, 2021 14:36
Package Build Script - Signed package
#!/bin/bash
args=("$@")
pkgName="${args[0]}"
echo "Supply the package name and version: build.sh <pkgname> <version>"
# get date for package name
myDate=`date +%Y%m%d`
# Name of the package.
NAME="${pkgName}"
#!/bin/bash
## basic package, not signed. Provide name you want and version as command line arguments.
args=("$@")
pkgName="${args[0]}"
echo "Supply the package name and version: build.sh <pkgname> <version>"
# get date for package name
myDate=`date +%Y%m%d`
## upload log to JPS
xpath() {
# the xpath tool changes in Big Sur
if [[ $(sw_vers -buildVersion) > "20A" ]]; then
/usr/bin/xpath -e "$@"
else
/usr/bin/xpath "$@"
fi
}
@stevewood-tx
stevewood-tx / gist:4d66eb7ed4611755ae4bb859fce37016
Created April 16, 2020 03:50
Upload File to Computer Record
curl -sku $apiUser:$apiPass $jpsURL/JSSResource/fileuploads/computers/id/$JSS_ID -F name=@${mylog} -X POST
JSS_ID=$(curl -H "Accept: text/xml" -sfku "${jss_user}:${jss_pass}" "${jss_url}/JSSResource/computers/serialnumber/${serial}/subset/general" | xpath /computer/general/id[1] | awk -F'>|<' '{print $3}')
serial=$(system_profiler SPHardwareDataType | awk '/Serial\ Number\ \(system\)/ {print $NF}');
@stevewood-tx
stevewood-tx / gist:4dba9f36252552dca6b16c43464ab899
Last active December 26, 2021 17:58
Simple Logging in Shell Scripts
#!/bin/zsh
mylogpath=/tmp/mylog
mylog=$mylogpath/myawesomlog-$(date +%Y%m%d-%H%M).log
[[ ! -d ${mylogpath} ]]; mkdir -p $mylogpath
set -xv; exec 1> $mylog 2>&1
... do some stuff ...