-
Notifications
You must be signed in to change notification settings - Fork 3
/
update_software.sh
executable file
·96 lines (86 loc) · 2.54 KB
/
update_software.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
#!/usr/bin/env sh
DATA_DIR=$HOME/data
LINE=`printf %80s | tr " " "="`
INDENT=" "
case `uname` in
Linux)
ECHO_CMD="echo -e"
;;
Darwin)
ECHO_CMD="echo"
;;
esac
stamp() {
OUTFILE=$DATA_DIR/$1-$2.log
$ECHO_CMD "\n$LINE" >> $OUTFILE
$ECHO_CMD "$3 $1" >> $OUTFILE
$ECHO_CMD `date` >> $OUTFILE
$ECHO_CMD "$LINE\n" >> $OUTFILE
}
if [ ! -d $DATA_DIR ]; then
$ECHO_CMD "Creating data directory at $DATA_DIR..."
mkdir -p $DATA_DIR
fi
#CONDA_FOUND=`which conda 2> /dev/null`
CONDA_FOUND=
if [ -n "$CONDA_FOUND" ]; then
stamp conda clean Cleaning
if conda clean -tipsy >> $DATA_DIR/conda-clean.log 2>&1; then
$ECHO_CMD "👍 conda cleaned"
else
$ECHO_CMD "💩 problem cleaning conda"
fi
stamp conda update
if conda update -yq conda >> $DATA_DIR/conda-update.log 2>&1; then
$ECHO_CMD "👍 conda updated"
stamp anaconda update Updating
if conda update -yq anaconda >> $DATA_DIR/anaconda-update.log 2>&1; then
$ECHO_CMD "👍 anaconda updated"
# either use anaconda package or update --all
# stamp conda-packages update
# if conda update -yq --all >> $DATA_DIR/conda-packages-update.log 2>&1; then
# $ECHO_CMD "conda packages updated"
# else
# $ECHO_CMD "problem updating conda packages"
# fi
conda list > $DATA_DIR/conda-list.log 2>&1
conda list --export > $DATA_DIR/conda-list-export.log 2>&1
else
$ECHO_CMD "💩 problem updating anaconda"
fi
else
$ECHO_CMD "💩 problem updating conda"
fi
fi
BREW_FOUND=`which brew 2> /dev/null`
if [ -n "$BREW_FOUND" ]; then
stamp brew cleanup Cleaning
if brew cleanup -s >> $DATA_DIR/brew-update.log 2>&1; then
$ECHO_CMD "👍 homebrew cleaned"
else
$ECHO_CMD "💩 problem cleaning homebrew"
fi
stamp brew update Updating
if brew update >> $DATA_DIR/brew-update.log 2>&1; then
$ECHO_CMD "👍 homebrew updated"
TO_BE_UPGRADED=`brew outdated`
if [ ${#TO_BE_UPGRADED} -gt 0 ]; then
$ECHO_CMD "homebrew formula to be upgraded:"
for item in $TO_BE_UPGRADED; do
$ECHO_CMD "$INDENT$item"
done
stamp brew upgrade Upgrading
if brew upgrade >> $DATA_DIR/brew-upgrade.log 2>&1; then
$ECHO_CMD "👍 homebrew formulas upgraded"
brew leaves > $DATA_DIR/brew-leaves.log 2>&1
else
$ECHO_CMD "💩 problem upgrading homebrew formula"
fi
else
$ECHO_CMD "🤷♀️ no homebrew formulas to upgrade"
fi
else
$ECHO_CMD "💩 problem updating homebrew"
fi
fi
date +"%a %Y-%m-%d %H:%M:%S"