-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathip_delete_tap
executable file
·56 lines (46 loc) · 1.16 KB
/
ip_delete_tap
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
#!/bin/bash
# $Id: ip_delete_tap 1373 2023-02-16 11:21:26Z mueller $
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright 2023- by Walter F.J. Mueller <[email protected]>
#
# Revision History:
# Date Rev Version Comment
# 2023-02-16 1373 1.0 Initial version
#
# handle options
optdry=""
while (( $# > 0 )) ; do
case $1 in
-dry|--dry) optdry=$1 ; shift 1 ;;
-*) echo "ip_delete_br-E: invalid option '$1'"; exit 1 ;;
*) break;;
esac
done
prefdry=""
if [[ -n "$optdry" ]] ; then
prefdry="echo"
fi
tap=${1:-tap0}
ip link show ${tap} >/dev/null 2>&1
if [ $? != 0 ]
then
echo "ip_delete_tap-I: tap ${tap} doesn't exist"
exit 0
fi
# sanitize PATH, use what sudo has
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
which_ip=$(which ip)
which_brctl=$(which brctl)
if [[ -z "$which_ip" ]]
then
echo "ip_delete_br-E: ip command not in PATH"
exit 1
fi
# print info that sudo password prompt is expected
if [[ $(id -u) -ne 0 ]] ; then echo "ip_delete_br-I: uses sudo" ; fi
$prefdry sudo ip tuntap delete ${tap} mode tap
#
if [[ -n "$which_brctl" ]]
then
$prefdry $which_brctl show ${br}
fi