-
Notifications
You must be signed in to change notification settings - Fork 0
/
creuclist.sh
executable file
·56 lines (51 loc) · 2.04 KB
/
creuclist.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
#!/usr/bin/env bash
# @Appname: creuclist create a file list of homebrew-cask updates
# @version: 0.0.3
# @Description: creates a list of installed homebrew-cask files that have updates and stores them in
# uclist.csv
# @Usage: On the technician's computer run this script
# edit uclist.csv to your requirements
# then run olinst
echo "Performing brew update to get the latest casks"
brew update
inputfile="uclist.csv"
if [ -f "$inputfile" ]; then
echo "$inputfile file found deleting"
rm -f $inputfile
# return
else
echo "$inputfile file not found"
# return -1
fi
echo "Creating homebrew cask list of updateable apps"
casks=( $(brew cask list) )
for cask in ${casks[@]}; do
current="$(brew cask info $cask | sed -n '1p' | sed -n 's/^.*: \(.*\)$/\1/p')"
auto_updates="$(brew cask cat $cask | sed -n s/'auto_updates '//p | sed -n 's/^.* \(.*\)$/\1/p')"
installed=( $(ls /usr/local/Caskroom/$cask))
# if value of current equals latest and auto_updates is not true then add to the uclist.csv
# if value of current equals latest and auto_updates is true then add to the uclatestlist.csv
# if value of current is not equal to value of installed then add to the uclist.csv
# else skip
if [ "$current" = "latest" ]; then
echo "$(tput sgr0)$(tput rev) ✔ $(tput sgr0) Adding $cask $current to upgrade list file"
if [ "$auto_updates" = "true" ]; then
echo $cask,$current,$auto_updates >>uclatestlist.csv
else
# echo "$cask,$current"
echo $cask,$current >>uclist.csv
fi
else
if (! [[ " ${installed[@]} " == *" $current "* ]]); then
echo "$(tput sgr0)$(tput rev) ✔ $(tput sgr0) Adding $cask v$current to upgrade list file "
echo $cask >>uclist.csv
fi
# display skipping cask when no updates to do.
#else
# if [ $current = "latest" ]; then
# echo "$cask $current is up-to-date, skipping."
# else
# echo "$cask v$current is up-to-date, skipping."
# fi
fi
done