mirror of
https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker.git
synced 2025-09-03 19:20:16 +00:00
Merge pull request #43 from itoffshore/alpine
fix dash shell compatibilities install / setup-ngxblocker
This commit is contained in:
commit
0e8a5d45da
2 changed files with 12 additions and 10 deletions
|
@ -129,9 +129,9 @@ download_files() {
|
||||||
}
|
}
|
||||||
|
|
||||||
check_config() {
|
check_config() {
|
||||||
local x=
|
local x= dirs="$*"
|
||||||
|
|
||||||
for x in "$@"; do
|
for x in $dirs; do
|
||||||
if [ ! -d $x ]; then
|
if [ ! -d $x ]; then
|
||||||
printf "Creating directory: $x\n"
|
printf "Creating directory: $x\n"
|
||||||
if [ "$DRY_RUN" = "N" ]; then
|
if [ "$DRY_RUN" = "N" ]; then
|
||||||
|
@ -268,3 +268,4 @@ exit $?
|
||||||
# PLEASE ALSO SEE THE SETUP SCRIPT TO INSERT THE NECESSARY INCLUDES FOR YOU
|
# PLEASE ALSO SEE THE SETUP SCRIPT TO INSERT THE NECESSARY INCLUDES FOR YOU
|
||||||
### You can now use a setup script contributed by Stuart Cardall to automatically add the includes for you
|
### You can now use a setup script contributed by Stuart Cardall to automatically add the includes for you
|
||||||
### See - https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/setup-ngxblocker
|
### See - https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/setup-ngxblocker
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
check_config() {
|
check_config() {
|
||||||
local files=$@
|
local files="$*"
|
||||||
|
|
||||||
if [ -z "$files" ]; then
|
if [ -z "$files" ]; then
|
||||||
echo "no vhost files in: $VHOST_DIR/*.$VHOST_EXT => exiting."
|
echo "no vhost files in: $VHOST_DIR/*.$VHOST_EXT => exiting."
|
||||||
|
@ -111,7 +111,7 @@ longest_str() {
|
||||||
|
|
||||||
add_includes() {
|
add_includes() {
|
||||||
local ph='<<!!>>' line=$1 file=$2 conf_dir=$3 text= update=
|
local ph='<<!!>>' line=$1 file=$2 conf_dir=$3 text= update=
|
||||||
local include_list=$(echo $@ | awk '{$1=$2=$3=""}sub("^"OFS"+","")')
|
local include_list="$(echo $@ | awk '{$1=$2=$3=""}sub("^"OFS"+","")')"
|
||||||
local col_size=$(( $(longest_str $include_list) + $(echo $conf_dir | wc -m) ))
|
local col_size=$(( $(longest_str $include_list) + $(echo $conf_dir | wc -m) ))
|
||||||
|
|
||||||
for text in $include_list; do
|
for text in $include_list; do
|
||||||
|
@ -175,10 +175,10 @@ find_includes() {
|
||||||
last) line=$(( $line + $start +1 ));;
|
last) line=$(( $line + $start +1 ));;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# if inserting beyond the end of the file
|
# if inserting beyond the end of the stanza
|
||||||
if [ $line -gt $end ]; then
|
if [ "$(sed -n $(( $line - 1))p $file | grep ^})" = "}" ]; then
|
||||||
# insert blank line
|
# insert blank line
|
||||||
sed -i "$end i \ " $file
|
sed -i "$(( line - 1)) i \ " $file
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $line
|
echo $line
|
||||||
|
@ -252,7 +252,7 @@ wget_opts() {
|
||||||
check_online() {
|
check_online() {
|
||||||
local url=$1 options=$(wget_opts)
|
local url=$1 options=$(wget_opts)
|
||||||
|
|
||||||
if wget $options $url &>/dev/null; then
|
if wget $options $url 2>&1 /dev/null; then
|
||||||
echo "true"
|
echo "true"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,8 @@ main() {
|
||||||
if [ -n "$(check_online $include_url)" ]; then
|
if [ -n "$(check_online $include_url)" ]; then
|
||||||
local tmp=$(mktemp)
|
local tmp=$(mktemp)
|
||||||
wget -q $include_url -O $tmp
|
wget -q $include_url -O $tmp
|
||||||
source $tmp 2>/dev/null
|
# use period not source in POSIX shell
|
||||||
|
. $tmp 2>/dev/null
|
||||||
rm -f $tmp
|
rm -f $tmp
|
||||||
else
|
else
|
||||||
printf "Repo down or missing: $include_url\n"
|
printf "Repo down or missing: $include_url\n"
|
||||||
|
@ -286,7 +287,7 @@ main() {
|
||||||
|
|
||||||
# double check we have some files sourced
|
# double check we have some files sourced
|
||||||
if [ -z "$CONF_FILES" ] || [ -z "$BOT_FILES" ]; then
|
if [ -z "$CONF_FILES" ] || [ -z "$BOT_FILES" ]; then
|
||||||
printf "Error sourcing variables from: $include_url"
|
printf "Error sourcing variables from: $include_url\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue