-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMac-Install-Nudge.sh
More file actions
44 lines (32 loc) · 1.66 KB
/
Mac-Install-Nudge.sh
File metadata and controls
44 lines (32 loc) · 1.66 KB
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
#!/bin/bash
# This script is provided AS IS without warranty of any kind.
# https://github.com/Mac-Nerd/Mac-scripts
# -----------------------------------------------------------
# Original source: https://github.com/rs1278/macOSinstallers/tree/main/Installers/Nudge
# This script determines the latest version of the Nudge installer, downloads and
# installs it. The optional LaunchAgent is also installed. The intent is to trigger Nudge
# by use of a scheduled task or script check. See the Getting Started guide for more info:
# https://github.com/macadmins/nudge/wiki/Getting-Started
# For ADM deployment, install the profile "Nudge-configuration.mobileconfig" as well.
# Variables
nudgeLatestURL="https://github.com/macadmins/nudge/releases/latest/"
versionUrl=$(curl "${nudgeLatestURL}" -s -L -I -o /dev/null -w '%{url_effective}')
versionNumber=$(printf "%s" "${versionUrl[@]}" | sed 's@.*/@@' | sed 's/%20/-/g')
versionNumber=${versionNumber:1}
downloadUrl="https://github.com/macadmins/nudge/releases/download/v$versionNumber/Nudge-$versionNumber.pkg"
#header="$(curl -sI "$downloadUrl" | tr -d '\r')"
pkgName=$(printf "%s" "${downloadUrl[@]}" | sed 's@.*/@@' | sed 's/%20/-/g')
pkgPath="/tmp/$pkgName"
downloadUrl2="https://github.com/macadmins/nudge/releases/download/v$versionNumber/Nudge_LaunchAgent-1.0.0.pkg"
pkgName2=$(printf "%s" "${downloadUrl2[@]}" | sed 's@.*/@@' | sed 's/%20/-/g')
pkgPath2="/tmp/$pkgName2"
# Download files
/usr/bin/curl -sL -o "$pkgPath" "$downloadUrl"
/usr/bin/curl -sL -o "$pkgPath2" "$downloadUrl2"
# Install PKGs
installer -pkg "$pkgPath" -target /
installer -pkg "$pkgPath2" -target /
# Delete PKGs
/bin/rm "$pkgPath"
/bin/rm "$pkgPath2"
exit 0