Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple IP address support #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Alternatively set the environment variables manually by running:

`export VARIABLE=value`

You can also use a comma to seperate multiple ip addresses, for example:

`export LANCACHE_IP="192.168.1.1,192.168.1.2"`

## Usage

1. `sudo ./generate.sh`
Expand Down
11 changes: 9 additions & 2 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ fi
# Check all required variables are set
: "${LANCACHE_IP:?must be set}"

# Put IP's into an array
IFS=',' read -ra IP_ARRAY <<< "$LANCACHE_IP"

# Get domains from `uklans/cache-domains` GitHub repo
rm -rf /var/git/lancache-cache-domains
/usr/bin/git clone https://github.com/uklans/cache-domains.git /var/git/lancache-cache-domains
Expand Down Expand Up @@ -62,8 +65,12 @@ do
echo "local-zone: \"${LINE}.\" redirect" >> $CONFIG_FILE
fi

# Add a standard A record config line
echo "local-data: \"${LINE}. A $LANCACHE_IP\"" >> $CONFIG_FILE
# Loop through all IP's to make A records
for IP in "${IP_ARRAY[@]}"
do
# Add a standard A record config line
echo "local-data: \"${LINE}. A $IP\"" >> $CONFIG_FILE
done

done < /var/git/lancache-cache-domains/$UPSTREAM.txt

Expand Down