Created
February 7, 2019 11:22
-
-
Save taniacomputer/cab6f6ea487204237ca2b9ddeeb63886 to your computer and use it in GitHub Desktop.
Slack post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SLACK_WEBHOOK="https://hooks.slack.com/services/A123456" | |
IMAGE="https://<s3bucket>/MBPJamf.png" | |
SSID="acme-wifi" | |
danger=0 | |
computer_name=$(scutil --get ComputerName) | |
primary_user=$(cat /etc/.seek) | |
title="SEEK Setup Completed for *$computer_name*" | |
text="*JSS ID:* $JSS_ID\n*Primary User:*" | |
# Primary User | |
if [[ ! -z "$primary_user" ]] | |
then | |
fullname=$(sudo dscl . read /Users/"$primary_user" RealName | sed 's/^ *//' | sed 's/RealName://g' | sed '/^\s*$/d') | |
text="$text $primary_user\n" | |
text="$text *Full name:* $fullname\n" | |
else | |
text="$text Unassigned\n" | |
fi | |
# FV Check for Primary User | |
if [[ ! -z "$primary_user" ]] | |
then | |
check_primary_user=$(fdesetup list | grep "$primary_user") | |
if [[ ! -z "$check_primary_user" ]] | |
then | |
text="$text*Primary User FV enabled?:* Yes\n" | |
else | |
text="$text*Primary User FV enabled?:* No\n" | |
danger=1 | |
fi | |
fi | |
# FV Check for TOC | |
check_toc=$(fdesetup list | grep "toc") | |
if [[ ! -z "$check_toc" ]] | |
then | |
text="$text*TOC FV enabled?:* Yes\n" | |
else | |
text="$text*TOC FV enabled?:* No\n" | |
danger=1 | |
fi | |
wifi=$(networksetup -getairportnetwork en0) | |
wifi_check=$(echo "$wifi" | grep "$SSID") | |
if [[ -z "$wifi_check" ]] | |
then | |
text="$text*WiFi Check*: Mac not connected to sk-staff\n" | |
danger=1 | |
else | |
text="$text*WiFi Check*: Connected to sk-staff\n" | |
fi | |
if [[ $danger -eq 1 ]] | |
then | |
color="danger" | |
else | |
color="good" | |
fi | |
escapedText=$(echo $text | sed 's/"/\"/g' | sed "s/'/\'/g" ) | |
json="{\"text\": \"$title\",\"attachments\":[{\"thumb_url\": \"$IMAGE\",\"color\":\"$color\" , \"text\": \"$escapedText\"}]}" | |
curl -sk -d payload="$json" "$SLACK_WEBHOOK" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment