forked from mrlnc/LTE-ciphercheck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-test.sh
executable file
·75 lines (66 loc) · 1.78 KB
/
start-test.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
#!/bin/bash
# parse parameters, https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--output-dir)
TARGET_DIR="$2"
shift # past argument
shift # past value
;;
--dl-earfcn)
export DL_EARFCN="$2"
shift # past argument
shift # past value
;;
--apn)
export APN="$2"
shift # past argument
shift # past value
;;
--imei)
export IMEI="$2"
shift # past argument
shift # past value
;;
--default)
DEFAULT=YES
shift # past argument
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
if [[ -z "$DL_EARFCN" || -z "$APN" || -z "$IMEI" ]]; then
echo "usage: start-test.sh --dl-earfcn earfcn --apn apn --imei imei"
echo "optional: --output-dir"
exit 1
fi
if [[ -z "$TARGET_DIR" ]]; then
TARGET_DIR=$(mktemp -d)
fi
START_DATE=$(date +%Y-%m-%d_%H:%M)
echo "Writing to ${TARGET_DIR} on host."
for DIR in config pcap log; do
mkdir ${TARGET_DIR}/${DIR}
if [[ $? -ne 0 ]]; then
echo "Error creating directory '${TARGET_DIR}/${DIR}', does the target exist and is writable?"
exit 1
fi
done
# fill in template config from parameters
envsubst < ./srsue/ciphercheck.conf.example > ${TARGET_DIR}/config/ciphercheck.conf
# we need access to USB; run privileged
sudo docker run \
--privileged \
-v ${TARGET_DIR}/config/ciphercheck.conf:/etc/srslte/ciphercheck.conf \
-v $(realpath ${TARGET_DIR}):/tmp/results \
lte-ciphercheck
END_DATE=$(date +%Y-%m-%d_%H:%M)
echo "Started ${START_DATE}, finished ${END_DATE}"
echo "Results written to ${TARGET_DIR} on host."