-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·88 lines (74 loc) · 2.53 KB
/
run.sh
File metadata and controls
executable file
·88 lines (74 loc) · 2.53 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
#!/usr/bin/env bash
###
# run.sh – Run apps for testing purposes.
#
# This script is not used for running apps in production, but for running
# them on a device that is not yet locked down. This may be useful as a demo
# machine or for testing new builds/features/etc.
###
set -euo pipefail
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ALL_APPS=()
for app in ${DIR}/vxsuite/apps/*; do
if [ -d "${app}" ]; then
ALL_APPS+=("$(basename "${app}")")
fi
done
usage() {
echo "usage: ./run.sh ($(IFS=\| ; echo "${ALL_APPS[*]}"))"
echo
echo "Runs a VxSuite app for testing purposes."
}
if [ $# = 0 ]; then
usage >&2
exit 1
fi
APP="$1"
if [[ " ${ALL_APPS[@]} " =~ " ${APP} " ]]; then
if [ ! -d "${DIR}/build/${APP}" ]; then
echo "⁉️ ${APP} is not yet built, building…"
"${DIR}/prepare_build.sh" "${APP}"
"${DIR}/build.sh" "${APP}"
fi
# set up config
export VX_CONFIG_ROOT="${DIR}/config"
export VX_METADATA_ROOT="${DIR}"
[ -f "${VX_CONFIG_ROOT}/machine-id" ] || echo 0000 > "${VX_CONFIG_ROOT}/machine-id"
echo "${APP}" > "${VX_CONFIG_ROOT}/machine-type"
echo "VotingWorks" > "${VX_CONFIG_ROOT}/machine-manufacturer"
echo "1" > "${VX_CONFIG_ROOT}/is-qa-image"
[ -f "${VX_CONFIG_ROOT}/machine-model-name" ] || echo dev > "${VX_CONFIG_ROOT}/machine-model-name"
[ -f "${VX_METADATA_ROOT}/code-version" ] || echo dev > "${VX_METADATA_ROOT}/code-version"
[ -f "${VX_METADATA_ROOT}/code-tag" ] || echo dev > "${VX_METADATA_ROOT}/code-tag"
# mark-scan requires daemons running in the background
# reload their daemon configs and then issue restart commands
if [[ "${APP}" == "mark-scan" ]]; then
sudo systemctl daemon-reload
# default to 155 daemons
vx_daemons="controller pat"
vxsuite_env_file="/vx/code/vxsuite/.env"
# check for the 150 env var to use 150 daemon
if grep REACT_APP_VX_MARK_SCAN_USE_BMD_150 $vxsuite_env_file | grep -i true > /dev/null 2>&1
then
vx_daemons="fai-100"
fi
for vx_daemon in ${vx_daemons}
do
sudo systemctl restart mark-scan-${vx_daemon}-daemon.service
done
fi
export DISPLAY=${DISPLAY:-:0}
cd "${DIR}/build/${APP}"
(
trap 'kill 0' SIGINT SIGHUP; "./run-${APP}.sh" &
# Delay kiosk-browser to make sure the app is running first
(while ! curl -s localhost:3000; do sleep 1; done; "./run-kiosk-browser.sh"; kill 0)
) 2>&1 | logger -S 4096 --tag votingworksapp
elif [[ "${APP}" = -h || "${APP}" = --help ]]; then
usage
exit 0
else
echo "✘ unknown app: ${APP}" >&2
usage >&2
exit 1
fi