mirror of
https://github.com/bigbeartechworld/big-bear-scripts.git
synced 2026-07-25 06:42:34 -04:00
Add more comments and let the user know what's happening
This commit is contained in:
@@ -5,28 +5,34 @@ GREEN='\033[0;32m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Get the local IP
|
||||
echo -e "${GREEN}Getting local IP...${NC}"
|
||||
|
||||
LOCAL_IP=$(hostname -I | awk '{print $1}')
|
||||
|
||||
# Get the subnet
|
||||
echo -e "${GREEN}Getting subnet...${NC}"
|
||||
|
||||
SUBNET=$(ip -o -f inet addr show | awk '/scope global/ {split($4, a, "."); print a[1] "." a[2] "." a[3] ".0"}')
|
||||
|
||||
echo -e "${GREEN}Updating package index...${NC}"
|
||||
sudo apt update
|
||||
|
||||
# Install unbound
|
||||
echo -e "\n${GREEN}Installing unbound...${NC}"
|
||||
|
||||
sudo apt install unbound -y
|
||||
|
||||
# Check if unbound is enabled
|
||||
echo -e "\n${GREEN}Checking if unbound is enabled to start on boot...${NC}"
|
||||
sudo systemctl is-enabled unbound
|
||||
|
||||
# Check if unbound is running
|
||||
echo -e "\n${GREEN}Checking the status of unbound...${NC}"
|
||||
sudo systemctl status unbound
|
||||
|
||||
# Add configurations to unbound.conf.d/main.conf
|
||||
echo -e "\n${GREEN}Adding configurations to unbound.conf.d/main.conf...${NC}"
|
||||
|
||||
# Header comment
|
||||
echo "# Adding DNS-Over-TLS support" | sudo tee -a /etc/unbound/unbound.conf.d/main.conf
|
||||
|
||||
# Begin server configuration block
|
||||
echo "server:" | sudo tee -a /etc/unbound/unbound.conf.d/main.conf
|
||||
|
||||
@@ -76,6 +82,8 @@ echo " access-control: 127.0.0.0/8 allow # Allow entire localhost subnet" |
|
||||
echo " access-control: $SUBNET/24 allow # Allow current local subnet" | sudo tee -a /etc/unbound/unbound.conf.d/main.conf
|
||||
|
||||
# Logging configurations
|
||||
echo -e "\n${GREEN}Configuring rsyslog...${NC}"
|
||||
|
||||
cat <<EOF | sudo tee /etc/rsyslog.d/unbound.conf
|
||||
# Log messages generated by the unbound application
|
||||
if $programname == 'unbound' then /var/log/unbound.log
|
||||
@@ -84,6 +92,8 @@ if $programname == 'unbound' then /var/log/unbound.log
|
||||
EOF
|
||||
|
||||
# Configuration for log rotation
|
||||
echo -e "\n${GREEN}Configuring log rotation...${NC}"
|
||||
|
||||
cat <<EOF | sudo tee /etc/logrotate.d/unbound
|
||||
/var/log/unbound.log {
|
||||
daily
|
||||
@@ -97,19 +107,23 @@ cat <<EOF | sudo tee /etc/logrotate.d/unbound
|
||||
EOF
|
||||
|
||||
# Restart the rsyslog and logrotate services to apply changes
|
||||
echo -e "\n${GREEN}Restarting rsyslog and logrotate...${NC}"
|
||||
|
||||
sudo systemctl restart rsyslog logrotate
|
||||
|
||||
# echo -e "\n${GREEN}Updating the sysctl configuration...${NC}"
|
||||
# echo "net.core.rmem_max=8388608" | sudo tee -a /etc/sysctl.conf
|
||||
|
||||
echo -e "\n${GREEN}Applying sysctl changes...${NC}"
|
||||
sudo sysctl -p
|
||||
# echo -e "\n${GREEN}Applying sysctl changes...${NC}"
|
||||
# sudo sysctl -p
|
||||
|
||||
echo -e "\n${GREEN}Allowing OpenSSH and UDP port 53 through UFW...${NC}"
|
||||
|
||||
sudo ufw allow OpenSSH
|
||||
sudo ufw allow 53/udp
|
||||
|
||||
echo -e "\n${GREEN}Restarting unbound server...${NC}"
|
||||
|
||||
sudo service unbound restart
|
||||
|
||||
echo -e "\n${GREEN}Script completed.${NC}"
|
||||
|
||||
Reference in New Issue
Block a user