# HG changeset patch # User Aleksej Bobylev # Date 1427546022 -7200 # Node ID 28a9c8b642126c3b42665af06d9de9f54d51ee48 # Parent fb3932bbddf8eec962f692e3f863ea533bd5027d network.sh: bugfix: start Live CD with predefined wpa.conf, not with empty file; remove "any" network, it prevents to connect to regular AP; shrink sleep timing (20s to 5s). diff -r fb3932bbddf8 -r 28a9c8b64212 etc/init.d/network.sh --- a/etc/init.d/network.sh Wed Mar 25 00:29:48 2015 +0200 +++ b/etc/init.d/network.sh Sat Mar 28 14:33:42 2015 +0200 @@ -11,6 +11,7 @@ . "$CONF" WPA_CONF='/etc/wpa/wpa.conf' +[ ! -e "$WPA_CONF" ] && cp /etc/wpa/wpa_empty.conf $WPA_CONF # Migrate existing settings to a new format file @@ -59,7 +60,7 @@ current_ssid="$(wpa_cli list_networks 2>/dev/null | fgrep '[CURRENT]' | cut -f2)" if [ "$current_ssid" != "$WIFI_ESSID" ]; then echo "Connecting to $WIFI_ESSID..." - for i in $(seq 20); do + for i in $(seq 5); do index=$(wpa_cli list_networks 2>/dev/null | \ grep -m1 -F $'\t'$WIFI_ESSID$'\t' | head -n1 | cut -f1) [ -z "$index" ] && echo -n '.' && sleep 1 @@ -70,6 +71,15 @@ } +# Remove selected network settings from wpa.conf + +remove_network() { + mv -f $WPA_CONF $WPA_CONF.old + cat $WPA_CONF.old | tr '\n' '\a' | sed 's|[^#]\(network={\)|\n\1|g' | \ + fgrep -v "ssid=\"$1\"" | tr '\a' '\n' > $WPA_CONF +} + + # For Wi-Fi. Users just have to enable it through WIFI="yes" and usually # ESSID="any" will work and the interface is autodetected. @@ -99,6 +109,9 @@ [ -n "$WIFI_CHANNEL" ] && IWCONFIG_ARGS="$IWCONFIG_ARGS channel $WIFI_CHANNEL" [ -n "$WIFI_AP" ] && IWCONFIG_ARGS="$IWCONFIG_ARGS ap $WIFI_AP" + # Use "any" network only when it is needed + [ "$WIFI_ESSID" != 'any' ] && remove_network 'any' + # Clean all / add / change stored networks settings if [ "$WIFI_BLANK_NETWORKS" == 'yes' ]; then echo "Creating new $WPA_CONF" @@ -107,9 +120,7 @@ if fgrep -q ssid=\"$WIFI_ESSID\" $WPA_CONF; then echo "Change network settings in $WPA_CONF" # Remove given existing network (it's to be appended later) - mv -f $WPA_CONF $WPA_CONF.old - cat $WPA_CONF.old | tr '\n' '\a' | sed 's|[^#]\(network={\)|\n\1|g' | \ - fgrep -v "ssid=\"$WIFI_ESSID\"" | tr '\a' '\n' > $WPA_CONF + remove_network "$WIFI_ESSID" else echo "Append existing $WPA_CONF" fi