-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDSE-DisableAutoBoot.zsh
More file actions
executable file
·47 lines (40 loc) · 1.26 KB
/
DSE-DisableAutoBoot.zsh
File metadata and controls
executable file
·47 lines (40 loc) · 1.26 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
44
45
46
#!/bin/zsh
# Author: Andrew W. Johnson
# Date: 2021.11.09
# Version: 1.00
# Stony Brook University/DoIT
#
# This Jamf script will turn off the AutoBoot feature on Intel Macintosh laptops.
# When the lid is opened or power connected, the computer automatically
# powers on and it upsets some users.
#
# Has not been tested on ARM processors.
#
# To turn off AutoBoot: /usr/sbin/nvram AutoBoot=%00
# To turn on AutoBoot: /usr/sbin/nvram AutoBoot=%03
# Check the status of AutoBoot.
myStatus=$( /usr/sbin/nvram AutoBoot 2>/dev/null | /usr/bin/awk '{print $2}' )
# If it's not set then set it.
if [[ -z ${myStatus} ]]; then
/bin/echo "AutoBoot has not been set. Setting..."
/usr/sbin/nvram AutoBoot=%00
fi
# If %03 is returned it means that it's on. So turn it off...
# If %00 is returned than it's off...
if [[ ${myStatus} = "%03" ]]; then
/bin/echo "AutoBoot is on. Turning off..."
/usr/sbin/nvram AutoBoot=%00
elif [[ ${myStatus} = "%00" ]]; then
/bin/echo "AutoBoot is already off."
exit 0
fi
# Check again to see if we had success.
myStatus=$( /usr/sbin/nvram AutoBoot 2>/dev/null | /usr/bin/awk '{print $2}' )
if [[ ${myStatus} = "%00" ]]; then
/bin/echo "AutoBoot change successful..."
exit 0
else
/bin/echo "AutoBoot change unsuccessful..."
exit 1
fi
exit 0