-
Notifications
You must be signed in to change notification settings - Fork 4
/
GenericMacOSScriptedInstall_NSUserDefaults.zsh
83 lines (72 loc) · 3.26 KB
/
GenericMacOSScriptedInstall_NSUserDefaults.zsh
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/zsh
set -e
# Change these values
ZORUS_DEPLOYMENT_TOKEN_USER_DEFAULTS=$(defaults read com.ZorusTech DeploymentKey)
if [[ -z "$ZORUS_DEPLOYMENT_TOKEN_USER_DEFAULTS" ]]
then
echo "The Zorus Deployment Token was not found in NSUserDefaults system."
exit 1
fi
ZORUS_DEPLOYMENT_TOKEN="$ZORUS_DEPLOYMENT_TOKEN_USER_DEFAULTS"
ZORUS_SET_DEPLOYMENT_TOKEN=true # Set this to false if you have an MDM that will deploy the deployment token with another approach.
# Do not change these values
ZORUS_WEB_DOWNLOAD_HOST="portal.zorustech.com"
ZORUS_APP_DATA_BASE_DIR="/Library/Application Support/Zorus, Inc"
ZORUS_SETTINGS_DIR="$ZORUS_APP_DATA_BASE_DIR/Settings"
echo " ___ ___ ___ ___ ___ "
echo " /\ \ /\ \ /\ \ /\__\ /\ \ "
echo " \:\ \ /::\ \ /::\ \ /:/ / /::\ \ "
echo " \:\ \ /:/\:\ \ /:/\:\ \ /:/ / /:/\ \ \ "
echo " \:\ \ /:/ \:\ \ /::\~\:\ \ /:/ / ___ _\:\~\ \ \ "
echo " _______\:\__\ /:/__/ \:\__\ /:/\:\ \:\__\ /:/__/ /\__\ /\ \:\ \ \__\ "
echo " \::::::::/__/ \:\ \ /:/ / \/_|::\/:/ / \:\ \ /:/ / \:\ \:\ \/__/ "
echo " \:\~~\~~ \:\ /:/ / |:|::/ / \:\ /:/ / \:\ \:\__\ "
echo " \:\ \ \:\/:/ / |:|\/__/ \:\/:/ / \:\/:/ / "
echo " \:\__\ \::/ / |:| | \::/ / \::/ / "
echo " \/__/ \/__/ \|__| \/__/ \/__/ "
echo " "
echo " Generic macOS Scripted Install (NSUserDefaults) "
echo " "
if [[ -d /Applications/MSP-Filtering.app ]]
then
echo "Detected existing installation. Skipping installation."
exit 0
fi
# Change below when we release.
ZORUS_WEB_DOWNLOAD_URL="https://$ZORUS_WEB_DOWNLOAD_HOST/product-downloads/agent"
if [[ $(sysctl -n machdep.cpu.brand_string) =~ "Apple" ]]
then
echo "Detected Apple Silicon Processor."
ZORUS_WEB_DOWNLOAD_URL+="?platformType=2&architectureType=2"
else
echo "Detected Intel Processor."
ZORUS_WEB_DOWNLOAD_URL+="?platformType=2&architectureType=1"
fi
echo "Creating Temporary Directory."
ZORUS_TEMP_DIR=$(mktemp -d)
cd "$ZORUS_TEMP_DIR"
echo "Created Temporary Directory $ZORUS_TEMP_DIR."
echo "Downloading Installer from $ZORUS_WEB_DOWNLOAD_URL."
curl -f -s -S --connect-timeout 30 --retry 5 --retry-delay 60 -L -o ZorusFilteringInstaller.pkg -H "X-Deployment-Token: $ZORUS_DEPLOYMENT_TOKEN" "$ZORUS_WEB_DOWNLOAD_URL"
echo "Downloaded Installer to $ZORUS_TEMP_DIR/ZorusFilteringInstaller.pkg."
if [[ $ZORUS_SET_DEPLOYMENT_TOKEN ]]
then
echo "Creating Credentials File."
if [ ! -f "$ZORUS_SETTINGS_DIR/credentials.json" ]
then
mkdir -p "$ZORUS_SETTINGS_DIR"
cat <<-EOF > "$ZORUS_SETTINGS_DIR/credentials.json"
{
"CredentialSettings": {
"DeploymentKey": "$ZORUS_DEPLOYMENT_TOKEN"
}
}
EOF
fi
echo "Created Credentials File."
else
echo "Skipped Creating Credentials File."
fi
echo "Installing Filtering."
installer -pkg "$ZORUS_TEMP_DIR/ZorusFilteringInstaller.pkg" -target /Applications
echo "Filtering Installed."