diff options
author | Patrick J Volkerding <volkerdi@slackware.com> | 2021-03-01 20:10:44 +0000 |
---|---|---|
committer | Eric Hameleers <alien@slackware.com> | 2021-03-02 08:59:52 +0100 |
commit | 07ac5d43e50cb2039f37b4e9447c4e52789c9fb2 (patch) | |
tree | 9b2ebc687d19203f8b4ebe1ab2a0b6c485454a3b /source/n/wireless_tools/scripts/rc.wireless | |
parent | fa458b65d9d4c5e933622574d999915ecda37a25 (diff) | |
download | current-07ac5d43e50cb2039f37b4e9447c4e52789c9fb2.tar.gz |
Mon Mar 1 20:10:44 UTC 202120210301201044
a/e2fsprogs-1.46.2-x86_64-1.txz: Upgraded.
a/etc-15.0-x86_64-14.txz: Rebuilt.
/etc/hosts: added IPv6 loopback addresses.
a/hwdata-0.345-noarch-1.txz: Upgraded.
ap/hplip-3.20.6-x86_64-7.txz: Rebuilt.
Fixed desktop file to show category and icon properly.
Thanks to upnort and ArTourter.
d/git-2.30.1-x86_64-3.txz: Rebuilt.
Make sure the bash-completion file is installed in the proper location.
Thanks to Robby Workman.
d/python-setuptools-54.0.0-x86_64-1.txz: Upgraded.
d/vala-0.50.4-x86_64-1.txz: Upgraded.
l/imagemagick-7.0.11_2-x86_64-1.txz: Upgraded.
l/python-pillow-8.1.1-x86_64-1.txz: Upgraded.
n/network-scripts-15.0-noarch-13.txz: Rebuilt.
Well, apparently there was a newer branch of this than the one that was
sitting in my usual pending queue, so here it is. This also includes some
additional documentation on the new features. NOTE: In order to use SLAAC
to configure IPv6, you'll need to have USE_SLAAC[x]="yes" for the interface
in rc.inet1.conf. This is to ensure that nobody is surprised to find their
machine fully exposed to the internet - better safe than sorry.
Thanks to Darren "Tadgy" Austin and Robby Workman.
n/wireless_tools-30.pre9-x86_64-4.txz: Rebuilt.
This package contains some updates to rc.wireless and rc.wireless.conf.
Thanks to Darren "Tadgy" Austin.
xfce/mousepad-0.5.3-x86_64-1.txz: Upgraded.
Diffstat (limited to 'source/n/wireless_tools/scripts/rc.wireless')
-rw-r--r-- | source/n/wireless_tools/scripts/rc.wireless | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/source/n/wireless_tools/scripts/rc.wireless b/source/n/wireless_tools/scripts/rc.wireless index e7a35b89..52559ff5 100644 --- a/source/n/wireless_tools/scripts/rc.wireless +++ b/source/n/wireless_tools/scripts/rc.wireless @@ -58,13 +58,21 @@ # test may depend on the kernel options and the # wireless driver used. # Convert the MAC address to uppercase in sed. +# 11/Nov/2019 * Darren Austin * Log to syslog, failling back to stdout. +# Output error to stderr if not called from +# rc.inet1. # ------------------------------------------------------------------------------ -LOGGER=${LOGGER:-cat} +# If possible, log events in /var/log/messages: +if [ -f /var/run/syslogd.pid ] && [ -x /usr/bin/logger ]; then + LOGGER=/usr/bin/logger +else # output to stdout/stderr: + LOGGER=/bin/cat +fi -if [ -z $IFNAME ] ; then - echo "WARNING: The script 'rc.wireless' must be executed by 'rc.inet1'!" | $LOGGER - echo " You should run the command \"/etc/rc.d/rc.inet1 <your_interface>_start\" yourself." | $LOGGER +if [ -z "$IFNAME" ] ; then + echo "ERROR: The script 'rc.wireless' must be executed by 'rc.inet1'!" >&2 + echo " You should run the command \"/etc/rc.d/rc.inet1 <your_interface>_start\" yourself." >&2 return 1 2> /dev/null || exit 1 fi @@ -89,11 +97,11 @@ IFCOMMAND="/sbin/ip link set dev ${INTERFACE}" is_wireless_device () { # Return 0 for a wireless interface, or 1 for a non-wireless interface. - if LC_ALL=C $IWPATH/iwconfig $1 2>&1 | grep -q "IEEE 802.11" ; then + if [ -d /sys/class/net/${1}/wireless ]; then return 0 - elif [ -d /sys/class/net/${1}/wireless ]; then + elif grep -Fxq 'DEVTYPE=wlan' /sys/class/net/${1}/uevent 2>/dev/null; then return 0 - elif [ "$(cat /sys/class/net/${1}/uevent | grep DEVTYPE)" = "DEVTYPE=wlan" ]; then + elif LC_ALL=C $IWPATH/iwconfig $1 2>&1 | grep -q "IEEE 802.11" ; then return 0 else # all tests failed, assume the device is not wireless (or add a better test :) return 1 @@ -110,8 +118,7 @@ is_wireless_device ${INTERFACE} || return 0 2> /dev/null || exit 0 # If we stop a wireless interface using wpa_supplicant, # we'll kill its wpa_supplicant daemon too and exit this script: if [ "$2" = "stop" ]; then - WPAPID=$(echo $(ps axww | grep wpa_supplicant | grep i${INTERFACE}) | cut -f1 -d' ') - [ ${WPAPID} ] && kill ${WPAPID} + pkill --full "bin/wpa_supplicant.* -i${INTERFACE}" return 0 fi @@ -124,7 +131,7 @@ $IFCOMMAND up sleep 3 # Get the MAC address for the interface -HWADDR=$(/sbin/ip link show dev ${INTERFACE} | sed -ne 's/.*link\/ether \(..:..:..:..:..:..\).*/\U\1/p') +HWADDR=$(cat "/sys/class/net/${INTERFACE}/address") # Empty all wireless parameters- some of them could still be set for a previous interface: # when rc.inet1 is sourced from rc.M all scripts are run in the same shell. @@ -177,7 +184,7 @@ WPACONF=${WLAN_WPACONF[$i]:-${WPACONF:="/etc/wpa_supplicant.conf"}} WPAWAIT=${WLAN_WPAWAIT[$i]:-${WPAWAIT:="60"}} -[ -n "$VERBOSE" -a -n "$INFO" ] && echo "$0: $1 information: '$INFO'" +[ -n "$VERBOSE" ] && [ -n "$INFO" ] && echo "$0: $1 information: '$INFO'" ################### # WIRELESS CONFIG # @@ -199,7 +206,7 @@ fi if [ ! -n "$NICKNAME" ] ; then NICKNAME=$(/bin/hostname) fi -if [ -n "$ESSID" -o -n "$MODE" ] ; then +if [ -n "$ESSID" ] || [ -n "$MODE" ] ; then echo "$0: $IWCOMMAND nick $NICKNAME" | $LOGGER $IWCOMMAND nick $NICKNAME fi @@ -217,7 +224,7 @@ elif [ -n "$CHANNEL" ] ; then fi # WEP keys (non-WPA) -if [ -n "$KEY" -a ! -n "$WPA" ] ; then +if [ -n "$KEY" ] && [ ! -n "$WPA" ] ; then if [ "$KEY" = "off" ]; then echo "$0: $IWCOMMAND key open" | $LOGGER $IWCOMMAND key open @@ -272,7 +279,7 @@ if [ -n "$IWPRIV" ] ; then echo "${IWPRIV}|" | \ while read -d '|' iwi; do if [ -n "$iwi" ]; then - echo "$0: '$IWPRIVCMD $iwi'" | $LOGGER + echo "$0: $IWPRIVCMD $iwi" | $LOGGER $IWPRIVCMD $iwi fi done @@ -290,12 +297,11 @@ if [ "$WPA" = "wpa_supplicant" ] || [ "$WPA" = "wpaxsupplicant" ] && [ -x ${SUPP $IFCOMMAND down #WPACONF=${WPACONF:-/etc/wpa_supplicant.conf} WPA_OPTIONS="" - [ ${WPADRIVER} ] && WPA_OPTIONS="-D${WPADRIVER}" # specify the driver - [ ${WPA} = "wpaxsupplicant" ] && WPA_OPTIONS="${WPA_OPTIONS} -e" # Use external xsupplicant (disables the internal supplicant) + [ -n "$WPADRIVER" ] && WPA_OPTIONS="-D${WPADRIVER}" # specify the driver + [ "$WPA" = "wpaxsupplicant" ] && WPA_OPTIONS="${WPA_OPTIONS} -e" # Use external xsupplicant (disables the internal supplicant) # We leave a running wpa_supplicant process in peace: - WPAPID=$(echo $(ps axww | grep wpa_supplicant | grep i${INTERFACE}) | cut -f1 -d' ') - if [ ${WPAPID} ]; then + if pgrep --full "bin/wpa_supplicant.* -i${INTERFACE}" >/dev/null ; then echo "$0: wpa_supplicant found running already" | $LOGGER else echo "$0: wpa_supplicant -B -c${WPACONF} ${WPA_OPTIONS} -i$INTERFACE" | $LOGGER @@ -317,7 +323,7 @@ if [ "$WPA" = "wpa_supplicant" ] || [ "$WPA" = "wpaxsupplicant" ] && [ -x ${SUPP fi done if [ $wi -eq $WPAWAIT ]; then - echo "WPA authentication did not complete, try running '/etc/rc.d/rc.inet1 ${INTERFACE}_start' in a few seconds." | $LOGGER + echo "$0: WPA authentication did not complete, try running '/etc/rc.d/rc.inet1 ${INTERFACE}_start' in a few seconds." | $LOGGER fi # Bring interface up to avoid 'not ready' errors when calling iwconfig $IFCOMMAND up |