Skip to content
This repository was archived by the owner on Jan 5, 2022. It is now read-only.

Commit 6f9b141

Browse files
committed
added automatic device/config detection
- calling the script with "-a" or "--auto" as parameter activates this - matches the serial from "adb devices" with existing config files - runs itself for each found device/config match
1 parent 41a1b65 commit 6f9b141

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Diff for: adebar-cli

+20-1
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,28 @@ declare -A OOPSES # array to store which lines where already reported
8686
BINDIR="${0%/*}"
8787

8888
# check parameters
89-
if [[ -z "$1" || "$1" = "-h" || "$1" = "--help" ]]; then
89+
if [[ "$1" = "-a" || "$1" = "--auto" ]]; then
90+
if [[ ! -d "${BINDIR}/config" ]]; then
91+
echo
92+
echo "Sorry, but you can't use automatic config detection with no config directory"
93+
echo "created. Please create it first, and have your config files placed there."
94+
echo
95+
exit 1
96+
fi
97+
declare -i trc=0
98+
for serial in $(adb devices|tail -n +2|awk '{print $1}'); do
99+
confi=$(egrep "^\s*SERIAL=.${serial}.\s*$" "${BINDIR}/config/"* |head -n 1|awk -F ':' '{print $1}')
100+
[[ -z "${confi}" ]] && continue # unknown device, i.e. serial not found in any config
101+
confi=${confi##*/}
102+
$0 $confi
103+
trc+=$?
104+
# $0 $confi # run adebar for this device
105+
done
106+
exit $trc
107+
elif [[ -z "$1" || "$1" = "-h" || "$1" = "--help" ]]; then
90108
echo
91109
echo "Syntax: $0 <config|target_directory> [suffix]"
110+
echo "Syntax: $0 <-a|--auto|-h|--help>"
92111
echo
93112
if [[ ! -d "${BINDIR}/config" || "$1" = "-h" || "$1" = "--help" ]]; then
94113
echo "There are no more command-line parameters currently, everything is"

0 commit comments

Comments
 (0)