first commit

This commit is contained in:
STP
2019-11-26 21:36:24 +01:00
commit d9ad30ccf3
2899 changed files with 168823 additions and 0 deletions

View File

@ -0,0 +1,36 @@
#!/bin/sh
set -e
# Description: Remove routes to allow communication between machines which
# only have an IPv4LL address assigned and those which only
# have a routable address assigned. These were added by
# /etc/network/if-up.d/avahi-autoipd.
#
# See http://developer.apple.com/qa/qa2004/qa1357.html for
# more information.
[ -x /usr/sbin/avahi-autoipd ] || exit 0
[ "$IFACE" != "lo" ] || exit 0
case "$ADDRFAM" in
inet) ;;
*) exit 0 ;;
esac
case "$METHOD" in
static|dhcp|NetworkManager) ;;
*) exit 0 ;;
esac
if [ -x /bin/ip ]; then
# route already present?
ip route show | grep -q '^169.254.0.0/16[[:space:]]' && exit 0
/bin/ip route del 169.254.0.0/16 dev $IFACE metric 1000 scope link || true
elif [ -x /sbin/route ]; then
# route already present?
/sbin/route -n | grep -q "^169.254.0.0[[:space:]]" && exit 0
/sbin/route del -net 169.254.0.0 netmask 255.255.0.0 dev $IFACE metric 1000 || true
fi

View File

@ -0,0 +1,16 @@
#!/bin/sh
#
# ifdown hook script for resolvconf
#
# This file is part of the resolvconf package.
#
[ -x /sbin/resolvconf ] || exit 0
case "$ADDRFAM" in
inet|inet6) : ;;
*) exit 0 ;;
esac
/sbin/resolvconf -d "${IFACE}.${ADDRFAM}" || :

View File

@ -0,0 +1,20 @@
#!/bin/sh -e
if [ -e /lib/lsb/init-functions ]; then
. /lib/lsb/init-functions
fi
if ! init_is_upstart; then
exit 0
fi
# Let's ignore meta entries (ifdown -a)
if [ "$ADDRFAM" = "meta" ]; then
exit 0
fi
initctl emit -n net-device-down \
"IFACE=$IFACE" \
"LOGICAL=$LOGICAL" \
"ADDRFAM=$ADDRFAM" \
"METHOD=$METHOD"

View File

@ -0,0 +1 @@
../../wpa_supplicant/ifupdown.sh

View File

@ -0,0 +1 @@
../if-up.d/avahi-daemon

View File

@ -0,0 +1,64 @@
#!/bin/sh
IWCONFIG=/sbin/iwconfig
if [ ! -x $IWCONFIG ]; then
exit 0
fi
apply_settings()
{
if [ -n "$IF_WIRELESS_MODE" ]; then
$IWCONFIG "$IFACE" mode auto
fi
if [ -n "$IF_WIRELESS_AP" ]; then
$IWCONFIG "$IFACE" ap off
fi
if [ -n "$IF_WIRELESS_RATE" ]; then
$IWCONFIG "$IFACE" rate auto
fi
if [ -n "$IF_WIRELESS_RTS" ]; then
$IWCONFIG "$IFACE" rts auto
fi
if [ -n "$IF_WIRELESS_FRAG" ]; then
$IWCONFIG "$IFACE" frag auto
fi
if [ -n "$IF_WIRELESS_POWER" ]; then
$IWCONFIG "$IFACE" power off
fi
if [ -n "$IF_WIRELESS_TXPOWER" ]; then
$IWCONFIG "$IFACE" txpower auto
fi
if [ -n "$IF_WIRELESS_ENC" ]; then
$IWCONFIG "$IFACE" enc off
fi
if [ -n "$IF_WIRELESS_KEY" ]; then
$IWCONFIG "$IFACE" key off
fi
if [ -n "$IF_WIRELESS_DEFAULTKEY" ]; then
$IWCONFIG "$IFACE" key off
fi
if [ -n "$IF_WIRELESS_NWID" ]; then
$IWCONFIG "$IFACE" nwid off
fi
if [ -n "$IF_WIRELESS_ESSID" ]; then
$IWCONFIG "$IFACE" essid any
fi
if [ -n "$IF_WIRELESS_COMMIT" ]; then
$IWCONFIG "$IFACE" commit
fi
}
apply_settings 2>/dev/null

View File

@ -0,0 +1 @@
../../wpa_supplicant/ifupdown.sh

View File

@ -0,0 +1,14 @@
#!/bin/sh
ETHTOOL=/sbin/ethtool
test -x $ETHTOOL || exit 0
[ "$IFACE" != "lo" ] || exit 0
# Gather together the mixed bag of settings applied with -s/--change
SETTINGS="\
${IF_ETHERNET_PORT:+ port $IF_ETHERNET_PORT}\
${IF_DRIVER_MESSAGE_LEVEL:+ msglvl $IF_DRIVER_MESSAGE_LEVEL}\
"
[ -z "$SETTINGS" ] || $ETHTOOL --change "$IFACE" $SETTINGS

View File

@ -0,0 +1,129 @@
#!/bin/sh
IWCONFIG=/sbin/iwconfig
if [ ! -x $IWCONFIG ]; then
exit 0
fi
# The wireless driver madness:
#
# - Some drivers want everything to be configured before bringing the interface up
# - Some drivers want everything to be configured after bringing the interface up
# - Some drivers want some parameters before, other parameters after bringing the interface up
#
# So, we try to set every parameter when the interface is still down,
# and remember which ones failed to be configured properly.
# If some failed, we bring the interface up, and try the failed ones again.
apply_settings()
{
if [ -n "$IF_WIRELESS_SENS" ]; then
$IWCONFIG "$IFACE" sens $IF_WIRELESS_SENS && IF_WIRELESS_SENS= || FAIL=true
fi
if [ -n "$IF_WIRELESS_MODE" ]; then
$IWCONFIG "$IFACE" mode $IF_WIRELESS_MODE && IF_WIRELESS_MODE= || FAIL=true
fi
if [ -n "$IF_WIRELESS_AP" ]; then
$IWCONFIG "$IFACE" ap $IF_WIRELESS_AP && IF_WIRELESS_AP= || FAIL=true
fi
if [ -n "$IF_WIRELESS_RATE" ]; then
$IWCONFIG "$IFACE" rate $IF_WIRELESS_RATE && IF_WIRELESS_RATE= || FAIL=true
fi
if [ -n "$IF_WIRELESS_RTS" ]; then
$IWCONFIG "$IFACE" rts $IF_WIRELESS_RTS && IF_WIRELESS_RTS= || FAIL=true
fi
if [ -n "$IF_WIRELESS_FRAG" ]; then
$IWCONFIG "$IFACE" frag $IF_WIRELESS_FRAG && IF_WIRELESS_FRAG= || FAIL=true
fi
if [ -n "$IF_WIRELESS_POWER" ]; then
$IWCONFIG "$IFACE" power $IF_WIRELESS_POWER && IF_WIRELESS_POWER= || FAIL=true
fi
if [ -n "$IF_WIRELESS_POWERPERIOD" ]; then
$IWCONFIG "$IFACE" power period $IF_WIRELESS_POWERPERIOD && IF_WIRELESS_POWERPERIOD= || FAIL=true
fi
if [ -n "$IF_WIRELESS_POWERTIMEOUT" ]; then
$IWCONFIG "$IFACE" power timeout $IF_WIRELESS_POWERTIMEOUT && IF_WIRELESS_POWERTIMEOUT= || FAIL=true
fi
if [ -n "$IF_WIRELESS_TXPOWER" ]; then
$IWCONFIG "$IFACE" txpower $IF_WIRELESS_TXPOWER && IF_WIRELESS_TXPOWER= || FAIL=true
fi
if [ -n "$IF_WIRELESS_RETRY" ]; then
$IWCONFIG "$IFACE" retry $IF_WIRELESS_RETRY && IF_WIRELESS_RETRY= || FAIL=true
fi
if [ -n "$IF_WIRELESS_ENC" ]; then
eval $IWCONFIG "$IFACE" enc $IF_WIRELESS_ENC && IF_WIRELESS_ENC= || FAIL=true
fi
if [ -n "$IF_WIRELESS_DEFAULTKEY" ]; then
$IWCONFIG "$IFACE" key ["$IF_WIRELESS_DEFAULTKEY"] && IF_WIRELESS_DEFAULTKEY= || FAIL=true
fi
if [ -n "$IF_WIRELESS_KEYMODE" ]; then
$IWCONFIG "$IFACE" key "$IF_WIRELESS_KEYMODE" && IF_WIRELESS_KEYMODE= || FAIL=true
fi
if [ -n "$IF_WIRELESS_KEY" ]; then
eval $IWCONFIG "$IFACE" key $IF_WIRELESS_KEY && IF_WIRELESS_KEY= || FAIL=true
fi
if [ -n "$IF_WIRELESS_KEY1" ]; then
$IWCONFIG "$IFACE" key [1] "$IF_WIRELESS_KEY1" && IF_WIRELESS_KEY1= || FAIL=true
fi
if [ -n "$IF_WIRELESS_KEY2" ]; then
$IWCONFIG "$IFACE" key [2] "$IF_WIRELESS_KEY2" && IF_WIRELESS_KEY2= || FAIL=true
fi
if [ -n "$IF_WIRELESS_KEY3" ]; then
$IWCONFIG "$IFACE" key [3] "$IF_WIRELESS_KEY3" && IF_WIRELESS_KEY3= || FAIL=true
fi
if [ -n "$IF_WIRELESS_KEY4" ]; then
$IWCONFIG "$IFACE" key [4] "$IF_WIRELESS_KEY4" && IF_WIRELESS_KEY4= || FAIL=true
fi
if [ -n "$IF_WIRELESS_FREQ" ]; then
$IWCONFIG "$IFACE" freq $IF_WIRELESS_FREQ && IF_WIRELESS_FREQ= || FAIL=true
fi
if [ -n "$IF_WIRELESS_CHANNEL" ]; then
$IWCONFIG "$IFACE" channel $IF_WIRELESS_CHANNEL && IF_WIRELESS_CHANNEL= || FAIL=true
fi
if [ -n "$IF_WIRELESS_NICK" ]; then
$IWCONFIG "$IFACE" nick "$IF_WIRELESS_NICK" && IF_WIRELESS_NICK= || FAIL=true
fi
if [ -n "$IF_WIRELESS_NWID" ]; then
$IWCONFIG "$IFACE" nwid "$IF_WIRELESS_NWID" && IF_WIRELESS_NWID= || FAIL=true
fi
if [ -n "$IF_WIRELESS_ESSID" ]; then
$IWCONFIG "$IFACE" essid "$IF_WIRELESS_ESSID" && IF_WIRELESS_ESSID= || FAIL=true
fi
if [ -n "$IF_WIRELESS_COMMIT" ]; then
$IWCONFIG "$IFACE" commit && IF_WIRELESS_COMMIT= || FAIL=true
fi
}
FAIL=
apply_settings 2>/dev/null
if [ -n "$FAIL" ]; then
FAIL=
ifconfig "$IFACE" up
apply_settings
fi

