-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·78 lines (67 loc) · 2.25 KB
/
setup.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
#!/bin/bash
# Purpose: Script to setup the docker container and/or enter it
# Usage: ./setup.sh (flags)
# Default: Checks if docker exists and is running, if not creates/starts it
# ---------------------------------------
force_build=false
enter=false
usage() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -b Force a rebuild of the docker"
echo " -d Disable detached start"
echo " -h Display this help message"
}
enter_container() {
echo "[--] Entering container..."
docker exec -it machine-learning /bin/bash
exit 0
}
while getopts ":beh" flag; do
case $flag in
b) # Force a rebuild
force_build=true
;;
e) # Enter the docker
enter=true
;;
h) # Display usage
usage
exit 0
;;
esac
done
# Sanity check; is docker & co installed?
if ! command -v docker &> /dev/null | command -v docker-compose &> /dev/null;
then
echo "[:(] docker and/or docker-compose is not installed."
exit 1
fi
if [ "$force_build" == false ] && \
docker-compose ps machine-learning | grep Up &> /dev/null;
then
[ "$enter" == true ] && enter_container
echo "[:(] Container is already running, did you mean to run with -e?"
exit 0
fi
# Build and start the docker container
echo "[--] Building container, may take a while..."
docker-compose build &> /dev/null
echo "[:)] Docker container built!"
echo "[--] Starting container..."
docker-compose up -d &> /dev/null
echo "[:)] Docker container up & running!"
[ "$enter" == true ] && enter_container
# ---------------------------------------
# bare-metal install, left in for now
# ---------------------------------------
# sudo cp /etc/apt/sources.list /etc/apt/sources.backup
# echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main \
# | sudo tee -a /etc/apt/sources.list
# echo deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main \
# | sudo tee -a /etc/apt/sources.list
# # wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
# # sudo apt update && sudo apt upgrade
# sudo apt-get install libllvm17 llvm-17 llvm-17-dev llvm-17-doc \
# llvm-17-examples llvm-17-runtime libedit-dev libzstd-dev \
# libcurl4-gnutls-dev libstdc++-12-dev clang-17