Commit 27c11787 authored by Jouke Witteveen's avatar Jouke Witteveen
Browse files

Forking netcfg to netctl (2/2)

This commit contains the refactoring and rewriting of code.
parent 4e457e0e
# netcfg completion
# netctl completion
_netcfg ()
_netctl()
{
local cur prev opts lopts cmds prfls
local cur prev prof
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
prof=$(find -L /etc/network.d -maxdepth 1 -type f -not -name '.*' -not -name '*~' -not -name '*.conf' -not -name '*.service' -printf "%f\n")
opts="-l -c -u -r -R -d -D -a -v -h"
lopts="--help --version"
cmds="list current check-iface up reconnect iface-recon down iface-down all-down all-suspend"
prfls="$(find -L /etc/network.d/ -maxdepth 1 -type f -not -name '*~' -not -name '*.conf' -not -name '.*' -printf '%f\n')"
case "${prev}" in
-R|iface-recon|-D|iface-down)
COMPREPLY=( $( compgen -W "$(ls /run/network/interfaces/)" -- $cur ) )
return 0
;;
-r|reconnect|-d|down)
COMPREPLY=( $( compgen -W "$(ls /run/network/profiles/)" -- $cur ) )
return 0
;;
-c|check-iface|-u|up)
COMPREPLY=( $( compgen -W "${prfls}" -- $cur ) )
return 0
;;
esac
case "${cur}" in
--*)
COMPREPLY=( $( compgen -W "${lopts}" -- $cur ) )
return 0
;;
-*)
COMPREPLY=( $( compgen -W "${opts} ${lopts}" -- $cur ) )
return 0
;;
*)
((COMP_CWORD == 1)) && \
COMPREPLY=( $( compgen -W "${opts} ${lopts} ${cmds} ${prfls}" -- $cur ) )
case $COMP_CWORD in
1)
COMPREPLY=( $(compgen -W "--help --version list store restore stop-all start stop restart switch-to status enable disable reenable" -- $cur) )
;;
2)
case $prev in
start|stop|restart|switch-to|status|enable|disable|reenable)
mapfile -t COMPREPLY < <(IFS=$'\n'; compgen -W "$prof" -- $cur)
;;
esac
;;
*)
COMPREPLY=()
;;
esac
} &&
complete -F _netctl netctl
return 0
}
complete -F _netcfg netcfg
# ex: ts=4 sw=4 et filetype=sh
CONNECTION="bond"
DESCRIPTION='Bond Interface'
INTERFACE='bond0'
IP='static'
ADDR="10.0.0.1"
NETMASK="255.0.0.0"
SLAVE_INTERFACES=("eth0" "eth2")
SKIPNOCARRIER="yes"
Description='Bond Interface'
Interface='bond0'
Connection=bond
BindsToInterfaces=(eth0 eth2)
IP=static
Address="10.0.0.1/8"
INTERFACE="br0"
CONNECTION="bridge"
DESCRIPTION="Example Bridge connection"
BRIDGE_INTERFACES="eth0 eth1 tap0"
IP="dhcp"
Description="Example Bridge connection"
Interface=br0
Connection=bridge
BindsToInterfaces=(eth0 eth1 tap0)
IP=dhcp
## sets forward delay time
#FWD_DELAY=0
#FWDDelay=0
## sets max age of hello message
#MAX_AGE=10
#MaxAge=10
CONNECTION='ethernet'
DESCRIPTION='A basic dhcp ethernet connection using iproute'
INTERFACE='eth0'
IP='dhcp'
Description='A basic dhcp ethernet connection using iproute'
Interface=eth0
Connection=ethernet
IP=dhcp
## for DHCPv6
#IP6='dhcp'
#IP6=dhcp
## for IPv6 autoconfiguration
#IP6='stateless'
#IP6=stateless
CONNECTION='ethernet'
DESCRIPTION='A more versatile static ethernet connection using iproute'
INTERFACE='eth0'
IP='static'
Description='A more versatile static ethernet connection using iproute'
Interface=eth0
Connection=ethernet
IP=static
# Any valid iproute command can be placed in this array
IPCFG=('addr add dev eth0 192.168.1.23/24 brd +' 'route add default via 192.168.1.1')
IPCustom=('addr add dev eth0 192.168.1.23/24 brd +' 'route add default via 192.168.1.1')
DNS=('192.168.1.1')
CONNECTION='ethernet'
DESCRIPTION='A basic static ethernet connection using iproute'
INTERFACE='eth0'
IP='static'
ADDR='192.168.1.23'
#ROUTES=('192.168.0.0/24 via 192.168.1.2')
GATEWAY='192.168.1.1'
Description='A basic static ethernet connection using iproute'
Interface=eth0
Connection=ethernet
IP=static
Address='192.168.1.23'
#Routes=('192.168.0.0/24 via 192.168.1.2')
Gateway='192.168.1.1'
DNS=('192.168.1.1')
## For IPv6 autoconfiguration
#IP6=stateless
## For IPv6 static address configuration
#IP6='static'
#ADDR6=('1234:5678:9abc:def::1/64' '1234:3456::123/96')
#ROUTES6=('abcd::1234')
#GATEWAY6='1234:0:123::abcd'
#IP6=static
#Address6=('1234:5678:9abc:def::1/64' '1234:3456::123/96')
#Routes6=('abcd::1234')
#Gateway6='1234:0:123::abcd'
CONNECTION='pppoe'
DESCRIPTION='Example PPPoE connection'
INTERFACE='eth0'
USER='example@yourprovider.com'
PASSWORD='very secret'
Description='Example PPPoE connection'
Interface=eth0
Connection=pppoe
User='example@yourprovider.com'
Password='very secret'
# Always keep a connection established
CONNECTION_MODE='persist'
ConnectionMode='persist'
# Establish connection on demand
#CONNECTION_MODE='demand'
#IDLE_TIMEOUT=300
#ConnectionMode='demand'
#IdleTimeout=300
# Use default route provided by the peer (default: true)
#DEFAULTROUTE=1
#DefaultRoute=true
# Use DNS provided by the peer (default: true)
#USEPEERDNS=1
#UsePeerDNS=true
# Override default LCP parameters from /etc/ppp/options
#LCP_ECHO_INTERVAL=15
#LCP_ECHO_FAILURE=10
#LCPEchoInterval=15
#LCPEchoFailure=10
# PPPoE options - experts only
#
# PPPoE service name
#PPPOE_SERVICE=''
#PPPoEService=''
# PPPoE access concentrator name
#PPPOE_AC=''
#PPPoEAC=''
# Attach to existing session (sessid:macaddr)
#PPPOE_SESSION=''
#PPPoESession=''
# Only connect to specified MAC address
#PPPOE_MAC=''
#PPPoEMAC=''
# Enable IPv6 support
#PPPOE_IP6='yes'
#PPPoEIP6=yes
CONNECTION='tunnel'
DESCRIPTION='An example ipv6 tunnel with Hurricane Electric'
Description='An example ipv6 tunnel with Hurricane Electric'
Interface=he-ipv6
Connection=tunnel
Mode='sit'
Remote='216.66.80.26'
#Local='172.16.0.1'
INTERFACE='he-ipv6'
MODE='sit'
REMOTE='216.66.80.26'
#LOCAL='172.16.0.1'
IP6='static'
ADDR6='2001:470:1f08:d87::2/64'
ROUTES6=('::/0')
IP6=static
Address6='2001:470:1f08:d87::2/64'
Routes6=('::/0')
INTERFACE='tun0'
CONNECTION='tuntap'
MODE='tun'
USER='nobody'
GROUP='nobody'
Interface=tun0
Connection=tuntap
Mode='tun'
User='nobody'
Group='nobody'
## Example IP configuration
#IP='static'
#SKIPNOCARRIER='yes'
#ADDR='10.10.1.2'
#IP=static
#Address='10.10.1.2'
INTERFACE="eth0.55"
VLAN_PHYS_DEV="eth0"
VLAN_ID="55"
CONNECTION="vlan"
IP="dhcp"
Interface=eth0.55
Connection=vlan
# The variable name is plural, but needs precisely one interface
BindsToInterfaces=eth0
VLANID=55
IP=dhcp
INTERFACE="eth0.11"
VLAN_PHYS_DEV="eth0"
VLAN_ID="11"
CONNECTION="vlan"
IP="static"
ADDR="192.168.0.100"
NETMASK="255.255.255.0"
GATEWAY="192.168.0.1"
Interface=eth0.11
Connection=vlan
# The variable name is plural, but needs precisely one interface
BindsToInterfaces=eth0
VLANID=11
IP=static
Address="192.168.0.100/24"
Gateway="192.168.0.1"
DNS=("192.168.0.2")
HOSTNAME="myhost"
DOMAIN="mydomain.com"
SEARCH="mydomain.com"
Hostname="myhost"
DNSDomain="mydomain.com"
DNSSearch="mydomain.com"
CONNECTION='wireless'
DESCRIPTION='A simple opened wireless connection'
INTERFACE='wlan0'
SECURITY='none'
Description='A simple opened wireless connection'
Interface=wlan0
Connection=wireless
Security=none
ESSID='MyNetwork'
IP='dhcp'
# Uncomment this if your ssid is hidden
#HIDDEN=yes
#Hidden=yes
CONNECTION='wireless'
DESCRIPTION='A simple WEP encrypted wireless connection'
INTERFACE='wlan0'
SECURITY='wep'
Description='A simple WEP encrypted wireless connection'
Interface=wlan0
Connection=wireless
Security=wep
ESSID='MyNetwork'
KEY='1234567890'
# Prepend hexadecimal keys with \"
Key=\"1234567890abcdef
IP='dhcp'
# Uncomment this if your ssid is hidden
#HIDDEN=yes
## Uncomment if you are using an ad-hoc connection
#ADHOC=1
#Hidden=yes
# Uncomment if you are using an ad-hoc connection
#AdHoc=yes
CONNECTION='wireless'
DESCRIPTION='A simple WEP encrypted wireless connection'
INTERFACE='wlan0'
SECURITY='wep'
Description='A simple WEP encrypted wireless connection'
Interface=wlan0
Connection=wireless
Security=wep
ESSID='MyNetwork'
KEY='s:Wireless Key'
Key='Wireless Key'
IP='dhcp'
# Uncomment this if your ssid is hidden
#HIDDEN=yes
#Hidden=yes
CONNECTION='wireless'
DESCRIPTION='A simple WPA encrypted wireless connection'
INTERFACE='wlan0'
SECURITY='wpa'
Description='A simple WPA encrypted wireless connection'
Interface=wlan0
Connection=wireless
Security=wpa
ESSID='MyNetwork'
## Uncomment if the supplied ESSID is hexadecimal
#ESSID_TYPE='hex'
KEY='WirelessKey'
# Prepend hexadecimal keys with \"
# If your key starts with ", write it as '"""<key>"'
Key='WirelessKey'
IP='dhcp'
# Uncomment this if your ssid is hidden
#HIDDEN=yes
#Hidden=yes
CONNECTION='wireless'
DESCRIPTION='A wpa_supplicant configuration based wireless connection'
INTERFACE='wlan0'
SECURITY='wpa-config'
WPA_CONF='/etc/wpa_supplicant.conf'
Description='A wpa_supplicant configuration based wireless connection'
Interface=wlan0
Connection=wireless
Security=wpa-config
WPAConfigFile='/etc/wpa_supplicant.conf'
IP='dhcp'
# Uncomment this if your ssid is hidden
#HIDDEN=yes
#Hidden=yes
CONNECTION='wireless'
INTERFACE=wlan0
SECURITY='wpa-configsection'
Interface=wlan0
Connection=wireless
Security=wpa-configsection
# Uncomment this if your ssid is hidden
#HIDDEN=yes
#Hidden=yes
IP='dhcp'
CONFIGSECTION='
ssid="University"
key_mgmt=WPA-EAP
eap=TTLS
group=TKIP
pairwise=TKIP CCMP
anonymous_identity="anonymous"
identity="myusername"
password="mypassword"
priority=1
phase2="auth=PAP"'
WPAConfigSection=(
'ssid="University"'
'key_mgmt=WPA-EAP'
'eap=TTLS'
'group=TKIP'
'pairwise=TKIP CCMP'
'anonymous_identity="anonymous"'
'identity="myusername"'
'password="mypassword"'
'priority=1'
'phase2="auth=PAP"'
)
CONNECTION='wireless'
DESCRIPTION='A simple WPA encrypted wireless connection using a static IP'
INTERFACE='wlan0'
SECURITY='wpa'
Description='A simple WPA encrypted wireless connection using a static IP'
Interface=wlan0
Connection=wireless
Security=wpa
ESSID='MyNetwork'
KEY='WirelessKey'
IP='static' # Any other CONNECTION='ethernet' options may be used.
ADDR='192.168.1.23'
GATEWAY='192.168.1.1'
Key='WirelessKey'
IP=static
Address='192.168.1.23'
Gateway='192.168.1.1'
DNS=('192.168.1.1')
# Uncomment this if your ssid is hidden
#HIDDEN=yes
#Hidden=yes
NETCFG(8)
NETCTL(1)
=========
NAME
----
netcfg - start/stop/control network profiles
netctl - Control the netctl network profile manager
SYNOPSIS
--------
netcfg [_options_]
*netctl* {*COMMAND*} [+PROFILE+]
netcfg *profile*
*netctl* [--help | --version]
DESCRIPTION
-----------
*netcfg* is used to configure and manage network connections via
profiles. It has pluggable support for a range of connection types, such
as wireless, ethernet, ppp. It is also capable of starting/stopping many
to one connections, that is, multiple connections within the same
profile, optionally with bonding.
It may be run at boot, by enabling the 'netcfg' systemd service, or, on
legacy systems, by adding 'net-profiles' to +DAEMONS+ in '/etc/rc.conf'.
After boot time, it may be used to start profiles, simply by passing only
the profile name.
When run without options, `netcfg profile` is equivalent to `netcfg -u
profile`.
*netctl* may be used to introspect and control the state of the systemd
services for the network profile manager.
OPTIONS
-------
*-l, list*::
List all available profiles
*current*::
Report currently running profiles
*-c, check-iface* _profile_::
Start the specified profile, only if it's interface is not currently up.
*-u, up* _profile_::
Start the specified profile
*-r, reconnect* _profile_::
Disconnect and reconnect the specified profile
*-R, iface-recon* _interface_::
Reconnect profile active on specified interface
*-d, down* _profile_::
Stop the specified profile
*-D, iface-down* _interface_::
Stop the profile up on the specified interface.
*-a, all-down*::
Stop all connected profiles
*all-suspend*::
Suspend and store the name of all active profiles.
*all-resume*::
Reconnect any profiles that have been suspended.
*-v, --version*::
Display version information and exit
*-h, --help*::
Display help message and exit
CONFIGURATION FILES
-------------------
'/etc/conf.d/netcfg'::
Parameters for startup.
'/etc/network.d/'::
User-defined profiles.
FILES
-----
'/usr/lib/network/connections/'::
Currently installed network profile types.
'/etc/network.d/examples/'::
Example profiles.
'/usr/share/doc/netcfg/contrib/'::
Inspirational scripts.
ENVIRONMENT VARIABLES
---------------------
+NETCFG_DEBUG+::
Set to 1 to activate debug output.
The following commands are understood:
*list*::
List all available profiles. Active profiles will be marked with a
`*'.
*store*::
Saves which profiles are currently active.
*restore*::
Loads the profiles that were active during the last invocation of
`*store*'.
*stop-all*::
Stops all active network profiles.
*start [+PROFILE+]*::
Start the network profile specified on the command line.
*stop [+PROFILE+]*::
Stop the network profile specified on the command line.
*restart [+PROFILE+]*::
Restart the network profile specified on the command line. If it is
not started yet, it will be started.
*switch-to [+PROFILE+]*::
Starts the network profile specified on the command line after
stopping all profiles that refer to the same interface.
*status [+PROFILE+]*::
Show terse runtime status information about a profile, followed by
its most recent log data from the journal.
*enable [+PROFILE+]*::
Enable the systemd unit for the profile specified. This will create
a unit configuration file. If the file already exists, the command
fails. No other profiles than the one specified will be enabled.
Changes to the general options in a profile specification will not
propagate to the unit configuration file automatically. After such
changes, it is necessary to `*reenable*' the profile.
*disable [+PROFILE+]*::
Disable the systemd unit for the profile specified. This will remove
the file created by `*enable*' even if it was customized, so be
carefull.
*reenable [+PROFILE+]*::
Reenable the systemd unit for the profile specified. This is
effectively a combination of `*disable*' and `*enable*'.
EXIT STATUS
-----------
On success 0 is returned, a non-zero failure code otherwise.
ENVIRONMENT
-----------
'$NETCTL_DEBUG'::
If set to `"yes"`, debugging output is generated.
'$NETCTL_STATE_FILE'::
The location of the state file. Defaults to
'/var/lib/netctl/netctl.state'.
SEE ALSO
--------
*netcfg-profiles*(5) on how to configure netcfg.
include::footer.txt[]
*netctl.profile*(5) *netctl.special*(7) *systemctl*(1)
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment