# HG changeset patch # User Aleksej Bobylev # Date 1440584114 -10800 # Node ID 528e2425397013fde0807f013332f7e86da75eaf # Parent 68f4d6a8f6a09b7011a025b98c9a6527b304c5cc hosts.cgi: change folder for saving lists state to /var/run/... diff -r 68f4d6a8f6a0 -r 528e24253970 hosts.cgi --- a/hosts.cgi Wed Aug 26 09:13:07 2015 +0200 +++ b/hosts.cgi Wed Aug 26 13:15:14 2015 +0300 @@ -26,7 +26,7 @@ # now hosts='host1 host2 ... hostn' # Folder to save downloaded and installed hosts lists -HOSTSDIR='/var/cache/tazpanel/hosts' +HOSTSDIR='/var/run/tazpanel/hosts' mkdir -p "$HOSTSDIR" @@ -54,7 +54,7 @@ # Install the list instlist() { - # Input: list=code letter, url=download url + # Input: list=code letter, url=download URL file="$HOSTSDIR/$list" [ -f "$file" ] && rm "$file" busybox wget -O "$file" "$url" @@ -240,9 +240,12 @@ EOT - if [ -e "$HOSTSDIR/$letter" ]; then + if [ -e "$HOSTSDIR/$letter" -o -n "$(grep -m1 "#$letter\$" /etc/hosts)" ]; then # List installed + # If /var/run/tazpkg/hosts/ was mistakenly cleaned + [ ! -f "$HOSTSDIR/$letter" ] && touch "$HOSTSDIR/$letter" + # Check for upgrades (once a day) if [ -f "$HOSTSDIR/$letter.up" ]; then # Update checked previously @@ -262,10 +265,10 @@ # Check for update (not really download) busybox wget -s --header "If-Modified-Since: $(date -Rur "$HOSTSDIR/$letter")" "$url" if [ "$?" -eq 0 ]; then - # Upgrade available + # Update available touch "$HOSTSDIR/$letter.avail" else - # Upgrade not available + # Update not available rm "$HOSTSDIR/$letter.avail" 2>/dev/null fi touch "$HOSTSDIR/$letter.up"