tazpanel rev 637
network.cgi: fix wait_up()
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Nov 09 10:08:06 2021 +0000 (2021-11-09) |
parents | cd2735c8e31b |
children | ddf3a6575b62 |
files | boot.cgi hosts.cgi index.cgi lib/libtazpanel network.cgi powersaving.cgi settings.cgi |
line diff
1.1 --- a/boot.cgi Sun Sep 27 16:27:37 2020 +0000 1.2 +++ b/boot.cgi Tue Nov 09 10:08:06 2021 +0000 1.3 @@ -157,7 +157,7 @@ 1.4 # Name 1.5 echo "<td>$name</td>" 1.6 # First check if daemon is started at boottime 1.7 - [ echo "RUN_DAEMONS" | fgrep $name ] && boot="on boot" 1.8 + echo "RUN_DAEMONS" | fgrep -q $name && boot="on boot" 1.9 # Standard SliTaz busybox daemons and firewall 1.10 echo -n "<td>" 1.11 grep -qi "^${name}_OPTIONS=" /etc/daemons.conf && cfg="options|$cfg" 1.12 @@ -350,7 +350,7 @@ 1.13 entry='-1' 1.14 echo "$menu" | while read line 1.15 do 1.16 - if [ -n "$(echo $line | grep '#</header>')" ]; then 1.17 + if echo $line | grep -q '#</header>'; then 1.18 entry=$(($entry + 1)) 1.19 fi 1.20 echo $line | sed "s|#</header>|$entry</header>|" 1.21 @@ -387,7 +387,7 @@ 1.22 1.23 [ "$iso" ] || msg err "$(_ 'Invalid ISO image.')" 1.24 1.25 - if [ "$iso" -a "$action" -a "$action" != "nop" ]; then 1.26 + if [ "$iso" ] && [ "$action" ] && [ "$action" != "nop" ]; then 1.27 case "$action" in 1.28 install*) dev=$(POST instdev) ;; 1.29 *) dev=$(POST usbkeydev) ;; 1.30 @@ -487,7 +487,7 @@ 1.31 <button name="syslog" data-icon="@logs@">$(_ 'System logs')</button> 1.32 <button name="daemons" data-icon="@daemons@" data-root>$(_ 'Manage daemons')</button> 1.33 EOT 1.34 - [ "$REMOTE_USER" = "root" -a -x /usr/bin/taziso ] && cat <<EOT 1.35 + [ "$REMOTE_USER" = "root" ] && [ -x /usr/bin/taziso ] && cat <<EOT 1.36 <button name="iso" data-icon="@cd@">$(_ 'ISO mine')</button> 1.37 EOT 1.38 [ -w /boot/grub/menu.lst ] && cat <<EOT
2.1 --- a/hosts.cgi Sun Sep 27 16:27:37 2020 +0000 2.2 +++ b/hosts.cgi Tue Nov 09 10:08:06 2021 +0000 2.3 @@ -158,7 +158,7 @@ 2.4 # Show diff 2.5 if [ -s "$HOSTSDIR/diff" ]; then 2.6 echo '<section><pre class="scroll">' 2.7 - cat "$HOSTSDIR/diff" | syntax_highlighter diff 2.8 + syntax_highlighter diff < "$HOSTSDIR/diff" 2.9 echo '</pre></section>' 2.10 fi 2.11 2.12 @@ -264,7 +264,7 @@ 2.13 <td> 2.14 EOT 2.15 2.16 - if [ -e "$HOSTSDIR/$letter" -o -n "$(grep -m1 "#$letter\$" /etc/hosts)" ]; then 2.17 + if [ -e "$HOSTSDIR/$letter" ] || grep -qm1 "#$letter\$" /etc/hosts; then 2.18 # List installed 2.19 2.20 # If /var/run/tazpkg/hosts/ was mistakenly cleaned 2.21 @@ -287,8 +287,7 @@ 2.22 2.23 if [ "$check" = 'yes' ]; then 2.24 # Check for update (not really download) 2.25 - busybox wget -s --header "If-Modified-Since: $(date -Rur "$HOSTSDIR/$letter")" "$url" 2.26 - if [ "$?" -eq 0 ]; then 2.27 + if busybox wget -s --header "If-Modified-Since: $(date -Rur "$HOSTSDIR/$letter")" "$url"; then 2.28 # Update available 2.29 touch "$HOSTSDIR/$letter.avail" 2.30 else
3.1 --- a/index.cgi Sun Sep 27 16:27:37 2020 +0000 3.2 +++ b/index.cgi Tue Nov 09 10:08:06 2021 +0000 3.3 @@ -102,7 +102,7 @@ 3.4 # Localized description 3.5 desc="$(sed -n "s|^.*xml:lang=\"${LANG%%_*}\">\(.*\)<.*|\1|p" $mimefile)" 3.6 fi 3.7 - if [ -z "$LANG" -o -z "$desc" ]; then 3.8 + if [ -z "$LANG" ] || [ -z "$desc" ]; then 3.9 # Default (English) description 3.10 desc="$(sed -n "s|^.*<comment>\(.*\)<.*|\1|p" $mimefile)" 3.11 fi 3.12 @@ -110,7 +110,7 @@ 3.13 pattern=$(sed -n 's|^.*pattern=\"\(.*\)\".*|\1|p' $mimefile) 3.14 extra="$extra --file-filter='$desc|$(echo $pattern)'" 3.15 fi 3.16 - icon="$(echo $(GET type) | tr '/' '-')" 3.17 + icon="$(GET type | tr '/' '-')" 3.18 fi 3.19 3.20 header 3.21 @@ -268,7 +268,7 @@ 3.22 *.ini) 3.23 echo '<code class="language-ini">'; end_code='</code>' 3.24 htmlize ;; 3.25 - *.conf|*.lst) 3.26 + *.lst) 3.27 syntax_highlighter conf ;; 3.28 *Xorg.0.log) 3.29 syntax_highlighter xlog ;;
4.1 --- a/lib/libtazpanel Sun Sep 27 16:27:37 2020 +0000 4.2 +++ b/lib/libtazpanel Tue Nov 09 10:08:06 2021 +0000 4.3 @@ -404,7 +404,7 @@ 4.4 if [ -n "$(which getent)" ]; then 4.5 getent "$1" 4.6 else 4.7 - cat "/etc/$1" | sed '/^#/d' 4.8 + sed '/^#/d' < "/etc/$1" 4.9 fi 4.10 } 4.11
5.1 --- a/network.cgi Sun Sep 27 16:27:37 2020 +0000 5.2 +++ b/network.cgi Tue Nov 09 10:08:06 2021 +0000 5.3 @@ -29,7 +29,7 @@ 5.4 5.5 # Sleep until connection established (max 5 seconds) 5.6 for i in $(seq 5); do 5.7 - [ -n "$(iwconfig 2>/dev/null | fgrep Link)" ] && break 5.8 + iwconfig 2>/dev/null | fgrep -q Link && break 5.9 sleep 1 5.10 done 5.11 } 5.12 @@ -108,7 +108,7 @@ 5.13 5.14 wait_up() { 5.15 for i in $(seq 5); do 5.16 - [ -z "$(cat /sys/class/net/*/operstate | fgrep up)"] && sleep 1 5.17 + cat /sys/class/net/*/operstate | fgrep -q up || sleep 1 5.18 done 5.19 } 5.20 5.21 @@ -150,7 +150,7 @@ 5.22 ;; 5.23 *\ hostname\ *) 5.24 hostname="$(GET hostname)" 5.25 - echo $(_ 'Changed hostname: %s' "$hostname") | log 5.26 + _ 'Changed hostname: %s' "$hostname" | log 5.27 echo "$hostname" > /etc/hostname;; 5.28 *\ rmarp\ *) 5.29 arp -d $(urldecode "$(GET entry)") ;; 5.30 @@ -393,10 +393,10 @@ 5.31 5.32 # Authentication type 5.33 AUTH="$(echo "$SCAN" | sed -n 's|.*Authentication Suites[^:]*: *\(.*\)|\1|p')" 5.34 - if [ -n "$(echo -n $AUTH | fgrep PSK)" ]; then 5.35 + if echo -n $AUTH | fgrep -q PSK; then 5.36 # WPA-Personal. Authentication using password (PSK = pre-shared key) 5.37 WIFI_KEY_TYPE='WPA' 5.38 - elif [ -n "$(echo -n $AUTH | fgrep 802.1x)" ]; then 5.39 + elif echo -n $AUTH | fgrep -q 802.1x; then 5.40 # WPA-Enterprise. Authentication using username, password, certificates... 5.41 WIFI_KEY_TYPE='EAP' 5.42 else 5.43 @@ -725,7 +725,7 @@ 5.44 [ $(($(cat /sys/class/net/$i/flags) & 0x1080)) -eq 4096 ] && 5.45 echo $i 5.46 done)" 5.47 - if [ "$REMOTE_USER" = "root" -a -n "$devs" ]; then 5.48 + if [ "$REMOTE_USER" = "root" ] && [ -n "$devs" ]; then 5.49 cat <<EOT 5.50 <section> 5.51 <header id="vlan">$(_ 'VLAN')</header> 5.52 @@ -837,7 +837,7 @@ 5.53 </section> 5.54 5.55 EOT 5.56 - [ "$REMOTE_USER" = "root" -a "$(which iptables-save)" ] && cat <<EOT 5.57 + [ "$REMOTE_USER" = "root" ] && [ "$(which iptables-save)" ] && cat <<EOT 5.58 <section> 5.59 <header id="iptables">$(_ 'Firewall') 5.60 $(edit_button /etc/knockd.conf "$(_ 'Port knocker')")
6.1 --- a/powersaving.cgi Sun Sep 27 16:27:37 2020 +0000 6.2 +++ b/powersaving.cgi Tue Nov 09 10:08:06 2021 +0000 6.3 @@ -21,7 +21,7 @@ 6.4 case "$p" in 6.5 governor) 6.6 for i in /sys/devices/system/cpu/cpu*/cpufreq ; do 6.7 - echo "$(POST $p)" > $i/scaling_governor 6.8 + POST $p > $i/scaling_governor 6.9 done 6.10 esac 6.11 done