-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_macOS.sh
More file actions
executable file
·59 lines (49 loc) · 1.28 KB
/
install_macOS.sh
File metadata and controls
executable file
·59 lines (49 loc) · 1.28 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
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
### define installer behavior
StartInstall ()
{
### install mojave ###
/Applications/Install\ macOS\ Mojave.app/Contents/Resources/startosinstall \
--rebootdelay 5 \
--nointeraction \
--agreetolicense
exit 0
}
OS=$(sw_vers -productVersion | cut -c 1-5)
### if already up to date, abort ###
if [ "$OS" = "10.14" ];
then
echo "10.14 already installed"
exit 0
fi
### if less than 10GB of free space, abort ###
StorageAvail=$(df -H / | tail -1 | awk '{print $4}' | tr -d "G")
if [ $StorageAvail -lt 10 ];
then
echo "Not enough free space"
exit 0
fi
### if installer isnt present, abort ###
if [ ! -d "/Applications/Install macOS Mojave.app" ];
then
echo "macOS installer not present"
exit 0
fi
PluggedInYN=$(pmset -g ps | grep "Power" | cut -c 18- | tr -d "'")
### are we plugged in? ###
if [ "$PluggedInYN" = "AC Power" ];
then
echo "not on battery power, proceeding"
StartInstall
else
### do we have enough power? ###
BatteryPercentage=$(pmset -g ps | tail -1 | awk -F ";" '{print $1}' | awk -F "\t" '{print $2}' | tr -d "%")
if [ $BatteryPercentage -ge 75 ];
then
echo "battery at 75% or higher, proceeding"
StartInstall
else
echo "battery less than 75%, aborting"
exit 0
fi
fi