luci-app-mosdns: remove lockfile when adlist download fail
Signed-off-by: sbwml <admin@cooluc.com>
This commit is contained in:
parent
a4b8a30fb4
commit
49051dbca3
@ -56,7 +56,6 @@ adlist_update() {
|
|||||||
[ "$(uci -q get mosdns.config.adblock)" != 1 ] && return 0
|
[ "$(uci -q get mosdns.config.adblock)" != 1 ] && return 0
|
||||||
lock_file=/var/lock/mosdns_ad_update.lock
|
lock_file=/var/lock/mosdns_ad_update.lock
|
||||||
ad_source=$(uci -q get mosdns.config.ad_source)
|
ad_source=$(uci -q get mosdns.config.ad_source)
|
||||||
AD_TMPDIR=$(mktemp -d) || exit 1
|
|
||||||
mirror=""
|
mirror=""
|
||||||
: > /etc/mosdns/rule/.ad_source
|
: > /etc/mosdns/rule/.ad_source
|
||||||
if [ -f "$lock_file" ]; then
|
if [ -f "$lock_file" ]; then
|
||||||
@ -65,6 +64,7 @@ adlist_update() {
|
|||||||
else
|
else
|
||||||
: > $lock_file
|
: > $lock_file
|
||||||
fi
|
fi
|
||||||
|
AD_TMPDIR=$(mktemp -d) || exit 1
|
||||||
has_update=0
|
has_update=0
|
||||||
for url in $ad_source;
|
for url in $ad_source;
|
||||||
do
|
do
|
||||||
@ -81,7 +81,7 @@ adlist_update() {
|
|||||||
done
|
done
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo -e "\e[1;31mRules download failed.\e[0m"
|
echo -e "\e[1;31mRules download failed.\e[0m"
|
||||||
rm -rf "$AD_TMPDIR"
|
rm -rf "$AD_TMPDIR" "$lock_file"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
[ $has_update -eq 1 ] && {
|
[ $has_update -eq 1 ] && {
|
||||||
@ -90,7 +90,7 @@ adlist_update() {
|
|||||||
\cp $AD_TMPDIR/* /etc/mosdns/rule/adlist
|
\cp $AD_TMPDIR/* /etc/mosdns/rule/adlist
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
rm -rf "$AD_TMPDIR" $lock_file
|
rm -rf "$AD_TMPDIR" "$lock_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
geodat_update() (
|
geodat_update() (
|
||||||
|
Loading…
Reference in New Issue
Block a user