tazpanel diff hosts.cgi @ rev 529
hosts.cgi: change folder for saving lists state to /var/run/...
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Wed Aug 26 13:15:14 2015 +0300 (2015-08-26) |
parents | 3d4145137792 |
children | 34508d2309a6 |
line diff
1.1 --- a/hosts.cgi Wed Aug 26 05:51:08 2015 +0300 1.2 +++ b/hosts.cgi Wed Aug 26 13:15:14 2015 +0300 1.3 @@ -26,7 +26,7 @@ 1.4 # now hosts='host1 host2 ... hostn' 1.5 1.6 # Folder to save downloaded and installed hosts lists 1.7 -HOSTSDIR='/var/cache/tazpanel/hosts' 1.8 +HOSTSDIR='/var/run/tazpanel/hosts' 1.9 mkdir -p "$HOSTSDIR" 1.10 1.11 1.12 @@ -54,7 +54,7 @@ 1.13 1.14 # Install the list 1.15 instlist() { 1.16 - # Input: list=code letter, url=download url 1.17 + # Input: list=code letter, url=download URL 1.18 file="$HOSTSDIR/$list" 1.19 [ -f "$file" ] && rm "$file" 1.20 busybox wget -O "$file" "$url" 1.21 @@ -240,9 +240,12 @@ 1.22 <td> 1.23 EOT 1.24 1.25 - if [ -e "$HOSTSDIR/$letter" ]; then 1.26 + if [ -e "$HOSTSDIR/$letter" -o -n "$(grep -m1 "#$letter\$" /etc/hosts)" ]; then 1.27 # List installed 1.28 1.29 + # If /var/run/tazpkg/hosts/ was mistakenly cleaned 1.30 + [ ! -f "$HOSTSDIR/$letter" ] && touch "$HOSTSDIR/$letter" 1.31 + 1.32 # Check for upgrades (once a day) 1.33 if [ -f "$HOSTSDIR/$letter.up" ]; then 1.34 # Update checked previously 1.35 @@ -262,10 +265,10 @@ 1.36 # Check for update (not really download) 1.37 busybox wget -s --header "If-Modified-Since: $(date -Rur "$HOSTSDIR/$letter")" "$url" 1.38 if [ "$?" -eq 0 ]; then 1.39 - # Upgrade available 1.40 + # Update available 1.41 touch "$HOSTSDIR/$letter.avail" 1.42 else 1.43 - # Upgrade not available 1.44 + # Update not available 1.45 rm "$HOSTSDIR/$letter.avail" 2>/dev/null 1.46 fi 1.47 touch "$HOSTSDIR/$letter.up"