i also made and updated install script with dns server installation all in one script :
#!/bin/bash
Function to check if Docker is installed
check_docker() {
if ! command -v docker &> /dev/null; then
echo “Docker is not installed, installing…”
sudo apt update
sudo apt install -y docker.io
else
echo “Docker is already installed”
fi
}
Function to create DNS server setup
setup_dns_server() {
DOCKER_IMAGE_NAME=“my-dns-server”
DOCKER_CONTAINER_NAME=“dns-server”
ZONE_FILE=“db.example.com”
echo “Creating directory for DNS server setup…”
mkdir -p ./my-dns-server
cd ./my-dns-server
Create Dockerfile for DNS Server
cat > Dockerfile <<EOL
FROM ubuntu:latest
RUN apt update && apt install -y bind9
COPY named.conf /etc/bind/
COPY named.conf.local /etc/bind/
EXPOSE 53/udp
EXPOSE 53/tcp
CMD [“named”, “-f”, “/etc/bind/named.conf”]
EOL
Create named.conf
cat > named.conf <<EOL
options {
directory “/var/cache/bind”;
allow-query { any; };
logging {
channel default_file {
file “/var/log/named.log” versions 3 size 5m;
severity info;
print-time yes;
print-severity yes;
print-category yes;
};
category default { default_file; };
};
allow-recursion { localhost; };
};
include “/etc/bind/named.conf.local”;
EOL
Create named.conf.local
cat > named.conf.local <<EOL
zone “example.com” {
type master;
file “/etc/bind/db.example.com”;
};
EOL
Create db.example.com (zone file)
cat > $ZONE_FILE <<EOL
$TTL 86400
@ IN SOA ns1.example.com. admin.example.com. (
2025022401 ; Serial
3600 ; Refresh
1800 ; Retry
1209600 ; Expire
86400 ) ; Minimum TTL
IN NS ns1.example.com.
ns1 IN A 192.168.1.1
@ IN A 192.168.1.1
EOL
Build and run the Docker container for the DNS server
sudo docker build -t $DOCKER_IMAGE_NAME .
sudo docker run -d -p 53:53/udp -p 53:53/tcp --name $DOCKER_CONTAINER_NAME $DOCKER_IMAGE_NAME
echo “DNS Server setup completed.”
}
Function to install n8n
install_n8n() {
echo “Installing n8n…”
Pull the n8n Docker image
sudo docker pull n8nio/n8n
Create and start n8n container with the required settings
sudo docker run -d
–name n8n
–env N8N_HOST=your-n8n-domain.com
–env N8N_PORT=5678
–env GENERIC_TIMEZONE=“UTC”
–env DB_TYPE=postgresdb
–env DB_POSTGRESDB_HOST=postgresdb_host
–env DB_POSTGRESDB_PORT=5432
–env DB_POSTGRESDB_USER=n8n
–env DB_POSTGRESDB_PASSWORD=password
–env DB_POSTGRESDB_DATABASE=n8n
-v ~/.n8n:/home/node/.n8n
–dns 192.168.1.1 \ # Use your DNS server IP address here
–restart always
n8nio/n8n
echo “n8n installed and running.”
}
Function to start the n8n service
start_n8n() {
echo “Starting n8n service…”
sudo docker start n8n
echo “n8n service started.”
}
Function to install and configure APIs for n8n (credentials need to be set up manually)
setup_n8n_api_credentials() {
echo “Set up API credentials for services like Twitter, LinkedIn, Gmail, etc., through the n8n UI.”
echo “For each API, you need to go to n8n → Credentials → Create New Credential → Select the API → Input credentials (API key, OAuth2).”
echo “You can find API documentation for each service in the n8n documentation or the service’s developer portal.”
}
Main script
echo “Starting the installation process…”
check_docker
setup_dns_server
install_n8n
setup_n8n_api_credentials
start_n8n
echo “Installation and setup completed!”