forked from FinalAngel/osx-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdater.sh
50 lines (43 loc) · 1.09 KB
/
updater.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
#!/bin/sh
function _current_epoch() {
echo $(($(date +%s) / 60 / 60 / 24))
}
function _update_osx_update() {
echo 'LAST_EPOCH=$(_current_epoch)' > ~/.osx-bootstrap/.osx-update
}
function _upgrade_osx() {
~/.osx-bootstrap/.osx-bootstrap
}
epoch_target=$UPDATE_OSX_DAYS
if [[ -z $epoch_target ]]; then
# Default to old behavior
epoch_target=13
fi
if [ -f ~/.osx-bootstrap/.osx-update ]
then
. ~/.osx-bootstrap/.osx-update
if [[ -z $LAST_EPOCH ]]; then
_update_osx_update && return 0;
fi
epoch_diff=$(($(_current_epoch) - $LAST_EPOCH))
if [ $epoch_diff -gt $epoch_target ]
then
if [[ $DISABLE_UPDATE_PROMPT = 'true' ]]
then
_upgrade_osx
else
echo ''
echo '##### OSX Bootstrap would like to check for updates?'
echo 'Type Y/N to update:'
read line
if [ $line = Y ] || [ $line = y ]; then
_upgrade_osx
else
_update_osx_update
fi
fi
fi
else
# create the update file
_update_osx_update
fi