I'd like to create a script that tries to connect me to the wifi specified by my wpa_supplicant conf, and if it fails, create a ad-hoc network. But I'm struggling with it.Here is what I do for now:#!/bin/bash# create adhoc network functioncreateAdHocNetwork(){    echo Creating ad-hoc network    ifconfig wlan0 down    iwconfig wlan0 mode ad-hoc    iwconfig wlan0 essid AccessPoint    ifconfig wlan0 11.0.0.1 netmask 255.255.255.0 up    echo Ad-hoc network created}# connect to wifi functionconnect(){    echo Trying to connect to configured wifi    ifdown wlan0    wpa_supplicant -B -i wlan0 -c /home/pi/pics/wpa_supplicant.conf    ifup wlan0    echo Wifi configured}echo =================================echo Wifi setupecho =================================connectecho Checking connectivity...sleep 5sping -c 5 -I wlan0 google.com > /dev/null 2>&1PINGSTATUS=$?echo Statusecho $PINGSTATUSif [ $PINGSTATUS -eq 0 ];    then        echo Connected to WiFi    else        echo Wifi not connected, fallback to ad-hoc        createAdHocNetworkfiexit 0It seems it works to connect to the configured wifi, but not for ad-hoc.Here is my /etc/network/interfaces :# start interfaces upon start of the systemauto lo wlan0# register loopback interfaceiface lo inet loopback# use dhcp and allow interface to be started when kernel detects a hotplug eventallow-hotplug eth0iface eth0 inet dhcp# use manual ip configuration for wlan0 interface and allow hotplug as wellallow-hotplug wlan0iface wlan0 inet dhcpAnd my /etc/dhcp/dhcpd.conf:ddns-update-style interim;default-lease-time 600;max-lease-time 7200;authoritative;log-facility local7;subnet 11.0.0.0 netmask 255.255.255.0 {  range 11.0.0.2 11.0.0.150;}I can see the ad-hoc network from other computer, but I cannot connect to it, any idea?Regards
Create a script that connect to wifi, and if it fails fallback to ad-hoc network
networking;wifi;wifi hotspot