View File

@ -0,0 +1 @@
../../wpa_supplicant/ifupdown.sh

View File

@ -0,0 +1,47 @@
#!/bin/sh
#
# ifup hook script for resolvconf
#
# This file is part of the resolvconf package.
#
[ -x /sbin/resolvconf ] || exit 0
case "$ADDRFAM" in
inet|inet6) : ;;
*) exit 0 ;;
esac
R=""
if [ "$IF_DNS_DOMAIN" ] ; then
R="${R}domain $IF_DNS_DOMAIN
"
fi
if [ "$IF_DNS_SEARCH" ] ; then
R="${R}search $IF_DNS_SEARCH
"
fi
if [ "$IF_DNS_SORTLIST" ] ; then
R="${R}sortlist $IF_DNS_SORTLIST
"
fi
for NS in $IF_DNS_NAMESERVERS ; do
R="${R}nameserver $NS
"
done
# Note: arguments of multiple instances of options are separated by newlines
set_NS_to_first_arg() { NS="$1" ; }
STANDARD_IFS="$IFS"
IFS='
'
for OPT in $IF_DNS_NAMESERVER ; do
IFS="$STANDARD_IFS"
set_NS_to_first_arg $OPT
[ "$NS" ] && R="${R}nameserver $NS
"
done
IFS="$STANDARD_IFS"
echo -n "$R" | /sbin/resolvconf -a "${IFACE}.${ADDRFAM}" || :

