WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: ifconfig in bootsync.sh doens't work as expected (Pi zero W as Access Point)  (Read 1788 times)

Offline Twist

  • Newbie
  • *
  • Posts: 41
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?

Offline Twist

  • Newbie
  • *
  • Posts: 41
I managed to fix this by inserting a sleep 1s between sethostname and ifconfig

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1063
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.

Offline Twist

  • Newbie
  • *
  • Posts: 41
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...)

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 661
I think you need to read the bootcodes for tinycore.

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


host=

Offline Twist

  • Newbie
  • *
  • Posts: 41
Hmmm, that was too easy...thanks

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1063
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