-
Notifications
You must be signed in to change notification settings - Fork 10
/
di-all.sh
executable file
·129 lines (86 loc) · 2.26 KB
/
di-all.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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/env zsh -f
# Purpose: Runs all di- scripts found in the same directory
#
# From: Timothy J. Luoma
# Mail: luomat at gmail dot com
# Date: 2016-05-13
## This keeps running on its own, so I have to do this to stop it
#exit 0
NAME="$0:t:r"
if [[ -e "$HOME/.path" ]]
then
source "$HOME/.path"
fi
zmodload zsh/datetime
LOG="$HOME/Library/Logs/$NAME.log"
EXPLAIN_USAGE='no'
LAUNCH_APPS='no'
po.sh "$NAME started"
# Delete (old) log if it exists already
# [[ -e "$LOG" ]] || rm -f "$LOG"
function timestamp { strftime "%Y-%m-%d at %-l:%M:%S %p" "$EPOCHSECONDS" }
function log { echo "$NAME [`timestamp`]: $@" | tee -a "$LOG" }
function launch_apps {
# Show updates in the Mac App Store app:
open 'macappstore://showUpdatesPage'
# Check for common updaters:
for APP in \
'/Library/Application Support/Microsoft/MAU2.0/Microsoft AutoUpdate.app' \
'/Applications/MacUpdate Desktop.app' \
'/Applications/MacUpdater.app'
do
EXPLAIN_USAGE='yes'
if [[ -e "$APP" ]]
then
echo "$NAME: Launching $APP:t"
open -g -a "$APP:t"
fi
done
}
for ARGS in "$@"
do
case "$ARGS" in
-a|--all)
LAUNCH_APPS='yes'
shift
;;
-A|--apps|-g|--gui)
# JUST launch the GUI apps, don't run the di- scripts
launch_apps
echo "$NAME: Done!"
exit 0
;;
-*|--*)
echo " $NAME [warning]: Don't know what to do with arg: $1"
shift
;;
esac
done # for args
# chdir to the directory where this script is found
cd "$0:h"
COUNT='0'
log "---------- STARTING AT `timestamp` ---------- "
##
## Get a list of all of the 'di-*.sh' files (be sure to exclude this script (di-all.sh) or else it'll go on forever)
##
command ls -1 di-*sh \
| egrep -v '(di-all.sh|di-auto.sh)' \
| while read line
do
log "Running $line"
((COUNT++))
"${line}" 2>&1 | tee -a "$LOG"
done
log "---------- FINISHED AT `timestamp` after checking $COUNT apps ---------- "
echo "$NAME last ran: `timestamp`. ${COUNT} apps were checked." >| "$HOME/.$NAME.lastrun.log"
exit 0
if [[ "$LAUNCH_APPS" == 'yes' ]]
then
launch_apps
else
# Explain how to launch GUI updaters, if any are found.
[[ "$EXPLAIN_USAGE" = "yes" ]] \
&& echo "\n$NAME: use '$0 --apps' to _just_ launch GUI updater apps,\n or '$0 --all' to use both di- scripts _and_ GUI updaters."
fi
exit 0
#EOF