mirror of
https://codeberg.org/h3xx/you-dont-need-pihole.git
synced 2024-08-14 20:27:01 +00:00
Remove 'set -e'
Makes scripts less able to handle errors properly.
This commit is contained in:
parent
06e9f59489
commit
942465cc22
1 changed files with 11 additions and 13 deletions
24
update.sh
24
update.sh
|
@ -13,8 +13,6 @@
|
|||
# You may NOT use this software for commercial purposes.
|
||||
###############################################################################
|
||||
|
||||
set -e
|
||||
|
||||
WORKDIR=${0%/*}
|
||||
CFG=$WORKDIR/update.cfg
|
||||
|
||||
|
@ -26,7 +24,7 @@ OUT=()
|
|||
URL=()
|
||||
DNSMASQ_RESTART_COMMAND=()
|
||||
if [[ -f $CFG ]]; then
|
||||
. "$CFG"
|
||||
. "$CFG" || exit
|
||||
fi
|
||||
|
||||
TEMP_DIR=$(mktemp -d -t "${0##*/}.XXXXXX")
|
||||
|
@ -37,9 +35,9 @@ trap 'cleanup' EXIT
|
|||
|
||||
copy_perms() {
|
||||
local -r FROM=$1 TO=$2
|
||||
chmod --reference="$FROM" -- "$TO"
|
||||
chmod --reference="$FROM" -- "$TO" || exit
|
||||
if [[ $UID -eq 0 ]]; then
|
||||
chown --reference="$FROM" -- "$TO"
|
||||
chown --reference="$FROM" -- "$TO" || exit
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -50,12 +48,12 @@ replace_with() {
|
|||
if [[ -f $ORIG ]]; then
|
||||
copy_perms "$ORIG" "$NEW"
|
||||
if [[ -n $BACKUPSUFFIX ]]; then
|
||||
mv -- "$ORIG" "$ORIG$BACKUPSUFFIX"
|
||||
mv -- "$ORIG" "$ORIG$BACKUPSUFFIX" || exit
|
||||
fi
|
||||
else
|
||||
mkdir -p -- "${ORIG%/*}"
|
||||
mkdir -p -- "${ORIG%/*}" || exit
|
||||
fi
|
||||
mv -- "$NEW" "$ORIG"
|
||||
mv -- "$NEW" "$ORIG" || exit
|
||||
else
|
||||
printf 'File "%s" not modified\n' \
|
||||
"$ORIG" \
|
||||
|
@ -66,7 +64,7 @@ replace_with() {
|
|||
(cd "$WORKDIR" &&
|
||||
git submodule update --init 'repos-noupdates/*' &&
|
||||
git submodule update --init --remote 'repos/*'
|
||||
)
|
||||
) || exit
|
||||
|
||||
for (( I = 0 ; I < ${#OUT[@]} ; ++I )); do
|
||||
MY_URL=${URL[$I]}
|
||||
|
@ -84,13 +82,13 @@ for (( I = 0 ; I < ${#OUT[@]} ; ++I )); do
|
|||
|
||||
wget \
|
||||
-O "$TEMP_OUT" \
|
||||
"$MY_URL"
|
||||
"$MY_URL" || exit
|
||||
|
||||
replace_with "$MY_OUT" "$TEMP_OUT"
|
||||
done
|
||||
|
||||
TEMP_BLOCKLIST=$(mktemp -p "$TEMP_DIR")
|
||||
"$WORKDIR/make-block.pl" --out="$TEMP_BLOCKLIST"
|
||||
"$WORKDIR/make-block.pl" --out="$TEMP_BLOCKLIST" || exit
|
||||
|
||||
# Blocklist generation succeeded, install it!
|
||||
|
||||
|
@ -102,11 +100,11 @@ if [[ ! -e $BLOCKLIST ]]; then
|
|||
# whatever file permissions 'mktemp' sets.
|
||||
umask 0022
|
||||
touch -- "$BLOCKLIST"
|
||||
)
|
||||
) || exit
|
||||
fi
|
||||
|
||||
replace_with "$BLOCKLIST" "$TEMP_BLOCKLIST"
|
||||
|
||||
if [[ ${#DNSMASQ_RESTART_COMMAND[@]} -gt 0 ]]; then
|
||||
"${DNSMASQ_RESTART_COMMAND[@]}"
|
||||
"${DNSMASQ_RESTART_COMMAND[@]}" || exit
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue