diff options
Diffstat (limited to 'scripts/runqemu-ifdown')
| -rwxr-xr-x | scripts/runqemu-ifdown | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/scripts/runqemu-ifdown b/scripts/runqemu-ifdown deleted file mode 100755 index 822a2a39b9..0000000000 --- a/scripts/runqemu-ifdown +++ /dev/null | |||
| @@ -1,72 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # QEMU network configuration script to bring down tap devices. This | ||
| 4 | # utility needs to be run as root, and will use the ip utility | ||
| 5 | # | ||
| 6 | # If you find yourself calling this script a lot, you can add the | ||
| 7 | # the following to your /etc/sudoers file to be able to run this | ||
| 8 | # command without entering your password each time: | ||
| 9 | # | ||
| 10 | # <my-username> ALL=NOPASSWD: /path/to/runqemu-ifup | ||
| 11 | # <my-username> ALL=NOPASSWD: /path/to/runqemu-ifdown | ||
| 12 | # | ||
| 13 | # Copyright (c) 2006-2011 Linux Foundation | ||
| 14 | # | ||
| 15 | # SPDX-License-Identifier: GPL-2.0-only | ||
| 16 | # | ||
| 17 | |||
| 18 | usage() { | ||
| 19 | echo "sudo $(basename $0) <tap-dev>" | ||
| 20 | } | ||
| 21 | |||
| 22 | if [ $EUID -ne 0 ]; then | ||
| 23 | echo "Error: This script (runqemu-ifdown) must be run with root privileges" | ||
| 24 | exit 1 | ||
| 25 | fi | ||
| 26 | |||
| 27 | if [ $# -gt 2 ] || [ $# -lt 1 ]; then | ||
| 28 | usage | ||
| 29 | exit 1 | ||
| 30 | fi | ||
| 31 | |||
| 32 | # backward compatibility | ||
| 33 | if [ $# -eq 2 ] ; then | ||
| 34 | echo "Warning: native-sysroot-basedir parameter is ignored. It is no longer needed." >&2 | ||
| 35 | fi | ||
| 36 | |||
| 37 | TAP=$1 | ||
| 38 | |||
| 39 | if ! ip tuntap del $TAP mode tap 2>/dev/null; then | ||
| 40 | echo "Error: Unable to run up tuntap del" | ||
| 41 | exit 1 | ||
| 42 | fi | ||
| 43 | |||
| 44 | IPTOOL=`which ip 2> /dev/null` | ||
| 45 | if [ "x$IPTOOL" = "x" ]; then | ||
| 46 | # better than nothing... | ||
| 47 | IPTOOL=/sbin/ip | ||
| 48 | fi | ||
| 49 | if [ -x "$IPTOOL" ]; then | ||
| 50 | if `$IPTOOL link show $TAP > /dev/null 2>&1`; then | ||
| 51 | $IPTOOL link del $TAP | ||
| 52 | fi | ||
| 53 | fi | ||
| 54 | # cleanup the remaining iptables rules | ||
| 55 | IPTABLES=`which iptables 2> /dev/null` | ||
| 56 | if [ "x$IPTABLES" = "x" ]; then | ||
| 57 | IPTABLES=/sbin/iptables | ||
| 58 | fi | ||
| 59 | if [ ! -x "$IPTABLES" ]; then | ||
| 60 | echo "$IPTABLES cannot be executed" | ||
| 61 | exit 1 | ||
| 62 | fi | ||
| 63 | |||
| 64 | if [ -z "$OE_TAP_NAME" ]; then | ||
| 65 | OE_TAP_NAME=tap | ||
| 66 | fi | ||
| 67 | |||
| 68 | n=$[ (`echo $TAP | sed "s/$OE_TAP_NAME//"` * 2) + 1 ] | ||
| 69 | dest=$[ (`echo $TAP | sed "s/$OE_TAP_NAME//"` * 2) + 2 ] | ||
| 70 | $IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$n/32 | ||
| 71 | $IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$dest/32 | ||
| 72 | true | ||
