-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdocker-start.sh
executable file
·75 lines (62 loc) · 2.36 KB
/
docker-start.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
#!/usr/bin/env bash
# Copyright 2020-2022 Billy Bromell, Adam Bromiley - Warwick Manufacturing
# Group, University of Warwick.
#
# This file is part of Netkit.
#
# Netkit is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Netkit is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Netkit. If not, see <http://www.gnu.org/licenses/>.
# Download and install Netkit-JH in the user's home directory.
# ANSI color escape sequences
color_normal=$'\033[0m'
color_red=$'\033[0;31m'
color_green=$'\033[0;32m'
color_magenta=$'\033[0;35m'
# Link to tutorial
tutorial_link="https://netkit-jh.github.io/docs/dev/guides/dockerbuild/"
if [ -n "$(mount --show-labels --types proc)" ]; then
echo "/proc already mounted ${color_green}[✓]$color_normal"
elif ! mount --types proc proc /proc; then
echo "${color_red}Could not mount /proc$color_normal"
exit 1
fi
if mount | grep '/netkit-build' &> /dev/null; then
echo "/netkit-build mounted ${color_green}[✓]$color_normal"
else
cat << END_OF_DIALOG
${color_red}Source Code Dir not mounted.$color_normal
Remember to pass a volume in the docker argument with:
-v PATH_TO_NETKIT_JH_BUILD:/netkit-build
$color_magenta$tutorial_link$color_normal
END_OF_DIALOG
exit 1
fi
# Should already be in /netkit-build from WORKDIR in Dockerfile
if [ -f "Makefile" ]; then
echo "Building Netkit${MAKE_ARGS:+" with '$MAKE_ARGS' as arguments to the Makefile"}"
# shellcheck disable=SC2086
if make $MAKE_ARGS; then
echo "Make exited successfully${color_green}[✓]$color_normal"
else
echo "${color_red}Error running Make$color_normal"
exit 1
fi
else
cat << END_OF_DIALOG
${color_red}Makefile doesn't exist.$color_normal
Have you cloned the netkit-jh-build source? Ensure you are passing the correct
directory as a Docker volume. You may need to give a full path.
$color_magenta$tutorial_link$color_normal
END_OF_DIALOG
exit 1
fi