Skip to content

Instantly share code, notes, and snippets.

View gist:0874c23c002c98488283526dd6532f0a
#!/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 Aug 9, 2022
Secure Token Users Extension Attribute
View gist:fa638783ff6f751ebbddfc54c5708e81
#!/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 Aug 31, 2021
Package Build Script - Signed Distribution Package
View gist:461ac4d7db4f52e9b7e3df603f897cd3
#!/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 Aug 31, 2021
Package Build Script - Signed package
View gist:caf2de88462dfb7716310573f4284280
#!/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}"
View gist:f9d57f624083a2e5fe50c438fed04067
#!/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`
View gist:8ade3c4133fe0fcdc853bc7be10f9436
## 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
}
View gist:4d66eb7ed4611755ae4bb859fce37016
curl -sku $apiUser:$apiPass $jpsURL/JSSResource/fileuploads/computers/id/$JSS_ID -F name=@${mylog} -X POST
View gist:53ab550a5568f873c973aac15d37da65
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}')
View gist:919c5d2d10eba4f306e57862f47a84f1
serial=$(system_profiler SPHardwareDataType | awk '/Serial\ Number\ \(system\)/ {print $NF}');
@stevewood-tx
stevewood-tx / gist:4dba9f36252552dca6b16c43464ab899
Last active Dec 26, 2021
Simple Logging in Shell Scripts
View gist:4dba9f36252552dca6b16c43464ab899
#!/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 ...