diff options
| author | xTITUSMAXIMUSX <62310795+xTITUSMAXIMUSX@users.noreply.github.com> | 2023-02-13 01:11:48 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-13 02:11:48 -0500 |
| commit | b26b895ed568a446b5697bb68cb7b3c18b360052 (patch) | |
| tree | 35246493be32c6c1cdedd045cf411a8dfa796e5a /scripts | |
| parent | b8710b201f9a95f137545fecd5197ddee8080c6e (diff) | |
| download | BedrockConnect-b26b895ed568a446b5697bb68cb7b3c18b360052.tar.gz BedrockConnect-b26b895ed568a446b5697bb68cb7b3c18b360052.tar.bz2 BedrockConnect-b26b895ed568a446b5697bb68cb7b3c18b360052.zip | |
Adding bind9 docker and updating scripts (#367)
* Updating
* update script
* Update install-bind.sh
* Fixed additional-from-cache no issue
* Add docker install script
* update for new install script
* Add null output to service start
* Trying different install method
* Added exit code 0
* testing exit off
* Fixed install method
* Inserted args on build for IP addresses
* Updated URL to Pugmatt github
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/docker-install-bind.sh | 129 | ||||
| -rw-r--r-- | scripts/install-bind.sh | 4 |
2 files changed, 131 insertions, 2 deletions
diff --git a/scripts/docker-install-bind.sh b/scripts/docker-install-bind.sh new file mode 100644 index 0000000..8571e3c --- /dev/null +++ b/scripts/docker-install-bind.sh @@ -0,0 +1,129 @@ +#!/usr/bin/env bash +# +# Bind install and cofiguration script for Bedrock Connect +# Usage: sudo scripts/install-bind.sh [BCIP] [NSIP] +# BCIP Optional IP of the bedrock connect server (Default: 104.238.130.180) +# NSIP Optional IP of the name server (Default: same as the bedrock connect server) +# +# Should support Ubuntu 18+ and Cent OS 7+ +# Tested on: Ubuntu 18.04 LTS, Ubuntu 20.04 LTS, Cent OS 7 and Cent OS 8 +# + +# +# Configuration +# + +BCIP=${1:-104.238.130.180} +NSIP=${2:-$BCIP} + +# +# Functions +# + +function add_domain() { + local domain=$1 + shift + + # Warn if exists + if [[ -n "$(cat $NAMED_ZONES | grep $domain)" ]]; then + echo "Warning: Domain $domain already exists, skipping..." + return + fi + + # Create zone file + echo "@ IN SOA $domain. admin.$domain. ( + 2014030801 ; serial + 1D ; refresh + 1H ; retry + 1W ; expire + 3H ) ; minimum +@ 300 NS ns.$domain. +ns 300 IN A $NSIP" > $NAMED_DBS/db.$domain + while [[ -n "$1" ]]; do + echo "$1 300 IN A $BCIP" >> $NAMED_DBS/db.$domain + shift + done + + # Add zone config to named + echo "zone \"$domain\" IN { + type master; + file \"db.$domain\"; + allow-query { any; }; +}; +" >> $NAMED_ZONES +} + +# +# Main +# + +if [[ "$(whoami)" != "root" ]]; then + echo "Error: This script need to be ran as root (or using sudo)." + exit 1 +fi + +# Check OS + +if [[ -f /etc/os-release ]]; then + source /etc/os-release + if [[ "$ID" == "ubuntu" || "$ID_LIKE" == "ubuntu" ]]; then + PKG_MGR=apt + PKG_MGR_SYNTAX="install" + PKGS="bind9 dnsutils" + NAMED_OPTIONS="/etc/bind/named.conf.options" + NAMED_ZONES="/etc/bind/named.conf.local" + NAMED_DBS="/var/cache/bind" + SERVICE_NAME="bind9" + elif [[ "$ID" == "centos" ]]; then + PKG_MGR=yum + PKG_MGR_SYNTAX="install" + PKGS="bind bind-utils" + NAMED_OPTIONS="/etc/named.conf" + NAMED_ZONES="/etc/named.conf" + NAMED_DBS="/var/named" + SERVICE_NAME="named" + elif [[ "$ID" == "arch" ]]; then + PKG_MGR=pacman + PKG_MGR_SYNTAX="-S" + PKGS="bind" + NAMED_OPTIONS="/etc/named.conf" + NAMED_ZONES="/etc/named.conf" + NAMED_DBS="/var/named" + SERVICE_NAME="named" + elif [[ "$ID" == "debian" ]]; then + PKG_MGR=apt + PKG_MGR_SYNTAX="install" + PKGS="bind9 dnsutils" + NAMED_OPTIONS="/etc/bind/named.conf.options" + NAMED_ZONES="/etc/bind/named.conf.local" + NAMED_DBS="/var/cache/bind" + SERVICE_NAME="named" + else + echo "Unsupported OS" + exit 2 + fi +else + echo "Unsupported OS" + exit 2 +fi + +# Install + +$PKG_MGR $PKG_MGR_SYNTAX -y $PKGS + +# Configure + +sed -i '/recursion/d' $NAMED_OPTIONS +sed -i '/additional-from-cache/d' $NAMED_OPTIONS +sed -i 's/^options {/options {\n\trecursion no;/' $NAMED_OPTIONS + +add_domain hivebedrock.network @ geo +add_domain mineplex.com mco +add_domain inpvp.net play +add_domain lbsg.net mco +add_domain cubecraft.net mco +add_domain galaxite.net play +add_domain pixelparadise.gg play + +# Reload config +/etc/init.d/named start
\ No newline at end of file diff --git a/scripts/install-bind.sh b/scripts/install-bind.sh index 9dffb5a..c518290 100644 --- a/scripts/install-bind.sh +++ b/scripts/install-bind.sh @@ -115,7 +115,7 @@ $PKG_MGR $PKG_MGR_SYNTAX -y $PKGS sed -i '/recursion/d' $NAMED_OPTIONS sed -i '/additional-from-cache/d' $NAMED_OPTIONS -sed -i 's/^options {/options {\n\trecursion no;\n\tadditional-from-cache no;/' $NAMED_OPTIONS +sed -i 's/^options {/options {\n\trecursion no;/' $NAMED_OPTIONS add_domain hivebedrock.network @ geo add_domain mineplex.com mco @@ -127,4 +127,4 @@ add_domain pixelparadise.gg play # Reload config -systemctl reload $SERVICE_NAME +systemctl reload $SERVICE_NAME
\ No newline at end of file |
