-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
executable file
·76 lines (63 loc) · 1.99 KB
/
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
76
#!/bin/bash
# Reset
Color_Off='\033[0m' # Text Reset
# Regular Colors
Black='\033[0;30m' # Black
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
Blue='\033[0;34m' # Blue
Purple='\033[0;35m' # Purple
Cyan='\033[0;36m' # Cyan
White='\033[0;37m' # White
# Checking that user do not run as root
if [ "$EUID" -eq 0 ]
then echo "Please do not run as root"
exit
fi
# Checking realtime-kernel
if [ -z "$(uname -a | grep PREEMPT_RT)" ]; then
echo -e "$Red[WARNING]$Color_Off System does not have Realtime kernel enabled"
echo "Please install one: https://ubuntu.com/pro"
RT_ARGS=""
else
RT_ARGS="--ulimit rtprio=99 --cpus=$(nproc) --cap-add=SYS_NICE"
fi
install_docker () {
echo "Installing docker..."
sudo apt install docker
}
# Checking docker installation
if ! [ -x "$(command -v docker)" ]; then
echo 'Error: docker is not installed.' >&2
read -p "Do you want to install it? (y/N)" choice
case "$choice" in
y|Y ) install_docker;;
* ) echo "Exiting" && exit 1;;
esac
fi
# Checking if docker image is found
if [ -z "$(docker images | grep beamformer)" ]; then
echo "Docker image not found."
read -p "Do you want to build it? (y/N)" choice
case "$choice" in
y|Y ) docker build -t beamformer .;;
* ) echo "Exiting" && exit 1;;
esac
fi
if [ -z "$(docker images | grep tftpd)" ]; then
echo -e "$Blue[INFO]$Color_Off System does not have a TFTP-server image for the FPGA to boot from"
echo "Please see boot/README.md"
fi
AUDIO_ARGS="-e PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native -v ${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native -v /run/dbus:/run/dbus --device /dev/snd"
# Starting the container
docker run -it \
$RT_ARGS \
--network=host \
-v $(pwd):/usr/src/app \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--privileged \
$AUDIO_ARGS \
--device=/dev/video02 \
beamformer bash