slitaz-boot-scripts rev 433
network.sh: more checks to keep Boot Log clean; change notification icons
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Tue May 24 17:20:44 2016 +0300 (2016-05-24) |
parents | ae63069a080f |
children | d8e26d386dd6 |
files | etc/init.d/network.sh |
line diff
1.1 --- a/etc/init.d/network.sh Mon May 23 14:19:56 2016 +0300 1.2 +++ b/etc/init.d/network.sh Tue May 24 17:20:44 2016 +0300 1.3 @@ -59,12 +59,17 @@ 1.4 1.5 notification() { 1.6 ps aux 2>/dev/null | grep -q [X]org || return 1.7 + [ -n "$DISPLAY" ] || return 1.8 + which notify-send >/dev/null || return 1.9 + 1.10 + icon=$(echo $1 | awk -vw=$WIFI '{printf("notification-network-%s%s\n", 1.11 + w=="yes"?"wireless":"wired", /start/?"":"-disconnected");}') 1.12 + 1.13 # FIXME: this valid only for lxde-session 1.14 local user="$(ps aux 2>/dev/null | grep [l]xde-session | awk 'END{print $2}')" 1.15 - local icon="$1" rpid='' 1.16 + local rpid='' 1.17 [ -s "$npid" ] && rpid="-r $(cat $npid)" 1.18 - which notify-send >/dev/null && 1.19 - su -c "notify-send $rpid -p -i $icon 'Network' \"$2\"" - $user | tail -n1 > $npid 1.20 + su -c "notify-send $rpid -p -i $icon 'Network' \"$2\"" - $user | tr -c 0-9 '\n' | tail -n1 > $npid 1.21 } 1.22 1.23 1.24 @@ -76,7 +81,9 @@ 1.25 su -l -c "$0 netapplet" - "$user" 1.26 done 1.27 # restart if LXPanel running 1.28 - which lxpanelctl > /dev/null && lxpanelctl restart 1.29 + if [ -n "$DISPLAY" -a -n "$(which lxpanelctl)" ]; then 1.30 + lxpanelctl restart 1.31 + fi 1.32 } 1.33 1.34 1.35 @@ -84,7 +91,7 @@ 1.36 1.37 eth() { 1.38 if [ "$WIFI" != 'yes' ]; then 1.39 - notification network-wired "$(_ 'Starting Ethernet interface %s...' "$INTERFACE")" 1.40 + notification start "$(_ 'Starting Ethernet interface %s...' "$INTERFACE")" 1.41 ifconfig $INTERFACE up 1.42 sleep 5 1.43 fi 1.44 @@ -107,7 +114,7 @@ 1.45 # notwithstanding to priority when scan_ssid=1 1.46 current_ssid="$(wpa_cli list_networks 2>/dev/null | fgrep '[CURRENT]' | cut -f2)" 1.47 if [ "$current_ssid" != "$WIFI_ESSID" ]; then 1.48 - notification network-wireless "$(_ 'Connecting to %s...' "$WIFI_ESSID")" 1.49 + notification start "$(_ 'Connecting to %s...' "$WIFI_ESSID")" 1.50 action 'Connecting to $WIFI_ESSID...' 1.51 for i in $(seq 5); do 1.52 index=$(wpa_cli list_networks 2>/dev/null | \ 1.53 @@ -145,7 +152,7 @@ 1.54 /etc/network.conf 1.55 fi 1.56 1.57 - notification network-wireless "$(_ 'Starting Wi-Fi interface %s...' "$WIFI_INTERFACE")" 1.58 + notification start "$(_ 'Starting Wi-Fi interface %s...' "$WIFI_INTERFACE")" 1.59 action 'Configuring Wi-Fi interface $WIFI_INTERFACE...' 1.60 ifconfig $WIFI_INTERFACE up 2>/dev/null 1.61 if iwconfig $WIFI_INTERFACE | fgrep -q 'Tx-Power'; then 1.62 @@ -333,7 +340,7 @@ 1.63 1.64 stop() { 1.65 ch_netapplet 1.66 - notification network-offline "$(_ 'Stopping all interfaces')" 1.67 + notification stop "$(_ 'Stopping all interfaces')" 1.68 echo 'Stopping all interfaces' 1.69 for iface in $(ifconfig | sed -e '/^[^ ]/!d' -e 's|^\([^ ]*\) .*|\1|' -e '/lo/d'); do 1.70 ifconfig $iface down