-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.sh
More file actions
executable file
·77 lines (64 loc) · 1.49 KB
/
Copy pathclient.sh
File metadata and controls
executable file
·77 lines (64 loc) · 1.49 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
#!/usr/bin/env bash
set -euo pipefail
. bash/shared/default.sh
export PATH="/usr/local/openssl-3.5/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/openssl-3.5/lib64${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export OPENSSL_CONF="/usr/local/openssl-3.5/ssl/openssl.cnf"
POSITIONAL=()
EXTRA_ARGS=()
print_openssl_info() {
print_status "Using OpenSSL: $(openssl version)"
printf '\n'
print_status "lib path: $LD_LIBRARY_PATH"
printf '\n'
}
passthrough() {
exec bin/client "$@"
}
parse_args() {
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help|help)
passthrough "$@"
;;
--sessionid|-sessionid)
shift
[[ $# -gt 0 ]] || passthrough
EXTRA_ARGS+=("--sessionid" "$1")
shift
;;
-*|--*)
EXTRA_ARGS+=("$1")
shift
;;
*)
POSITIONAL+=("$1")
shift
;;
esac
done
}
main() {
print_openssl_info
parse_args "$@"
if [[ ${#POSITIONAL[@]} -lt 3 ]]; then
passthrough "$@"
fi
IP="${POSITIONAL[0]}"
PORT="${POSITIONAL[1]}"
USER="${POSITIONAL[2]}"
SK_PATH="${POSITIONAL[3]:-${IDENTITY_SK:-sample/${USER}.sk.pem}}"
CERT_PATH="${POSITIONAL[4]:-${CLIENT_CERT:-sample/${USER}.crt}}"
print_highlight "Using:"
print_status "IP: $IP"
print_status "Port: $PORT"
print_status "Username: $USER"
print_status "Identity key: $SK_PATH"
print_status "Client cert: $CERT_PATH"
printf '\n'
CMD=(bin/client "$IP" "$PORT" "$USER" "$SK_PATH" "$CERT_PATH")
CMD+=("${EXTRA_ARGS[@]}")
print_status "Executing: ${CMD[*]}"
exec "${CMD[@]}"
}
main "$@"