View File

@ -0,0 +1,37 @@
#!/bin/sh
set -e
# Description: Add routes to allow communication between machines which
# only have an IPv4LL address assigned and those which only
# have a routable address assigned.
#
# See http://developer.apple.com/qa/qa2004/qa1357.html for
# more information.
[ -x /usr/sbin/avahi-autoipd ] || exit 0
[ "$IFACE" != "lo" ] || exit 0
case "$ADDRFAM" in
inet) ;;
*) exit 0 ;;
esac
case "$METHOD" in
static|dhcp|NetworkManager) ;;
*) exit 0 ;;
esac
if [ -x /bin/ip ]; then
# route already present?
ip route show | grep -q '^169.254.0.0/16[[:space:]]' && exit 0
/bin/ip route add 169.254.0.0/16 dev $IFACE metric 1000 scope link
elif [ -x /sbin/route ]; then
# route already present?
/sbin/route -n | egrep -q "^169.254.0.0[[:space:]]" && exit 0
/sbin/route add -net 169.254.0.0 netmask 255.255.0.0 dev $IFACE metric 1000
fi

View File

@ -0,0 +1,16 @@
#!/bin/sh
# Don't run the avahi-daemon unicast local check while bringing up
# the loopback device; it's not necessary until we bring up a real network
# device
[ "$IFACE" != "lo" ] || exit 0
case "$ADDRFAM" in
inet|inet6) ;;
*) exit 0 ;;
esac
# If we have an unicast .local domain, we immediately disable avahi to avoid
# conflicts with the multicast IP4LL .local domain
if [ -x /usr/lib/avahi/avahi-daemon-check-dns.sh ] ; then
exec /usr/lib/avahi/avahi-daemon-check-dns.sh
fi

55
etc_org/network/if-up.d/ethtool Executable file
View File

@ -0,0 +1,55 @@
#!/bin/sh
ETHTOOL=/sbin/ethtool
test -x $ETHTOOL || exit 0
[ "$IFACE" != "lo" ] || exit 0
# Find settings with a given prefix and print them as they appeared in
# /etc/network/interfaces, only with the prefix removed.
# This actually prints each name and value on a separate line, but that
# doesn't matter to the shell.
gather_settings () {
set | sed -n "
/^IF_$1[A-Za-z0-9_]*=/ {
h; # hold line
s/^IF_$1//; s/=.*//; s/_/-/g; # get name without prefix
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/; # lower-case
p;
g; # restore line
s/^[^=]*=//; s/^'\(.*\)'/\1/; # get value
p;
}"
}
# Gather together the mixed bag of settings applied with -s/--change
SETTINGS="\
${IF_LINK_SPEED:+ speed $IF_LINK_SPEED}\
${IF_LINK_DUPLEX:+ duplex $IF_LINK_DUPLEX}\
"
# WOL has an optional pass-key
set -- $IF_ETHERNET_WOL
SETTINGS="$SETTINGS${1:+ wol $1}${2:+ sopass $2}"
# Autonegotiation can be on|off or an advertising mask
case "$IF_ETHERNET_AUTONEG" in
'') ;;
on|off) SETTINGS="$SETTINGS autoneg $IF_ETHERNET_AUTONEG" ;;
*) SETTINGS="$SETTINGS autoneg on advertise $IF_ETHERNET_AUTONEG" ;;
esac
[ -z "$SETTINGS" ] || $ETHTOOL --change "$IFACE" $SETTINGS
SETTINGS="$(gather_settings ETHERNET_PAUSE_)"
[ -z "$SETTINGS" ] || $ETHTOOL --pause "$IFACE" $SETTINGS
SETTINGS="$(gather_settings HARDWARE_IRQ_COALESCE_)"
[ -z "$SETTINGS" ] || $ETHTOOL --coalesce "$IFACE" $SETTINGS
SETTINGS="$(gather_settings HARDWARE_DMA_RING_)"
[ -z "$SETTINGS" ] || $ETHTOOL --set-ring "$IFACE" $SETTINGS
SETTINGS="$(gather_settings OFFLOAD_)"
[ -z "$SETTINGS" ] || $ETHTOOL --offload "$IFACE" $SETTINGS

