forked from M-earnest/docker_workshop
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcheck_install.sh
More file actions
110 lines (95 loc) · 2.7 KB
/
check_install.sh
File metadata and controls
110 lines (95 loc) · 2.7 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
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
#!/usr/bin/env bash
# Script to run after following all install instructions to make sure that
# everything was installed correctly!
#
# Usage:
#
# $ bash check_install.sh
#
# The script will try and print out any missing programs to the screen with
# brief instructions on how to install them. If everything is installed
# correctly you will see a message printed to screen notifying you of this.
#
missing=
function check_installed() {
func=${1}
hash ${func} 2> /dev/null || {
printf "Missing software program: ${func}. "
printf "Check installation instructions\n"
missing=true
}
}
function get_os() {
UNAME=$( $( command -v uname) -a | tr '[:upper:]' '[:lower:]' )
if echo "${UNAME}" | grep -q "microsoft"; then
printf "windows\n"
elif echo "${UNAME}" | grep -q "darwin"; then
printf "darwin\n"
elif echo "${UNAME}" | grep -q "linux"; then
printf "linux\n"
else
printf "unknown\n"
fi
}
curr_os=$( get_os )
# expected VSCode extensions
extensions=(
ms-azuretools.vscode-docker
ms-vsliveshare.vsliveshare
ms-vsliveshare.vsliveshare-audio
ms-vsliveshare.vsliveshare-pack
)
if [ "${curr_os}" == "windows" ]; then
extensions+=(ms-vscode-remote.remote-wsl)
fi
# expected importable python package
packages=(
flake8
IPython
jupyter
jupyterlab
)
# check basic installations
check_installed git
check_installed conda
check_installed python
check_installed code
check_installed docker
# check vscode extensions
if [ "${curr_os}" == "windows" ]; then
cmd.exe /c "code --list-extensions" > /tmp/vscode_ext 2> /dev/null
vscode_ext=$( cat /tmp/vscode_ext )
else
vscode_ext=$( code --list-extensions )
fi
for ext in ${extensions[@]}; do
if [[ $vscode_ext != *${ext}* ]]; then
ext=$( echo "${ext}" | tr '[:upper:]' '[:lower:]' )
printf "Missing VSCode extension: "
printf "install with $ code --install-extension ${ext}\n"
missing=true
fi
done
# check python packages
for package in ${packages[@]}; do
python -c "import ${package}" 2> /dev/null || {
package=$( echo "${package}" | tr '[:upper:]' '[:lower:]' )
printf "Missing Python package: "
printf "install with $ conda install ${package}\n"
missing=true
}
done
# congratulations, you did it!
if [ -z ${missing} ]; then
if [ "${curr_os}" != "windows" ]; then
python -c 'print("\U0001f389" * 3, end=" ")'
fi
printf "Everything seems to be installed correctly! "
if [ "${curr_os}" != "windows" ]; then
python -c 'print("\U0001f389" * 3)'
else
printf "\n"
fi
printf "Congratulations, you're all ready for the course!\n"
fi
exit 0