-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathList-Program-Installed.sh
54 lines (44 loc) · 1.08 KB
/
List-Program-Installed.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/zsh
set -x
#File log
filelog="/tmp/list_programs.txt"
function Slack_notification() {
# Send notification messages to a Slack channel by using Slack webhook
#
# input parameters:
# color = good; warning; danger
# $text_slack - main text
######
local message="{
\"channel\": \"${channel}\",
\"attachments\": [
{
\"text\": \"$text_slack\",
\"color\": \"$color\"
}
]
}"
# Send message
curl -X POST \
-H "Authorization: Bearer ${SLACK_API_TOKEN}" \
-H 'Content-type: application/json' \
--data "$message" \
https://slack.com/api/chat.postMessage
sleep 1
# Send file
curl -F file=@${filelog} \
-F channels=${channel} \
-H "Authorization: Bearer ${SLACK_API_TOKEN}" \
https://slack.com/api/files.upload
sleep 1
}
{
uname -a
system_profiler SPHardwareDataType | grep "Serial Number (system)"
dscl . list /Users | grep -v '^_'
mdfind "kMDItemContentType == 'com.apple.application-bundle'" | grep -v "^/System/"
speedtest-cli
} > ${filelog} 2>&1
set +x
text_slack="List programs in $Company $(hostname)."
Slack_notification