diff --git a/src/scripts/dns_ldap_veyon.sh b/src/scripts/dns_ldap_veyon.sh new file mode 100644 index 0000000..3eb708a --- /dev/null +++ b/src/scripts/dns_ldap_veyon.sh @@ -0,0 +1,183 @@ +#!/bin/bash + +# Abort on any error +set -e + +# Variables +LDAP_DOMAIN="doncom" +LDAP_ORG="Doncom Organization" +LDAP_ADMIN_PASS="davidtomas" +LDAP_BASE_DN="dc=doncom" +LDAP_ADMIN_DN="cn=admin,dc=doncom" +DNS_SERVER_IP="127.0.0.1" +VEYON_CONFIG_DIR="/etc/veyon" +VEYON_JSON_FILE="$VEYON_CONFIG_DIR/veyon.json" +VEYON_CONFIG="$VEYON_CONFIG_DIR/veyon.conf" + +# Verificar la variable VEYON_JSON_FILE +echo "VEYON_JSON_FILE: $VEYON_JSON_FILE" + +# Get the IP address of the active network interface +IP_ADDRESS=$(ip route get 1 | awk '{print $NF;exit}') + +# Get the network address and subnet mask +NETWORK=$(ipcalc -n $IP_ADDRESS | cut -d'=' -f2) +NETMASK=$(ipcalc -m $IP_ADDRESS | cut -d'=' -f2) + +# Calculate the network range +NETWORK_RANGE="$NETWORK/$NETMASK" + +# Update system +echo "Updating system..." +sudo apt-get update -y && sudo apt-get upgrade -y + +# Install BIND DNS server +echo "Installing BIND DNS server..." +sudo apt-get install -y bind9 bind9utils bind9-doc + +# Configure BIND +echo "Configuring BIND..." +sudo bash -c "cat > /etc/bind/named.conf.local < /etc/bind/db.$LDAP_DOMAIN <&1 | grep -c "dn: $LDAP_BASE_DN") +if [ "$BASE_DN_EXIST" -eq 0 ]; then + echo "Creating LDAP base structure..." + cat < /dev/null +echo " \"locations\": [" | sudo tee -a $VEYON_JSON_FILE > /dev/null + +for HOST in $NMAP_OUTPUT; do + echo " {" | sudo tee -a $VEYON_JSON_FILE > /dev/null + echo " \"name\": \"$HOST\"," | sudo tee -a $VEYON_JSON_FILE > /dev/null + echo " \"computers\": [" | sudo tee -a $VEYON_JSON_FILE > /dev/null + echo " {" | sudo tee -a $VEYON_JSON_FILE > /dev/null + echo " \"name\": \"$HOST\"," | sudo tee -a $VEYON_JSON_FILE > /dev/null + echo " \"host\": \"$HOST\"" | sudo tee -a $VEYON_JSON_FILE > /dev/null + echo " }" | sudo tee -a $VEYON_JSON_FILE > /dev/null + echo " ]" | sudo tee -a $VEYON_JSON_FILE > /dev/null + echo " }," | sudo tee -a $VEYON_JSON_FILE > /dev/null +done + +# Remove trailing comma from last entry +sudo sed -i '$s/,$//' $VEYON_JSON_FILE + +echo " ]" | sudo tee -a $VEYON_JSON_FILE > /dev/null +echo "}" | sudo tee -a $VEYON_JSON_FILE > /dev/null + +echo "Veyon configuration file created successfully." + +# Install Veyon +echo "Installing Veyon..." +sudo apt-get install -y libveyon-core veyon-configurator veyon-master veyon-plugins veyon-service + +# Configure Veyon +echo "Configuring Veyon..." +sudo veyon-cli config set MasterKey "your_master_key_here" + +# Restart Veyon service +sudo systemctl restart veyon.service +sudo systemctl enable veyon.service + +echo "Veyon installed and configured successfully." + +echo " ]" | sudo /usr/bin/tee -a $VEYON_JSON_FILE > /dev/null +echo "}" | sudo /usr/bin/tee -a $VEYON_JSON_FILE > /dev/null