-
Notifications
You must be signed in to change notification settings - Fork 1
/
fram
executable file
·80 lines (63 loc) · 1.64 KB
/
fram
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
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-only
# Board FRAM - Board Farm Remote Access Management - Client convenience wrapper
#
# Copyright (C) 2023-2024 Glider bv
set -e
CONFIG="$HOME/.framrc"
test -f "$CONFIG" || { echo Config file "$CONFIG" does not exist; exit 1; }
function usage()
{
cat <<END
Board FRAM - Board Farm Remote Access Management
Usage:
$(basename "$0") <command>
$(basename "$0") <board> <command> ...
Generic commands are:
help Show this usage information
list List all available boards
Basic board-specific commands are:
help Show full board usage information
console Access the board console
ls List the boot directory contents
power [on|off|status*] Control board power
reset Reset board
status Show board status
upload <file> ... Upload files to boot directory
Options marked with an asterisk are the default.
Use "fram <board> help" for more commands and board-specific usage information.
END
exit 0
}
CMD=$(basename "$0")
if [ "$CMD" != "fram" ]; then
BOARD=${CMD#*-}
CMD=${CMD%%-*}
elif [ $# -ge 2 ]; then
BOARD=$1
shift
CMD=$1
shift
else
case $1 in
list)
cut -d = -f 1 "$CONFIG"
;;
*)
usage
;;
esac
exit 0
fi
TARGET=$(sed -n -e "s/^$BOARD=//p" "$CONFIG")
test -z "$TARGET" && { echo "$BOARD" not found in "$CONFIG"; exit 1; }
case "${CMD}" in
console|shell)
SSH_ARGS=-t
;;
upload)
rsync -zav "$@" "$TARGET:"
exit 0
;;
esac
ssh $SSH_ARGS "$TARGET" "$CMD" "$@"