View File

@ -0,0 +1,42 @@
#! /bin/sh
# Reload the OpenSSH server when an interface comes up, to allow it to start
# listening on new addresses.
set -e
# Don't bother to restart sshd when lo is configured.
if [ "$IFACE" = lo ]; then
exit 0
fi
# Only run from ifup.
if [ "$MODE" != start ]; then
exit 0
fi
# OpenSSH only cares about inet and inet6. Get ye gone, strange people
# still using ipx.
if [ "$ADDRFAM" != inet ] && [ "$ADDRFAM" != inet6 ]; then
exit 0
fi
# Is /usr mounted?
if [ ! -e /usr/sbin/sshd ]; then
exit 0
fi
if [ ! -f /var/run/sshd.pid ] || \
[ "$(ps -p "$(cat /var/run/sshd.pid)" -o comm=)" != sshd ]; then
exit 0
fi
# We'd like to use 'reload' here, but it has some problems; see #502444. On
# the other hand, repeated restarts of ssh make systemd unhappy
# (#756547/#757822), so use reload in that case.
if [ -d /run/systemd/system ]; then
systemctl reload --no-block ssh.service >/dev/null 2>&1 || true
else
invoke-rc.d ssh restart >/dev/null 2>&1 || true
fi
exit 0

54
etc_org/network/if-up.d/upstart Executable file
View File

@ -0,0 +1,54 @@
#!/bin/sh -e
MARK_DEV_PREFIX="/run/network/ifup."
MARK_STATIC_NETWORK_EMITTED="/run/network/static-network-up-emitted"
if [ -e /lib/lsb/init-functions ]; then
. /lib/lsb/init-functions
fi
if ! init_is_upstart; then
exit 0
fi
# Let's ignore meta entries (ifup -a)
if [ "$ADDRFAM" = "meta" ]; then
exit 0
fi
# lo emission handled by /etc/init/network-interface.conf
if [ "$IFACE" != lo ]; then
initctl emit -n net-device-up \
"IFACE=$IFACE" \
"LOGICAL=$LOGICAL" \
"ADDRFAM=$ADDRFAM" \
"METHOD=$METHOD"
fi
get_auto_interfaces() {
# write to stdout a list of interfaces configured as 'auto' in interfaces(5)
local found=""
# stderr redirected as it outputs things like:
# Ignoring unknown interface eth0=eth0.
found=$(ifquery --list --allow auto 2>/dev/null) || return
set -- ${found}
echo "$@"
}
all_interfaces_up() {
# return true if all interfaces listed in /etc/network/interfaces as 'auto'
# are up. if no interfaces are found there, then "all [given] were up"
local prefix="$1" iface=""
for iface in $(get_auto_interfaces); do
# if cur interface does is not up, then all have not been brought up
[ -f "${prefix}${iface}" ] || return 1
done
return 0
}
# touch our own "marker" indicating that this interface has been brought up.
: > "${MARK_DEV_PREFIX}$IFACE"
if all_interfaces_up "${MARK_DEV_PREFIX}" &&
mkdir "${MARK_STATIC_NETWORK_EMITTED}" 2>/dev/null; then
initctl emit --no-wait static-network-up
fi

View File

@ -0,0 +1 @@
../../wpa_supplicant/ifupdown.sh

View File

@ -0,0 +1,7 @@
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
# The loopback network interface
auto lo
iface lo inet loopback