Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: Twist on June 15, 2018, 01:57:27 AM

Title: ifconfig in bootsync.sh doens't work as expected (Pi zero W as Access Point)
Post by: Twist on June 15, 2018, 01:57:27 AM
Hi all, still very new to tiny core, and even newer to this forum.

I'm in the process of setting up a raspi zero W as an access point. Partly using the instruction at http://brezular.com/wp-content/uploads/2017/12/router-manual.txt to get going.

My bootsynch.sh reads:
Code: [Select]
/usr/bin/sethostname FluxMux
ifconfig wlan0 192.168.127.1 netmask 255.255.255.0
dnsmasq -C /etc/dnsmasq.conf
/opt/bootlocal.sh &

And in bootlocal.sh I have:
hostapd /etc/hostapd.conf

Once booted my wlan0 has an IP6 but not the configured IP4 address... When I then manually issue
Quote
ifconfig wlan0 192.168.127.1 netmask 255.255.255.0
and restart hostapd things work fine.

Am I missing something?
Title: Re: ifconfig in bootsync.sh doens't work as expected (Pi zero W as Access Point)
Post by: Twist on June 15, 2018, 08:18:21 AM
I managed to fix this by inserting a sleep 1s between sethostname and ifconfig
Title: Re: ifconfig in bootsync.sh doens't work as expected (Pi zero W as Access Point)
Post by: Paul_123 on June 18, 2018, 07:31:20 AM
For what it is worth, you need to set the the hostname on the kernel commandline.  Setting it where you are doing it is not reliable.

Also, network configuration is done in the background, so your sleep command is just enough delay to let the network finish configuring before launch.   It might be better to actually check for network configuration rather than just a blind sleep.
Title: Re: ifconfig in bootsync.sh doens't work as expected (Pi zero W as Access Point)
Post by: Twist on June 18, 2018, 01:02:41 PM
Thanks for your reply Paul_123

I'd be keen to do this 'the proper way', but I don't know how.

I don't know what I need to put into the command.txt file to set a hostname. When googling I just find it is not possible...
How do I check if the network config is done? (Started at sleep 10s, then 5, then 2, 1 still worked...)
Title: Re: ifconfig in bootsync.sh doens't work as expected (Pi zero W as Access Point)
Post by: patrikg on June 18, 2018, 01:20:14 PM
I think you need to read the bootcodes for tinycore.

http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes


host=
Title: Re: ifconfig in bootsync.sh doens't work as expected (Pi zero W as Access Point)
Post by: Twist on June 18, 2018, 01:54:54 PM
Hmmm, that was too easy...thanks
Title: Re: ifconfig in bootsync.sh doens't work as expected (Pi zero W as Access Point)
Post by: Paul_123 on June 19, 2018, 01:05:26 PM
Here is a simple script that we use to check for the network to be configured.   It tests the connection every 0.5s until it is configured (20 seconds max).  In this case we look for a Bcast address to make that determination.

Code: [Select]
CNT=1
until ifconfig | grep -q Bcast
do
        if [ $((CNT++)) -gt 40 ]; then
#               echo -n "No network found!"
                break
        else
#               echo -n "."
                sleep 0.5
        fi
done