Commit 4e457e0e authored by Jouke Witteveen's avatar Jouke Witteveen
Browse files

Forking netcfg to netctl (1/2)

This commit contains the moving of files.
parent 6737a37e
Copyright (c) 2007, James Rayner
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the Arch Linux nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
export VERSION = 3.1
export VERSION = 0.1
.PHONY: install install-docs docs tarball pkgbuild upload clean
.PHONY: install install-docs docs tarball pkgbuild clean
install: install-docs
# Configuration files
install -d $(DESTDIR)/etc/network.d/{examples,interfaces}
install -Dm644 config/netcfg $(DESTDIR)/etc/conf.d/netcfg
install -m644 config/iftab $(DESTDIR)/etc/iftab
install -d $(DESTDIR)/etc/network.d/{examples,hooks,interfaces}
install -m644 docs/examples/* $(DESTDIR)/etc/network.d/examples/
# Libs
install -d $(DESTDIR)/usr/lib/network/{connections,hooks}
install -m644 src/{network,rfkill,8021x,globals} $(DESTDIR)/usr/lib/network/
install -m755 src/connections/* $(DESTDIR)/usr/lib/network/connections/
# Hooks
install -m755 src/hooks/* $(DESTDIR)/usr/lib/network/hooks/
install -d $(DESTDIR)/usr/lib/network/connections
install -m644 src/lib/{8021x,globals,ip,rfkill} $(DESTDIR)/usr/lib/network/
install -m644 src/lib/connections/* $(DESTDIR)/usr/lib/network/connections/
install -m755 src/lib/{auto.action,network} $(DESTDIR)/usr/lib/network/
# Scripts
install -d $(DESTDIR)/usr/bin
install -m755 \
scripts/netcfg \
scripts/netcfg-daemon \
scripts/netcfg-menu \
scripts/netcfg-wpa_actiond \
scripts/netcfg-wpa_actiond-action \
scripts/wifi-menu \
src/netctl \
src/netctl-auto \
src/wifi-menu \
$(DESTDIR)/usr/bin/
install -Dm755 scripts/ifplugd.action $(DESTDIR)/etc/ifplugd/netcfg.action
install -Dm755 scripts/pm-utils $(DESTDIR)/usr/lib/pm-utils/sleep.d/50netcfg
# Daemons
install -Dm755 rc.d/net-set-variable $(DESTDIR)/etc/rc.d/functions.d/net-set-variable
install -m755 \
rc.d/net-profiles \
rc.d/net-rename \
rc.d/net-auto-wired \
rc.d/net-auto-wireless \
$(DESTDIR)/etc/rc.d/
install -Dm755 src/ifplugd.action $(DESTDIR)/etc/ifplugd/netctl.action
# Services
install -d $(DESTDIR)/usr/lib/systemd/system
install -m644 \
systemd/*.service \
$(DESTDIR)/usr/lib/systemd/system/
install -m644 services/*.service $(DESTDIR)/usr/lib/systemd/system/
install-docs: docs
install -d $(DESTDIR)/usr/share/man/{man5,man8}
install -d $(DESTDIR)/usr/share/man/{man1,man5,man7}
install -m644 docs/*.1 $(DESTDIR)/usr/share/man/man1/
install -m644 docs/*.5 $(DESTDIR)/usr/share/man/man5/
install -m644 docs/*.8 $(DESTDIR)/usr/share/man/man8/
install -d $(DESTDIR)/usr/share/doc/netcfg/contrib
install -m644 contrib/{*.hook,pm-utils.handler} $(DESTDIR)/usr/share/doc/netcfg/contrib/
install -m644 docs/*.7 $(DESTDIR)/usr/share/man/man7/
docs:
$(MAKE) -C $@
tarball: netcfg-$(VERSION).tar.xz
netcfg-$(VERSION).tar.xz: | docs
cp scripts/netcfg{,.orig}
sed -i "s/NETCFG_VER=.*/NETCFG_VER=$(VERSION)/" scripts/netcfg
tarball: netctl-$(VERSION).tar.xz
netctl-$(VERSION).tar.xz: | docs
cp src/netctl{,.orig}
sed -i "s/NETCTL_VERSION=.*/NETCTL_VERSION=$(VERSION)/" src/netctl
git stash save -q
git archive -o netcfg-$(VERSION).tar --prefix=netcfg-$(VERSION)/ stash
git archive -o netctl-$(VERSION).tar --prefix=netctl-$(VERSION)/ stash
git stash pop -q
mv scripts/netcfg{.orig,}
tar --exclude-vcs --transform "s%^%netcfg-$(VERSION)/%" --owner=root --group=root --mtime=./netcfg-$(VERSION).tar -rf netcfg-$(VERSION).tar docs/*.[1-8]
xz netcfg-$(VERSION).tar
mv src/netctl{.orig,}
tar --exclude-vcs --transform "s%^%netctl-$(VERSION)/%" --owner=root --group=root --mtime=./netctl-$(VERSION).tar -rf netctl-$(VERSION).tar docs/*.[1-8]
xz netctl-$(VERSION).tar
pkgbuild: PKGBUILD
PKGBUILD: netcfg-$(VERSION).tar.xz
PKGBUILD: netctl-$(VERSION).tar.xz
sed -e "s/%pkgver%/$(VERSION)/" -e "s/%md5sum%/$(shell md5sum $< | cut -d ' ' -f 1)/" contrib/PKGBUILD > $@
upload: netcfg-$(VERSION).tar.xz
md5sum $< > MD5SUMS.$(VERSION)
scp $< MD5SUMS.$(VERSION) gerolde.archlinux.org:/srv/ftp/other/netcfg/
clean:
$(MAKE) -C docs clean
-@rm -vf PKGBUILD *.xz MD5SUMS.* 2>/dev/null
-@rm -vf PKGBUILD *.xz 2>/dev/null
version 3.1
- reword systemd service descriptions
- fix support for 'last' when using systemd
- fix support for 'options' in /etc/resolv.conf
version 3.0
- drop a version number digit
- add support for 'options' in /etc/resolv.conf
- update rfkill implementation
- fix bond connections (FS#31770)
- assorted fixes
version 2.8.11
- add IPv6 support for PPPoE connections
- use a workound for a unit stopping bug in systemd
version 2.8.10
- allow hex passphrases in wifi-menu
- ifplugd path change for net-auto-wired (FS#31340)
version 2.8.9
- add priority support to net-auto-wireless (FS#30737)
- fix wifi-menu key handling (FS#31057)
- add systemd net-profiles symlink for compatibility
version 2.8.8
- fix killing wpa_actiond (FS#30664)
- fix tuntap without an IP (FS#30638)
version 2.8.7
- Fixed parsing of GROUP= part of ctrl_interface for custom wifi configurations
version 2.8.6
- Fixed key limitation test in wifi-menu
- Improved responsiveness for wireless networking
- Revised logic for wpa_supplicant configurations with non-standard control paths
- Code cleanup
version 2.8.5
- Provide the ability to start the last used profile (FS#23015)
- Support weird characters in wifi-menu (FS#30342) and elsewhere
- Fix net-auto-wired.service (FS#30348)
- Introduce polling timeout logic
- Increase default carrier timeout (FS#30361)
version 2.8.4
- fixed wait for wifi scan results (FS#29946)
- PPPoE default to noauth (FS#30016)
- stop waiting longer than necessary when bringing an interface up
version 2.8.3
- Duplicate Address Detection is dealt with for IPv6 users (FS#28887)
NOTE: IPCFG is now processed after IPv6 address set-up
- additional attributes in ADDR6 and ROUTES6 entries are now allowed
- initscripts sh compatibility is restored (FS#29880)
- a bonding documentation error is fixed (FS#29918)
version 2.8.2
- netcfg now has a website: www.archlinux.org/netcfg/
- replace routes in IPv6 by default (FS#29480)
- fixes: pm-utils support is back, systemd improvements, documentation, FS#28522
version 2.8.1
- add compatibility for configuration in /etc/rc.conf
give users time to move to the new scheme
- fix support for the kernel command line
- give initscripts users more familiar output
version 2.8.0
- end support for wireless-dbus and ethernet-iproute syntax
use wireless and ethernet instead
- end support for configuration in /etc/rc.conf
use /etc/conf.d/netcfg instead
- add sample script demonstrating firewall location handling (FS#26380)
- drop implicit dependency on initscripts
- add systemd service file for profiles (netcfg@<profile>.service)
- add systemd service file for NETWORKS array in /etc/conf.d/netcfg (netcfg.service)
- assorted fixes (FS#20569, FS#28138, FS#28590, FS#28683)
version 2.7.3
- fix dhcpcd to not remove/re-acquire a lease unnecessarily
- fix sysctl parameters for interfaces with vlans (FS#26259)
version 2.7.2
- fix bash completion
- discontinue "-old" connections
version 2.7
- add support for tunnel interfaces
- add support for interface bonding (FS#24802)
- add support for hexadecimal ESSIDs (FS#24333)
- add support for PPPoE connections
- add support for profile backgrounding in net-profiles (FS#23934)
- add interactive wifi connection tool wifi-menu
- add netcfg option to reconnect an interface (-R) (FS#28196)
- rename the option to disconnect an interface (was: -i, now: -D)
- stop suggesting profile-scripting through /etc/network.d/hooks as it was
unused and the {PRE,POST}_{UP,DOWN} variables work just fine (FS#27496)
- assorted fixes (FS#24599, FS#26370, FS#26607, FS#28022)
version 2.6.8
- fix broken 802.11 in non-wireless setups (FS#25473)
- fix rfkill errors in net-auto-wireless (FS#25514)
- fix error message about non-existing net.ipv6.conf... (FS#25530)
version 2.6.7
- fix wrong quoting of $profile (FS#25362)
- fix wrong parsing of wpa_supplicant configuration (FS#25464)
- fix conflict with old ROUTES variable (FS#25432)
version 2.6.6
- fix wrong rc scripts names in suspend hook (FS#20330)
- fix wireless failure when using wpa-config and a custom
ctrl_interface path (FS#24929)
- bash-completion: add -r to option list (FS#25188)
version 2.6.5
- specify device name explicitly when setting gateways
version 2.6.4
- documentation update, new man page "netcfg-profiles"
- modify wireless workflow to avoid issues with association
version 2.6.3
- fix infinite symlink loop (FS#25077)
version 2.6.2
- fix broken WEP support (FS#24896)
- fix dhcpcd/dhclient not stopped properly (FS#23293)
- fix specifying access point by BSSID (FS#24906)
version 2.6.1
- fix missing mkdir for net-auto-wireless
- add basic configuration capabilities to tun/tap interfaces
version 2.6
- add support for IPv6 configuration (FS#18699)
- add support for static routes configuration (FS#18700)
- add support for creating tun/tap interfaces (FS#15049)
- add configuration file /etc/conf.d/netcfg for net-auto-wireless
- add support for restricting automatic startup of profiles (FS#23169)
- bridge: add support for several brctl options (FS#16625)
- wireless: add support for explicit BSSID (FS#24582)
- wireless: add support for ad-hoc connections (FS#19683)
- wireless: no longer require wireless_tools to work
- use /run instead of /var/run
- drops hard dependency on net-tools package
- drops hard dependency on wireless_tools package
version 2.5.5
- new connection types: openvpn (FS#21490), vlan
- new option HIDDEN (for hidden SSIDs)
- new option SKIPNOCARRIER (FS#21755)
- default WPA driver is now nl80211
- minor fixes and improvements (FS#17190, FS#17546,
FS#20150, FS#20569, FS#21377, FS#23293)
- better zsh completion file (FS#19823)
netcfg 2.5.4
- new connection type: bridge
- new option NETMASK for ethernet
netcfg 2.5.3
- fixes to rfkill handling (FS#18391, FS#18385)
- fix for FS#18411
netcfg 2.5.2
- fix for FS#17190
netcfg 2.5.1
- fix for FS#17190
- additional examples
netctl 0.1
- forked from netcfg 3.1 and changed considerably
Dependencies:
- Linux
- systemd
- Bash 4.x
- GNU Coreutils
- iproute2
- dialog: for interactive menu
- ifplugd: for automatic connection
- wireless_tools: for net_rename
For DHCP support:
- dhcpcd
- dhclient (for DHCPv6)
- resolvconf
For wireless support:
- wpa_supplicant
Optional:
- dhcpcd or dhclient: for DHCP support
- wpa_supplicant: for WPA support
- dialog: for the interactive assistant
- ifplugd: for automatic connection
- wpa_actiond: for automatic connection
For bonding support
- ifenslave
For bridge support:
- bridge-utils
- ifenslave: for bonding support
- bridge-utils: for bridge support
For documentation generation:
- asciidoc
Naming Conventions for Variables:
end-user variables - CamelCase
local variables - lower_case
other variables - UPPER_CASE
# Example iftab
# Format: {New name} {Criteria}
# Match on driver
#ipw0 driver ipw2100
#eth9 driver ndiswrapper
#rl0 driver 8139too
# Match on MAC address
#wlan0 mac 00:11:22:33:44:%5
#eth1 mac 11:22:33:44:55:66
# Match on sysfs attribute
#myvpn SYSFS{address} 00:10:83:*
# Automatically number
#eth* ipw2100
## More examples in 'man iftab'
# Enable these netcfg profiles at boot time.
# - prefix an entry with a '@' to background its startup
# - set to 'last' to restore the profiles running at the last shutdown
# - set to 'menu' to present a menu (requires the dialog package)
# Network profiles are found in /etc/network.d
NETWORKS=(last)
# Specify the name of your wired interface for net-auto-wired
WIRED_INTERFACE="eth0"
# Specify the name of your wireless interface for net-auto-wireless
WIRELESS_INTERFACE="wlan0"
# Array of profiles that may be started by net-auto-wireless.
# When not specified, all wireless profiles are considered.
#AUTO_PROFILES=("profile1" "profile2")
# Maintainer: Jouke Witteveen <j.witteveen@gmail.com>
pkgname=netcfg
pkgname=netctl
pkgver=%pkgver%
pkgrel=1
pkgdesc="Network configuration and profile scripts"
url="http://archlinux.org/netcfg/"
license=("BSD")
backup=(etc/iftab etc/conf.d/netcfg)
groups=(base)
depends=("coreutils" "dhcpcd" "iproute2")
url="http://archlinux.org/netctl/"
license=("GPL")
depends=("coreutils" "iproute2" "openresolv")
#makedepends=('asciidoc') # The source tarball includes pre-built documentation.
optdepends=('dialog: for the menu based profile and wifi selectors'
optdepends=('dialog: for the menu based wifi assistant'
'dhclient: for DHCP support (or dhcpcd)'
'dhcpcd: for DHCP support (or dhclient)'
'wpa_supplicant: for wireless networking support'
'ifplugd: for automatic wired connections through net-auto-wired'
'wpa_actiond: for automatic wireless connections through net-auto-wireless'
'wireless_tools: for interface renaming through net-rename'
'ifplugd: for automatic wired connections through netctl-ifplugd'
'wpa_actiond: for automatic wireless connections through netctl-auto'
'ifenslave: for bond connections'
'bridge-utils: for bridge connections'
)
source=(ftp://ftp.archlinux.org/other/netcfg/netcfg-${pkgver}.tar.xz)
conflicts=("netcfg")
source=(ftp://ftp.archlinux.org/other/netctl/netctl-${pkgver}.tar.xz)
arch=(any)
md5sums=('%md5sum%')
package() {
cd "$srcdir/netcfg-${pkgver}"
cd "$srcdir/netctl-${pkgver}"
make DESTDIR="$pkgdir" install
install -D -m644 LICENSE "$pkgdir/usr/share/licenses/netcfg/LICENSE"
# Shell Completion
install -D -m644 contrib/bash-completion "$pkgdir/usr/share/bash-completion/completions/netcfg"
install -D -m644 contrib/zsh-completion "$pkgdir/usr/share/zsh/site-functions/_netcfg"
# Compatibility
ln -s netcfg.service "$pkgdir/usr/lib/systemd/system/net-profiles.service"
install -D -m644 contrib/bash-completion "$pkgdir/usr/share/bash-completion/completions/netctl"
}
### Sample netcfg hook script for location based firewall rules.
### To install, make this executable and put it in /usr/lib/network/hooks
### USAGE
## You need to have iptables installed to use this script.
## Add a location to your network profile and add firewall to your POST_UP.
## The iptables setup in /etc/iptables/$LOCATION.rules will now be loaded
## automatically when a connection is established.
##
## Sample excerpt from the profile:
## LOCATION="library"
## POST_UP="firewall"
function firewall {
/usr/sbin/iptables-restore < "/etc/iptables/$LOCATION.rules"
}
### Sample netcfg hook script for logging/debugging connections
### To install, make this executable and put it in /usr/lib/network/hooks
. /etc/rc.conf
. /etc/rc.d/functions
# if NETCFG_DEBUG is set, debugging messages go to stderr instead of syslog
# What facility to send log messages to? if set to "", nothing will be sent to syslog
NETCFG_LOG="${NETCFG_LOG-local0}"
function report_log {
if [[ -n "$NETCFG_LOG" ]]; then
local caller level="$1"
shift
case "$0" in
net-auto|netcfg-auto-*) caller=net-auto;;
net-profiles) caller=net-profiles;;
net-rename) caller=net-rename;;
*) caller=netcfg;;
esac
logger -p "${NETCFG_LOG}.$level" -t "$caller" -- "$*"
fi
}
function report_err {
report_log err "$*"
printhl "$*"
}
function report_notice {
report_log notice "$*"
# print "$*" >&2
checkyesno "$NETCFG_DEBUG" && echo "DEBUG: $*" >&2
}
function report_debug {
if checkyesno "$NETCFG_DEBUG"; then
echo "DEBUG: $*" >&2
else
report_log debug "$*"
fi
}
function report_try {
report_log notice "trying $*..."
stat_busy "$*"
REPORT_TRYING=1
}
function report_fail {
if [[ -n "$*" ]]; then
report_log err "$*"
if [[ -n "$REPORT_TRYING" ]]; then
stat_append "- $*"
REPORT_TRYING=
stat_fail
else
printhl "$*"
fi
elif [[ -n "$REPORT_TRYING" ]]; then
REPORT_TRYING=
stat_fail
fi
}
function report_success {
if [[ -n "$*" ]]; then
stat_append "- $*"
REPORT_TRYING=
fi
report_log notice "${*:-succeeded}"
stat_done
}
# vim: ft=sh ts=4 et sw=4:
#!/bin/bash
. /usr/lib/pm-utils/functions
[[ -f /usr/lib/network/network ]] || exit $NA
. /usr/lib/network/network
. /etc/conf.d/netcfg
WIRELESS_INTERFACE=${WIRELESS_INTERFACE:-wlan0}
auto_resume()
{
if checkyesno ${RESTOREPROFILES:-no}; then
all_resume
sleep 2
fi
restartservice net-auto-wireless
restartservice net-auto-wired
restartservice net-profiles
}
daemon_suspend_all()
{
stopservice net-auto-wireless
stopservice net-auto-wired
stopservice net-profiles
}
case "$1" in
hibernate|suspend_hybrid|suspend)
report_notice "suspending all interfaces..."
daemon_suspend_all
if checkyesno "${RESTOREPROFILES:-no}"; then
interface_suspend all
fi
;;
thaw|resume)
if [ -f "$STATE_DIR/interface/${WIRELESS_INTERFACE}" ]; then
report_notice "resuming all interfaces..."
auto_resume ${WIRELESS_INTERFACE}
else
report_notice "resuming all interfaces except wireless..."
all_resume ${WIRELESS_INTERFACE}
fi
;;
radio_off)
report_notice "suspending wireless interface..."
interface_suspend ${WIRELESS_INTERFACE} no
set_iface disabled ${WIRELESS_INTERFACE}
bring_interface forcedown ${WIRELESS_INTERFACE}
;;
radio_on)
report_notice "resuming wireless interface..."
auto_resume ${WIRELESS_INTERFACE}
if [ -x /etc/pm/power.d/??wifi ]; then
/usr/bin/on_ac_power # this is in pm-utils
case $? in
0) # on ac
/etc/pm/power.d/??wifi false
;;
1) # on battery
/etc/pm/power.d/??wifi true
;;
esac
fi
;;
*)
;;
esac
exit $?
# vim: ft=sh ts=4 et sw=4:
#compdef netcfg
local -a disp
all_options() {
local _subcommands
_subcommands=('list:List all available profiles'
'current:Report currently running profiles'
'check-iface:Start the specified profile, only if its interface is not currently up'
'up:Start the specified profile'
'reconnect:Disconnect and reconnect the specified profile'
'iface-recon:Reconnect profile active on specified interface'
'down:Stop the specified profile'
'iface-down:Stop the profile up on the specified interface'
'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')
_path_files -W "/etc/network.d" -g "*(.)"
_describe 'subcommand' _subcommands
}
all_profiles() {
_path_files -W "/etc/network.d" -g "*(.)"
}
up_profiles() {
_files -W "/run/network/profiles"
}
up_ifaces() {
_files -W "/run/network/interfaces"
}
_arguments -C \
'(- *)-l[List all available profiles]' \
'(- *)-c[Start the specified profile, only if its interface is not currently up]:Network profile:all_profiles' \
'(- *)-u[Start specified profile]:Network profile:all_profiles' \
'(- *)-r[Disconnect and reconnect the specified profile]:Active profiles:up_profiles' \
'(- *)-R[Reconnect profile active on specified interface]:Active interface:up_ifaces' \
'(- *)-d[Take specified profile down]:Active profile:up_profiles' \
'(- *)-D[Take down profile active on specified interface]:Active interface:up_ifaces' \
'(- *)-a[Take all active profiles down]' \
'(- *)*:All options:all_options'
if [[ ${#words} == 3 ]]; then
case $words[2] in