Hello development folks,
the following patch is the first attempt of cleaning the all shell scripts we use in and around IPFire 2.x, which is necessary as they contain quite some glitches (most of them are aesthetic or balancing ones, but some might be more severe, especially when it comes to malfunctions due to unexpected input) and IPFire 3.x probably will not be arriving that fast.
In other words, there is no sense in delaying the inevitable.
There is an umbrealla bug for this task (#12398) assigned to my humble self, but to make sure my changes are welcomed by the development community, I start with the hostapd initscript and wait for comments. If they are positive, I plan to clean up all the 132 shell scripts one by one.
Please refer to #12398 for further information about the progress and what I am going to do. Patches and commits will be tracked there.
Looking forward to your opinions.
Thanks, and best regards, Peter Müller
- replaced /bin/sh by /bin/bash - fixed indentaion - updated copyright banner - attempt to eliminate shellcheck issues
Partially fixes: #12398
Signed-off-by: Peter Müller peter.mueller@ipfire.org --- src/initscripts/packages/hostapd | 38 ++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 9 deletions(-)
diff --git a/src/initscripts/packages/hostapd b/src/initscripts/packages/hostapd index 5945375f3..60f50cace 100644 --- a/src/initscripts/packages/hostapd +++ b/src/initscripts/packages/hostapd @@ -1,6 +1,26 @@ -#!/bin/sh +#!/bin/bash +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2020 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +############################################################################### + . /etc/sysconfig/rc -. ${rc_functions} +. "${rc_functions}"
CHANNEL="6" COUNTRY="00" @@ -8,7 +28,7 @@ TXPOWER="auto" INTERFACE="blue0" MACMODE="0"
-eval $(/usr/local/bin/readhash /var/ipfire/wlanap/settings) +eval "$(/usr/local/bin/readhash /var/ipfire/wlanap/settings)"
case "${1}" in start) @@ -18,21 +38,21 @@ case "${1}" in
# Check Interface configuration if [ ! -d "/sys/class/net/${INTERFACE}" ]; then - boot_mesg "Interface $INTERFACE doesn't exist." ${FAILURE} + boot_mesg "Interface $INTERFACE doesn't exist." "${FAILURE}" echo_failure exit 0 fi
if [ "$(ip link show $INTERFACE | /bin/grep "ether")" == "" ]; then - boot_mesg "Interface $INTERFACE is assigned to wlan master device." ${FAILURE} - boot_mesg "Please reboot to fix this." ${FAILURE} + boot_mesg "Interface $INTERFACE is assigned to wlan master device." "${FAILURE}" + boot_mesg "Please reboot to fix this." "${FAILURE}" echo_failure exit 0 fi
# Check if INTERFACE is an actual wireless device if [ ! -d "/sys/class/net/${INTERFACE}/wireless" ]; then - boot_mesg "Interface $INTERFACE is not a wireless device." ${FAILURE} + boot_mesg "Interface $INTERFACE is not a wireless device." "${FAILURE}" echo_failure exit 0 fi @@ -45,7 +65,7 @@ case "${1}" in DRIVER="HOSTAP" driver="hostap" else - boot_mesg "Interface $INTERFACE is a not supported wireless device." ${FAILURE} + boot_mesg "Interface $INTERFACE is a not supported wireless device." "${FAILURE}" echo_failure exit 0 fi @@ -86,7 +106,7 @@ case "${1}" in
if [ "$(/usr/sbin/iwconfig $INTERFACE | /bin/grep "Mode:Master")" == "" ]; then killproc /usr/bin/hostapd > /dev/null 2>&1 - boot_mesg "Try to create additional AP device ..." + boot_mesg "Try to create additional AP device ..." ip link set ${INTERFACE} down ip link set ${INTERFACE} name ${INTERFACE}_man iw dev ${INTERFACE}_man interface add ${INTERFACE} type __ap
Reviewed-by: Michael Tremer michael.tremer@ipfire.org
On 2 May 2020, at 10:15, Peter Müller peter.mueller@ipfire.org wrote:
- replaced /bin/sh by /bin/bash
- fixed indentaion
- updated copyright banner
- attempt to eliminate shellcheck issues
Partially fixes: #12398
Signed-off-by: Peter Müller peter.mueller@ipfire.org
src/initscripts/packages/hostapd | 38 ++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 9 deletions(-)
diff --git a/src/initscripts/packages/hostapd b/src/initscripts/packages/hostapd index 5945375f3..60f50cace 100644 --- a/src/initscripts/packages/hostapd +++ b/src/initscripts/packages/hostapd @@ -1,6 +1,26 @@ -#!/bin/sh +#!/bin/bash +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2020 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +###############################################################################
. /etc/sysconfig/rc -. ${rc_functions} +. "${rc_functions}"
CHANNEL="6" COUNTRY="00" @@ -8,7 +28,7 @@ TXPOWER="auto" INTERFACE="blue0" MACMODE="0"
-eval $(/usr/local/bin/readhash /var/ipfire/wlanap/settings) +eval "$(/usr/local/bin/readhash /var/ipfire/wlanap/settings)"
case "${1}" in start) @@ -18,21 +38,21 @@ case "${1}" in
# Check Interface configuration if [ ! -d "/sys/class/net/${INTERFACE}" ]; then
boot_mesg "Interface $INTERFACE doesn't exist." ${FAILURE}
boot_mesg "Interface $INTERFACE doesn't exist." "${FAILURE}" echo_failure exit 0
fi
if [ "$(ip link show $INTERFACE | /bin/grep "ether")" == "" ]; then
boot_mesg "Interface $INTERFACE is assigned to wlan master device." ${FAILURE}
boot_mesg "Please reboot to fix this." ${FAILURE}
boot_mesg "Interface $INTERFACE is assigned to wlan master device." "${FAILURE}"
boot_mesg "Please reboot to fix this." "${FAILURE}" echo_failure exit 0
fi
# Check if INTERFACE is an actual wireless device if [ ! -d "/sys/class/net/${INTERFACE}/wireless" ]; then
boot_mesg "Interface $INTERFACE is not a wireless device." ${FAILURE}
fiboot_mesg "Interface $INTERFACE is not a wireless device." "${FAILURE}" echo_failure exit 0
@@ -45,7 +65,7 @@ case "${1}" in DRIVER="HOSTAP" driver="hostap" else
boot_mesg "Interface $INTERFACE is a not supported wireless device." ${FAILURE}
fiboot_mesg "Interface $INTERFACE is a not supported wireless device." "${FAILURE}" echo_failure exit 0
@@ -86,7 +106,7 @@ case "${1}" in
if [ "$(/usr/sbin/iwconfig $INTERFACE | /bin/grep "Mode:Master")" == "" ]; then killproc /usr/bin/hostapd > /dev/null 2>&1
boot_mesg "Try to create additional AP device ..."
boot_mesg "Try to create additional AP device ..." ip link set ${INTERFACE} down ip link set ${INTERFACE} name ${INTERFACE}_man iw dev ${INTERFACE}_man interface add ${INTERFACE} type __ap
-- 2.26.1