diff options
-rwxr-xr-x | scripts/runqemu-gen-tapdevs | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/scripts/runqemu-gen-tapdevs b/scripts/runqemu-gen-tapdevs index 75547c1361..7f67ee5540 100755 --- a/scripts/runqemu-gen-tapdevs +++ b/scripts/runqemu-gen-tapdevs | |||
@@ -8,39 +8,42 @@ | |||
8 | # SPDX-License-Identifier: GPL-2.0-only | 8 | # SPDX-License-Identifier: GPL-2.0-only |
9 | # | 9 | # |
10 | 10 | ||
11 | uid=`id -u` | ||
12 | gid=`id -g` | 11 | gid=`id -g` |
13 | if [ -n "$SUDO_UID" ]; then | ||
14 | uid=$SUDO_UID | ||
15 | fi | ||
16 | if [ -n "$SUDO_GID" ]; then | 12 | if [ -n "$SUDO_GID" ]; then |
17 | gid=$SUDO_GID | 13 | gid=$SUDO_GID |
18 | fi | 14 | fi |
19 | 15 | ||
20 | usage() { | 16 | usage() { |
21 | echo "Usage: sudo $0 <uid> <gid> <num>" | 17 | echo "Usage: sudo $0 <gid> <num>" |
22 | echo "Where <uid> is the numeric user id the tap devices will be owned by" | ||
23 | echo "Where <gid> is the numeric group id the tap devices will be owned by" | 18 | echo "Where <gid> is the numeric group id the tap devices will be owned by" |
24 | echo "<num> is the number of tap devices to create (0 to remove all)" | 19 | echo "<num> is the number of tap devices to create (0 to remove all)" |
25 | echo "For example:" | 20 | echo "For example:" |
26 | echo "$ bitbake qemu-helper-native" | 21 | echo "$ bitbake qemu-helper-native" |
27 | echo "$ sudo $0 $uid $gid 4" | 22 | echo "$ sudo $0 $gid 4" |
28 | echo "" | 23 | echo "" |
29 | exit 1 | 24 | exit 1 |
30 | } | 25 | } |
31 | 26 | ||
32 | # Allow passing 4 arguments for backward compatibility with warning | 27 | # Allow passing 4 arguments for backward compatibility with warning |
33 | if [ $# -eq 4 ]; then | 28 | if [ $# -gt 4 ]; then |
34 | echo "Warning: The <native-sysroot-basedir> parameter is no longer needed. Ignoring." | 29 | echo "Error: Incorrect number of arguments" |
30 | usage | ||
35 | fi | 31 | fi |
36 | if [ $# -lt 3 ] || [ $# -gt 4 ]; then | 32 | if [ $# -gt 3 ]; then |
33 | echo "Warning: Ignoring the <native-sysroot-basedir> parameter. It is no longer needed." | ||
34 | fi | ||
35 | if [ $# -gt 2 ]; then | ||
36 | echo "Warning: Ignoring the <uid> parameter. It is no longer needed." | ||
37 | GID=$2 | ||
38 | COUNT=$3 | ||
39 | elif [ $# -eq 2 ]; then | ||
40 | GID=$1 | ||
41 | COUNT=$2 | ||
42 | else | ||
37 | echo "Error: Incorrect number of arguments" | 43 | echo "Error: Incorrect number of arguments" |
38 | usage | 44 | usage |
39 | fi | 45 | fi |
40 | 46 | ||
41 | TUID=$1 | ||
42 | GID=$2 | ||
43 | COUNT=$3 | ||
44 | 47 | ||
45 | # check if COUNT is a number and >= 0 | 48 | # check if COUNT is a number and >= 0 |
46 | if ! [ $COUNT -ge 0 ]; then | 49 | if ! [ $COUNT -ge 0 ]; then |
@@ -78,10 +81,10 @@ if [ $COUNT -eq 0 ]; then | |||
78 | exit 0 | 81 | exit 0 |
79 | fi | 82 | fi |
80 | 83 | ||
81 | echo "Creating $COUNT tap devices for UID: $TUID GID: $GID..." | 84 | echo "Creating $COUNT tap devices for GID: $GID..." |
82 | for ((index=0; index < $COUNT; index++)); do | 85 | for ((index=0; index < $COUNT; index++)); do |
83 | echo "Creating tap$index" | 86 | echo "Creating tap$index" |
84 | if ! ifup=`$RUNQEMU_IFUP $TUID $GID 2>&1`; then | 87 | if ! ifup=`$RUNQEMU_IFUP $GID 2>&1`; then |
85 | echo "Error bringing up interface: $ifup" | 88 | echo "Error bringing up interface: $ifup" |
86 | exit 1 | 89 | exit 1 |
87 | fi | 90 | fi |