mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Fix bash completion for sudo users (mostly cosmetic) + man page and
example fixes Ticket: CM-2911 Reviewed By: CCR-1637 Testing Done: tested ifupdown2 sanity and bash completion The python argcomplete module that i use for ifupdown2 has a limitation that it does not work with sudo when used in the global mode. But there is a workaround for it online (long story short...instead of enabling the global argparse complete ...the author recommends registering argparse complete bash completion individually for your script). This patch does just that. This patch also moves the udev overrides to their respective packages. Two of them are owned by ifupdown2. Conflicts: rootconf/default/home/cumulus/sysroot-complete
This commit is contained in:
9
completion/ifup
Normal file
9
completion/ifup
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
_python_argcomplete() {
|
||||||
|
local IFS=''
|
||||||
|
COMPREPLY=( $(IFS="$IFS" COMP_LINE="$COMP_LINE" COMP_POINT="$COMP_POINT" _ARGCOMPLETE_COMP_WORDBREAKS="$COMP_WORDBREAKS" _ARGCOMPLETE=1 "$1" 8>&1 9>&2 1>/dev/null 2>/dev/null) )
|
||||||
|
if [[ $? != 0 ]]; then
|
||||||
|
unset COMPREPLY
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
complete -F _python_argcomplete ifup ifdown ifquery ifreload
|
16
debian/python-ifupdown2.postinst
vendored
16
debian/python-ifupdown2.postinst
vendored
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
MYNAME="${0##*/}"
|
MYNAME="${0##*/}"
|
||||||
@@ -70,6 +70,20 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# override default udev bridge and hotplug rules because they interfere with
|
||||||
|
# networking init script
|
||||||
|
udev_user_rulesdir=/etc/udev/rules.d/
|
||||||
|
udev_sys_rulesdir=/lib/udev/rules.d/
|
||||||
|
if [ -e $udev_user_rulesdir ]; then
|
||||||
|
udev_ifupdown2_overrides=("80-networking.rules" "60-bridge-network-interface.rules")
|
||||||
|
for u in ${udev_ifupdown2_overrides[*]}
|
||||||
|
do
|
||||||
|
if [ -e ${udev_sys_rulesdir}/$u -a ! -e ${udev_user_rulesdir}/$u ]; then
|
||||||
|
(cd ${udev_user_rulesdir} && ln -sf /dev/null $u)
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -x "/etc/init.d/networking" ]; then
|
if [ -x "/etc/init.d/networking" ]; then
|
||||||
update-rc.d networking start 40 S . start 35 0 6 . >/dev/null || exit $?
|
update-rc.d networking start 40 S . start 35 0 6 . >/dev/null || exit $?
|
||||||
fi
|
fi
|
||||||
|
9
debian/python-ifupdown2.postrm
vendored
9
debian/python-ifupdown2.postrm
vendored
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ rm -f /sbin/ifup /sbin/ifdown /sbin/ifquery
|
|||||||
case "$1" in
|
case "$1" in
|
||||||
purge)
|
purge)
|
||||||
# Note: We don't remove /etc/network/interfaces
|
# Note: We don't remove /etc/network/interfaces
|
||||||
rm -f /etc/network/run/ifstate
|
rm -f /var/tmp/network/ifstatenew
|
||||||
|
|
||||||
if [ -L /etc/network/run ] ; then
|
if [ -L /etc/network/run ] ; then
|
||||||
rm -f /etc/network/run
|
rm -f /etc/network/run
|
||||||
@@ -17,6 +17,11 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
udevlink=$(readlink /etc/udev/rules.d/80-networking.rules 2>/dev/null)
|
||||||
|
[ -n "$udevlink" -a "$udevlink" == "/dev/null" ] && rm -f /etc/udev/rules.d/80-networking.rules
|
||||||
|
udevlink=$(readlink /etc/udev/rules.d/60-bridge-network-interface.rules 2>/dev/null)
|
||||||
|
[ -n "$udevlink" -a "$udevlink" == "/dev/null" ] && rm -f /etc/udev/rules.d/60-bridge-network-interface.rules
|
||||||
|
|
||||||
if [ "$1" = "purge" ] ; then
|
if [ "$1" = "purge" ] ; then
|
||||||
update-rc.d networking remove >/dev/null
|
update-rc.d networking remove >/dev/null
|
||||||
fi
|
fi
|
||||||
|
@@ -11,6 +11,19 @@ iface eth0 inet dhcp
|
|||||||
|
|
||||||
#source /etc/network/interfaces.d/template.bridges
|
#source /etc/network/interfaces.d/template.bridges
|
||||||
|
|
||||||
|
# swp interface
|
||||||
|
auto swp30
|
||||||
|
iface swp30
|
||||||
|
address 12.0.0.4/24
|
||||||
|
address 12.0.0.6/24
|
||||||
|
address 2000:1000:1000:1000:3::5/128
|
||||||
|
mtu 1600
|
||||||
|
alias "test network"
|
||||||
|
duplex full
|
||||||
|
autoneg on
|
||||||
|
speed 1000
|
||||||
|
|
||||||
|
# bond interface
|
||||||
auto bond3
|
auto bond3
|
||||||
iface bond3 inet static
|
iface bond3 inet static
|
||||||
address 100.0.0.4/16
|
address 100.0.0.4/16
|
||||||
@@ -22,6 +35,7 @@ iface bond3 inet static
|
|||||||
bond-min-links 1
|
bond-min-links 1
|
||||||
bond-xmit_hash_policy layer3+4
|
bond-xmit_hash_policy layer3+4
|
||||||
|
|
||||||
|
# bond interface
|
||||||
auto bond4
|
auto bond4
|
||||||
iface bond4 inet static
|
iface bond4 inet static
|
||||||
address 100.0.0.6/16
|
address 100.0.0.6/16
|
||||||
@@ -33,14 +47,16 @@ iface bond4 inet static
|
|||||||
bond-min-links 1
|
bond-min-links 1
|
||||||
bond-xmit_hash_policy layer3+4
|
bond-xmit_hash_policy layer3+4
|
||||||
|
|
||||||
|
# bond interface
|
||||||
auto br0
|
auto br0
|
||||||
iface br0
|
iface br0
|
||||||
address 12.0.0.4/24
|
address 12.0.0.4/24
|
||||||
address 12.0.0.6/24
|
address 12.0.0.6/24
|
||||||
address6 2000:1000:1000:1000:3::5/128
|
address 2000:1000:1000:1000:3::5/128
|
||||||
mstpctl_ports bond3 bond4 swp5 swp8
|
bridge-ports bond3 bond4 swp5 swp8
|
||||||
mstpctl_stp on
|
bridge-stp on
|
||||||
|
|
||||||
|
# vlan interface on bond
|
||||||
auto bond3.2000
|
auto bond3.2000
|
||||||
iface bond3.2000 inet static
|
iface bond3.2000 inet static
|
||||||
address 100.1.0.4/16
|
address 100.1.0.4/16
|
||||||
@@ -51,7 +67,8 @@ iface bond4.2000 inet static
|
|||||||
|
|
||||||
auto br2000
|
auto br2000
|
||||||
iface br2000 inet6 static
|
iface br2000 inet6 static
|
||||||
address6 2001:dad:beef::4/64
|
address 2001:dad:beef::4/64
|
||||||
mstpctl_ports bond3.2000 bond4.2000 swp5.2000
|
bridge-ports bond3.2000 bond4.2000 swp5.2000
|
||||||
mstpctl_treeprio 61440
|
bridge-stp on
|
||||||
mstpctl_stp on
|
mstpctl-treeprio 61440
|
||||||
|
mstpctl-portp2p bond3.2000=yes bond4.2000=yes
|
||||||
|
@@ -6,16 +6,12 @@ ifquery
|
|||||||
query network interface configuration
|
query network interface configuration
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
|
||||||
:Author: roopa@cumulusnetworks.com
|
:Author: Roopa Prabhu <roopa@cumulusnetworks.com>
|
||||||
:Date: 2014-02-05
|
:Date: 2014-02-05
|
||||||
:Copyright: Copyright 2014 Cumulus Networks, Inc. All rights reserved.
|
:Copyright: Copyright 2014 Cumulus Networks, Inc. All rights reserved.
|
||||||
:Version: 0.1
|
:Version: 0.1
|
||||||
:Manual section: 8
|
:Manual section: 8
|
||||||
|
|
||||||
NAME
|
|
||||||
====
|
|
||||||
**ifquery** - query interface configuration
|
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
========
|
========
|
||||||
|
|
||||||
@@ -36,7 +32,8 @@ DESCRIPTION
|
|||||||
in **/etc/network/interfaces** file.
|
in **/etc/network/interfaces** file.
|
||||||
|
|
||||||
**ifquery** always works on the current **interfaces(5)** file
|
**ifquery** always works on the current **interfaces(5)** file
|
||||||
**/etc/network/interfaces**.
|
**/etc/network/interfaces** unless an alternate interfaces file is
|
||||||
|
provided with the **-i** option.
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
=======
|
=======
|
||||||
@@ -65,13 +62,24 @@ OPTIONS
|
|||||||
Exclude interfaces from the list of interfaces to
|
Exclude interfaces from the list of interfaces to
|
||||||
operate on. Can be specified multiple times
|
operate on. Can be specified multiple times
|
||||||
|
|
||||||
|
-i INTERFACESFILE, --interfaces INTERFACESFILE
|
||||||
|
Use interfaces file instead of default
|
||||||
|
/etc/network/interfaces
|
||||||
|
|
||||||
-r, --running print raw interfaces file entries
|
-r, --running print raw interfaces file entries
|
||||||
|
|
||||||
-c, --check check interface file contents against running state
|
-c, --check check interface file contents against running state
|
||||||
of an interface. Returns exit code 0 on success and
|
of an interface. Returns exit code 0 on success and
|
||||||
1 on error
|
1 on error
|
||||||
|
|
||||||
-p, --print-dependency {list,dot} print iface dependency in list or dot format
|
-x, --raw print raw config file entries
|
||||||
|
|
||||||
|
|
||||||
|
-o {native,json}, --format {native,json}
|
||||||
|
interface display format
|
||||||
|
|
||||||
|
-p, --print-dependency {list,dot}
|
||||||
|
print iface dependency in list or dot format
|
||||||
|
|
||||||
-s, --syntax-help print supported interface config syntax. Scans all
|
-s, --syntax-help print supported interface config syntax. Scans all
|
||||||
addon modules and dumps supported syntax from them
|
addon modules and dumps supported syntax from them
|
||||||
|
@@ -6,7 +6,7 @@ ifup
|
|||||||
network interface management commands
|
network interface management commands
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
|
||||||
:Author: roopa@cumulusnetworks.com
|
:Author: Roopa Prabhu <roopa@cumulusnetworks.com>
|
||||||
:Date: 2014-02-05
|
:Date: 2014-02-05
|
||||||
:Copyright: Copyright 2014 Cumulus Networks, Inc. All rights reserved.
|
:Copyright: Copyright 2014 Cumulus Networks, Inc. All rights reserved.
|
||||||
:Version: 0.1
|
:Version: 0.1
|
||||||
@@ -85,10 +85,19 @@ OPTIONS
|
|||||||
|
|
||||||
-n, --no-act print out what would happen,but don't do it
|
-n, --no-act print out what would happen,but don't do it
|
||||||
|
|
||||||
-p, --print-dependency {list,dot} print iface dependency in list or dot format.
|
-p, --print-dependency {list,dot}
|
||||||
|
print iface dependency in list or dot format
|
||||||
|
|
||||||
--no-scripts, --no-addons dont run any addon modules/scripts. Only bring
|
-m, --admin-state, --no-scripts
|
||||||
the interface administratively up/down
|
dont run any addon modules/scripts. Only bring
|
||||||
|
the interface administratively up/down
|
||||||
|
|
||||||
|
-u, --use-current-config
|
||||||
|
By default ifdown looks at the saved state for
|
||||||
|
interfaces to bring down. This option allows ifdown
|
||||||
|
to look at the current interfaces file. Useful when
|
||||||
|
your state file is corrupted or you want down to use
|
||||||
|
the latest from the interfaces file
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
========
|
========
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# PYTHON_ARGCOMPLETE_OK
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
@@ -231,7 +230,7 @@ def update_ifup_argparser(argparser):
|
|||||||
|
|
||||||
def update_ifdown_argparser(argparser):
|
def update_ifdown_argparser(argparser):
|
||||||
update_ifupdown_argparser(argparser)
|
update_ifupdown_argparser(argparser)
|
||||||
argparser.add_argument('--use-current-config',
|
argparser.add_argument('-u', '--use-current-config',
|
||||||
dest='usecurrentconfig', action='store_true',
|
dest='usecurrentconfig', action='store_true',
|
||||||
help='By default ifdown looks at the saved state for ' +
|
help='By default ifdown looks at the saved state for ' +
|
||||||
'interfaces to bring down. This option allows ifdown to ' +
|
'interfaces to bring down. This option allows ifdown to ' +
|
||||||
@@ -253,12 +252,12 @@ def update_ifquery_argparser(argparser):
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
help='check interface file contents against ' +
|
help='check interface file contents against ' +
|
||||||
'running state of an interface')
|
'running state of an interface')
|
||||||
group.add_argument('--raw', action='store_true', dest='raw',
|
group.add_argument(-x', '--raw', action='store_true', dest='raw',
|
||||||
help='print raw config file entries')
|
help='print raw config file entries')
|
||||||
group.add_argument('--print-savedstate', action='store_true',
|
group.add_argument('--print-savedstate', action='store_true',
|
||||||
dest='printsavedstate',
|
dest='printsavedstate',
|
||||||
help=argparse.SUPPRESS)
|
help=argparse.SUPPRESS)
|
||||||
argparser.add_argument('-m', '--format', dest='format', default='native',
|
argparser.add_argument('-o', '--format', dest='format', default='native',
|
||||||
choices=['native', 'json'],
|
choices=['native', 'json'],
|
||||||
help='interface display format')
|
help='interface display format')
|
||||||
argparser.add_argument('-p', '--print-dependency',
|
argparser.add_argument('-p', '--print-dependency',
|
||||||
@@ -296,7 +295,7 @@ def update_ifreload_argparser(argparser):
|
|||||||
# default='/etc/network/interfaces',
|
# default='/etc/network/interfaces',
|
||||||
# help='use interfaces file instead of default ' +
|
# help='use interfaces file instead of default ' +
|
||||||
# '/etc/network/interfaces')
|
# '/etc/network/interfaces')
|
||||||
argparser.add_argument('--use-current-config',
|
argparser.add_argument('-u', '--use-current-config',
|
||||||
dest='usecurrentconfig', action='store_true',
|
dest='usecurrentconfig', action='store_true',
|
||||||
help='By default ifreload looks at saved state for ' +
|
help='By default ifreload looks at saved state for ' +
|
||||||
'interfaces to bring down. With this option ifreload will'
|
'interfaces to bring down. With this option ifreload will'
|
||||||
@@ -378,6 +377,15 @@ def main(argv):
|
|||||||
args = parse_args(argv[1:], op)
|
args = parse_args(argv[1:], op)
|
||||||
if not validate_args(op, args):
|
if not validate_args(op, args):
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
if not sys.argv[0].endswith('ifquery') and not os.geteuid() == 0:
|
||||||
|
print 'error: must be root to run this command'
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
if not sys.argv[0].endswith('ifquery') and not utils.lockFile(lockfile):
|
||||||
|
print 'Another instance of this program is already running.'
|
||||||
|
exit(0)
|
||||||
|
|
||||||
read_config()
|
read_config()
|
||||||
init(args)
|
init(args)
|
||||||
handlers.get(op)(args)
|
handlers.get(op)(args)
|
||||||
@@ -399,13 +407,6 @@ def main(argv):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
if not sys.argv[0].endswith('ifquery') and not os.geteuid() == 0:
|
|
||||||
print 'error: must be root to run this command'
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
if not utils.lockFile(lockfile):
|
|
||||||
print 'Another instance of this program is already running.'
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
# required during boot
|
# required during boot
|
||||||
os.putenv('PATH', ENVPATH)
|
os.putenv('PATH', ENVPATH)
|
||||||
|
3
setup.py
3
setup.py
@@ -24,5 +24,6 @@ setup(name='ifupdown2',
|
|||||||
('/usr/share/doc/python-ifupdown2/examples/',
|
('/usr/share/doc/python-ifupdown2/examples/',
|
||||||
['docs/examples/interfaces',
|
['docs/examples/interfaces',
|
||||||
'docs/examples/interfaces_bridge_template_func',
|
'docs/examples/interfaces_bridge_template_func',
|
||||||
'docs/examples/interfaces_with_template'])]
|
'docs/examples/interfaces_with_template']),
|
||||||
|
('/etc/bash_completion.d/', ['completion/ifup'])]
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user