Author: krejzi Date: Mon Feb 11 08:22:35 2013 New Revision: 11012 Log: Added wpa service configuration to wpa_supplicant p age and few modifications to wpa and dhclient services.
Modified: trunk/BOOK/general.ent trunk/BOOK/introduction/welcome/changelog.xml trunk/BOOK/networking/netprogs/wpa_supplicant.xml trunk/bootscripts/blfs/services/dhclient trunk/bootscripts/blfs/services/wpa Modified: trunk/BOOK/general.ent ============================================================================== --- trunk/BOOK/general.ent Sun Feb 10 13:48:21 2013 (r11011) +++ trunk/BOOK/general.ent Mon Feb 11 08:22:35 2013 (r11012) @@ -66,7 +66,7 @@ <!ENTITY lfs-vim-version "7.3"> <!-- End LFS versions --> -<!ENTITY blfs-bootscripts-version "20130204"> +<!ENTITY blfs-bootscripts-version "20130211"> <!ENTITY blfs-bootscripts-download "&downloads-root;/blfs-bootscripts-&blfs-bootscripts-version;.tar.bz2"> <!ENTITY blfs-wiki "http://wiki.&lfs-domainname;/blfs/wiki"> Modified: trunk/BOOK/introduction/welcome/changelog.xml ============================================================================== --- trunk/BOOK/introduction/welcome/changelog.xml Sun Feb 10 13:48:21 2013 (r11011) +++ trunk/BOOK/introduction/welcome/changelog.xml Mon Feb 11 08:22:35 2013 (r11012) @@ -45,6 +45,16 @@ --> <listitem> + <para>February 11th, 2013</para> + <itemizedlist> + <listitem> + <para>[krejzi] - Added wpa service configuration to + wpa_supplicant instructions.</para> + </listitem> + </itemizedlist> + </listitem> + + <listitem> <para>February 10th, 2013</para> <itemizedlist> <listitem> Modified: trunk/BOOK/networking/netprogs/wpa_supplicant.xml ============================================================================== --- trunk/BOOK/networking/netprogs/wpa_supplicant.xml Sun Feb 10 13:48:21 2013 (r11011) +++ trunk/BOOK/networking/netprogs/wpa_supplicant.xml Mon Feb 11 08:22:35 2013 (r11012) @@ -207,12 +207,9 @@ Now, as the <systemitem class="username">root</systemitem> user: </para> -<screen role="root"><userinput>install -v -m755 wpa_{cli,passphrase,supplicant} \ - /sbin && -install -v -m644 doc/docbook/wpa_supplicant.conf.5 \ - /usr/share/man/man5 && -install -v -m644 doc/docbook/wpa_{cli,passphrase,supplicant}.8 \ - /usr/share/man/man8</userinput></screen> +<screen role="root"><userinput>install -v -m755 wpa_{cli,passphrase,supplicant} /sbin/ && +install -v -m644 doc/docbook/wpa_supplicant.conf.5 /usr/share/man/man5/ && +install -v -m644 doc/docbook/wpa_{cli,passphrase,supplicant}.8 /usr/share/man/man8/</userinput></screen> <para> If you have built <application>WPA Supplicant</application> with @@ -223,7 +220,7 @@ </para> <screen role="root"><userinput>install -v -m644 dbus/fi.{epitest.hostap.WPASupplicant,w1.wpa_supplicant1}.service \ - /usr/share/dbus-1/system-services && + /usr/share/dbus-1/system-services/ && install -v -m644 dbus/dbus-wpa_supplicant.conf \ /etc/dbus-1/system.d/wpa_supplicant.conf</userinput></screen> @@ -233,10 +230,9 @@ <systemitem class="username">root</systemitem> user: </para> -<screen role="root"><userinput> -install -v -m755 wpa_gui-qt4/wpa_gui /usr/bin/ && -install -v -m644 doc/docbook/wpa_gui.8 /usr/share/man/man8/ && -install -v -m644 wpa_gui-qt4/wpa_gui.desktop /usr/share/applications/ && +<screen role="root"><userinput>install -v -m755 wpa_gui-qt4/wpa_gui /usr/bin/ && +install -v -m644 doc/docbook/wpa_gui.8 /usr/share/man/man8/ && +install -v -m644 wpa_gui-qt4/wpa_gui.desktop /usr/share/applications/ && install -v -m644 wpa_gui-qt4/icons/wpa_gui.svg /usr/share/pixmaps/</userinput></screen> <note> @@ -249,6 +245,7 @@ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../../xincludes/update-desktop-database.xml"/> + </sect2> <sect2 role="configuration"> @@ -256,12 +253,16 @@ <sect3 id="wpa_supplicant-config"> <title>Config File</title> - <para><filename>/etc/wpa_supplicant.conf</filename></para> + + <para> + <filename>/etc/sysconfig/wpa_supplicant-*.conf</filename> + </para> <indexterm zone="wpa_supplicant wpa_supplicant-config"> <primary - sortas="e-etc-wpa_supplicant.conf">/etc/wpa_supplicant.conf</primary> + sortas="e-etc-sysconfig-wpa_supplicant-star.conf">/etc/sysconfig/wpa_supplicant-*.conf</primary> </indexterm> + </sect3> <sect3> @@ -269,26 +270,27 @@ <para> To connect to an access point that uses a password, you need to put - the pre-shared key in <filename>/etc/wpa_supplicant.conf</filename>. Use - <command>wpa_passphrase</command> to generate this. SSID is the string - that the access point/router transmits to identify itself. As the + the pre-shared key in <filename> + /etc/sysconfig/wpa_supplicant-<replaceable>wlan0</replaceable>.conf</filename>. + SSID is the string that the access point/router transmits to + identify itself. Run the following command as the <systemitem class="username">root</systemitem> user: </para> -<screen role="root"><userinput>wpa_passphrase <replaceable>SSID</replaceable> <replaceable>SECRET_PASSWORD</replaceable> > /etc/wpa_supplicant.conf</userinput></screen> +<screen role="root"><userinput>wpa_passphrase <replaceable>SSID</replaceable> <replaceable>SECRET_PASSWORD</replaceable> > /etc/sysconfig/wpa_supplicant-<replaceable>wlan0</replaceable>.conf</userinput></screen> <para> - <filename>/etc/wpa_supplicant.conf</filename> can hold the details of - several access points. When you run <command>wpa_supplicant</command> - it will scan for the SSIDs it can see and choose the appropriate - password to connect. + <filename>/etc/sysconfig/wpa_supplicant-<replaceable>wlan0</replaceable>.conf + </filename> can hold the details of several access points. When + <command>wpa_supplicant</command> is started, it will scan for the + SSIDs it can see and choose the appropriate password to connect. </para> <para> If you want to connect to an access point that isn't password - protected, put an entry like this in - <filename>/etc/wpa_supplicant.conf</filename>. Replace - "Some-SSID" with the SSID of the access point/router. + protected, put an entry like this in <filename> + /etc/sysconfig/wpa_supplicant-<replaceable>wlan0</replaceable>.conf</filename>. + Replace "Some-SSID" with the SSID of the access point/router. </para> <screen>network={ @@ -303,45 +305,113 @@ source tree. </para> - <para> - To use <command>wpa_cli</command> to control the running - <command>>wpa_supplicant</command> daemon, add a control interface to - <filename>/etc/wpa_supplicant.conf</filename> as the - <systemitem class="username">root</systemitem> user: - </para> - -<screen role="root"><userinput>echo ctrl_interface=/run/wpa_supplicant >> /etc/wpa_supplicant.conf</userinput></screen> </sect3> <sect3> <title>Connecting to an Access Point</title> + <para id="wpa-service"> + If you want to configure network interfaces at boot using + <command>wpa_supplicant</command>, you need to install the + <filename>/lib/services/wpa</filename> script + included in <xref linkend="bootscripts"/> package: + </para> + +<screen role="root"><userinput>make install-service-wpa</userinput></screen> + + <indexterm zone="wpa_supplicant wpa-service"> + <primary sortas="f-wpa">wpa</primary> + </indexterm> + <para> - If your router/access point uses DHCP to allocate IP addresses you - can install <xref linkend="dhcpcd"/> and use it to connect. As the + If your router/access point uses DHCP to allocate IP addresses, you + can install <xref linkend="dhcp"/> client and use it to + automatically obtain network addresses. Create the + <filename>/etc/sysconfig/ifconfig-<replaceable>wlan0</replaceable> + </filename> by running the following command as the + <systemitem class="username">root</systemitem> user: + </para> + +<screen role="root"><userinput>cat > /etc/sysconfig/ifconfig.<replaceable>wlan0</replaceable> << "EOF" +<literal>ONBOOT="yes" +IFACE="<replaceable>wlan0</replaceable>" +SERVICE="wpa" + +# Additional arguments to wpa_supplicant +WPA_ARGS="" + +WPA_SERVICE="dhclient" +DHCP_START="" +DHCP_STOP="" + +# Set PRINTIP="yes" to have the script print +# the DHCP assigned IP address +PRINTIP="no" + +# Set PRINTALL="yes" to print the DHCP assigned values for +# IP, SM, DG, and 1st NS. This requires PRINTIP="yes". +PRINTALL="no"</literal> +EOF</userinput></screen> + + <para> + If you prefer <xref linkend="dhcpcd"/> instead of + <xref linkend="dhcp"/> client, then create the + <filename>/etc/sysconfig/ifconfig-<replaceable>wlan0</replaceable> + </filename> by running the following command as the + <systemitem class="username">root</systemitem> user: + </para> + +<screen role="root"><userinput>cat > /etc/sysconfig/ifconfig.<replaceable>wlan0</replaceable> << "EOF" +<literal>ONBOOT="yes" +IFACE="<replaceable>wlan0</replaceable>" +SERVICE="wpa" + +# Additional arguments to wpa_supplicant +WPA_ARGS="" + +WPA_SERVICE="dhcpcd" +DHCP_START="-b -q <replaceable><insert appropriate start options here></replaceable>" +DHCP_STOP="-k <replaceable><insert additional stop options here></replaceable>"</literal> +EOF</userinput></screen> + + <para> + Alternatively, if you use static addresses on your local network, + then create the + <filename>/etc/sysconfig/ifconfig-<replaceable>wlan0</replaceable> + </filename> by running the following command as the <systemitem class="username">root</systemitem> user: </para> -<screen role="root"><userinput>wpa_supplicant -B -c/etc/wpa_supplicant.conf -iwlan0 -Dnl80211,wext -sleep 2 # let it settle -dhcpcd</userinput></screen> +<screen role="root"><userinput>cat > /etc/sysconfig/ifconfig.<replaceable>wlan0</replaceable> << "EOF" +<literal>ONBOOT="yes" +IFACE="<replaceable>wlan0</replaceable>" +SERVICE="wpa" + +# Additional arguments to wpa_supplicant +WPA_ARGS="" + +WPA_SERVICE="ipv4-static" +IP="192.168.1.1" +GATEWAY="192.168.1.2" +PREFIX="24" +BROADCAST="192.168.1.255"</literal> +EOF</userinput></screen> <para> - Alternatively, you can use static addresses on your local network. - This has the advantage that you can put the hostnames in - <filename>/etc/hosts</filename>. Replace 192.168.1.6 with the static - address you've chosen. Replace 192.168.1.1 with the local IP address of - the access point/router. Run the following commands as the + You can connect to the wireless access point by + running the following command as the <systemitem class="username">root</systemitem> user: </para> -<screen role="root"><userinput>ip addr add 192.168.1.6 dev wlan0 -ip link set wlan0 up -wpa_supplicant -B -c/etc/wpa_supplicant.conf -iwlan0 -Dnl80211,wext -ip route add 192.168.1.1 dev wlan0 -ip route add default via 192.168.1.1 dev wlan0</userinput></screen> +<screen role="root"><userinput>ifup <replaceable>wlan0</replaceable></userinput></screen> + + <para> + Replace <replaceable>wlan0</replaceable> with the correct + wireless interface. + </para> </sect3> + </sect2> <sect2 role="content"> Modified: trunk/bootscripts/blfs/services/dhclient ============================================================================== --- trunk/bootscripts/blfs/services/dhclient Sun Feb 10 13:48:21 2013 (r11011) +++ trunk/bootscripts/blfs/services/dhclient Mon Feb 11 08:22:35 2013 (r11012) @@ -14,10 +14,13 @@ . /lib/lsb/init-functions . $IFCONFIG +PIDFILE=/run/dhclient-$1.pid +LFILE=/var/lib/dhclient/dhclient-$1.leases + getipstats() { # Print the last 16 lines of dhclient.leases - sed -e :a -e '$q;N;17,$D;ba' /var/lib/dhclient/dhclient-$1.leases + sed -e :a -e '$q;N;17,$D;ba' ${LFILE} } # Make compatible with older versions of init-functions @@ -32,14 +35,19 @@ case "$2" in up) - if [ -e /run/dhclient-$1.pid ]; then - log_warning_msg "\n dhclient appears to be running on $1" - exit 0 + if [ -e ${PIDFILE} ]; then + ps $(cat ${PIDFILE}) | grep dhclient >/dev/null + if [ "$?" = "0" ]; then + log_warning_msg "\n dhclient appears to be running on $1" + exit 0 + else + rm ${PIDFILE} + fi fi log_info_msg "\n Starting dhclient on the $1 interface..." - /sbin/dhclient -lf /var/lib/dhclient/dhclient-$1.leases -pf /run/dhclient-$1.pid $DHCP_START $1 + /sbin/dhclient -lf ${LFILE} -pf ${PIDFILE} $DHCP_START $1 if [ "$?" != "0" ]; then log_failure_msg2 @@ -83,15 +91,20 @@ ;; down) - if [ ! -e /run/dhclient-$1.pid ]; then - log_warning_msg "dhclient doesn't appear to be running on $1" + if [ ! -e ${PIDFILE} ]; then + log_warning_msg "\n dhclient doesn't appear to be running on $1" exit 0 fi log_info_msg "\n Stopping dhclient on the $1 interface..." - /sbin/dhclient -r -lf /var/lib/dhclient/dhclient-$1.leases -pf /run/dhclient-$1.pid $DHCP_STOP $1 - rm -f /run/dhclient-$1.pid + /sbin/dhclient -r -lf ${LFILE} -pf ${PIDFILE} $DHCP_STOP $1 + + ps $(cat ${PIDFILE}) | grep dhclient >/dev/null + if [ "$?" != "0" ]; then + rm -f ${PIDFILE} + fi + evaluate_retval ;; Modified: trunk/bootscripts/blfs/services/wpa ============================================================================== --- trunk/bootscripts/blfs/services/wpa Sun Feb 10 13:48:21 2013 (r11011) +++ trunk/bootscripts/blfs/services/wpa Mon Feb 11 08:22:35 2013 (r11012) @@ -12,12 +12,20 @@ . /lib/lsb/init-functions . $IFCONFIG +PIDFILE=/run/wpa_supplicant/$1.pid +CONTROL_IFACE=/run/wpa_supplicant/$1 + case "$2" in up) - if [ -e /run/wpa_supplicant/$1.pid ]; then - log_warning_msg "\n wpa_supplicant already running on $1." - exit 0 + if [ -e ${PIDFILE} ]; then + ps $(cat ${PIDFILE}) | grep wpa_supplicant >/dev/null + if [ "$?" = "0" ]; then + log_warning_msg "\n wpa_supplicant already running on $1." + exit 0 + else + rm ${PIDFILE} + fi fi if [ ! -e /etc/sysconfig/wpa_supplicant-$1.conf ]; then @@ -30,7 +38,7 @@ mkdir -p /run/wpa_supplicant - /sbin/wpa_supplicant -q -B -Dnl80211,wext -P/run/wpa_supplicant/$1.pid -C/run/wpa_supplicant -c/etc/sysconfig/wpa_supplicant-$1.conf -i$1 ${WPA_ARGS} + /sbin/wpa_supplicant -q -B -Dnl80211,wext -P${PIDFILE} -C/run/wpa_supplicant -c/etc/sysconfig/wpa_supplicant-$1.conf -i$1 ${WPA_ARGS} if [ "$?" != "0" ]; then log_failure_msg2 @@ -61,9 +69,9 @@ log_info_msg "\n Stopping wpa_supplicant on the $1 interface..." - if [ -e /run/wpa_supplicant/$1.pid ]; then - kill -9 $(cat /run/wpa_supplicant/$1.pid) - rm -f /run/wpa_supplicant/$1.pid /run/wpa_supplicant/$1 + if [ -e ${PIDFILE} ]; then + kill -9 $(cat ${PIDFILE}) + rm -f ${PIDFILE} ${CONTROL_IFACE} evaluate_retval else log_warning_msg "\n wpa_supplicant already stopped on $1" -- http://linuxfromscratch.org/mailman/listinfo/blfs-book FAQ: http://www.linuxfromscratch.org/blfs/faq.html Unsubscribe: See the above information page
