#!/bin/bash ###Air Gapped Server on Raspberry PI SCRIPT_VERSION='2.0' DOMAIN_NAME='airgap.droneengage.com' IP='192.168.1.161' MACHINE_IP='192.168.1.161' EXTERNAL_IP='192.168.1.161' ## same as MACHINE_IP if MACHINE_IP is real ip. MIN_WEBRTC_PORTS=20000 MAX_WEBRTC_PORTS=40000 TURN_PWD='airgap:1234' ## NODEJS Version NODE_MAJOR=18 REPOSITORY_AUTH='https://github.com/DroneEngage/droneenage_authenticator.git' REPOSITORY_SERVER='https://github.com/DroneEngage/droneengage_server.git' REPOSITORY_WEBCLIENT='https://github.com/DroneEngage/droneengage_webclient.git' RED='\033[1;31m' GREEN='\033[1;32m' YELLOW='\033[1;33m' BLUE='\033[1;34m' NC='\033[0m' # No Color echo -e $YELLOW "INSTALLING AIRGAP SERVER FOR DRONEENGAGE" $NC echo -e $YELLOW "For mode details: https://youtu.be/R1BedRTxuuY" $NC echo -e $GREEN "script version $SCRIPT_VERSION" read -p "Press any key to proceed " k sudo apt update ###################################### GET IP of the SERVER # Prompt the user for an IP address while true; do echo -e $GREEN "You need to write the static IP of this server" $NC read -p "Enter an IP address of this server : " ip_address # Validate the IP address format if [[ ! $ip_address =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then echo -e $YELLOW "Invalid IP address format. Please try again." $NC continue fi # Confirm the entered IP address read -p "You entered $ip_address. Is this correct? [y/n]: " confirm # Check the user's confirmation if [[ $confirm =~ ^[Yy]$ ]]; then IP=$ip_address MACHINE_IP=$IP EXTERNAL_IP=$IP echo -e $GREEN "IP address confirmed: $IP" $NC break else echo -e $YELLOW "IP address confirmation declined." $NC fi done ###################################### COTURN echo -e $GREEN "Install CoTurn" $NC sudo apt install -y coturn echo -e $BLUE "Run CoTurn as a Service" $NC sudo touch /etc/turnserver.conf sudo bash -c "cat > /etc/turnserver.conf < ~/ssl/fullchain.pem < ~/ssl/privkey.pem < ~/ssl/root.crt < /etc/dnsmasq.conf </dev/null; then echo -e "${GREEN}Node.js is already installed. Skipping installation.${NC}" else echo -e $GREEN "Install NodeJS" $NC sudo apt-get update sudo apt-get install -y ca-certificates curl gnupg sudo mkdir -p /etc/apt/keyrings curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list sudo apt-get update sudo apt-get install nodejs -y sudo npm install -g npm@latest fi node -v npm -v read -p "Press any key to proceed " k ###################################### PM2 echo -e $GREEN "Install PM2" $NC sudo npm install -g pm2 -timeout=9999999 pm2 startup ###################################### GIT echo -e $GREEN "Install GIT" $NC sudo apt install -y git ###################################### NODE-HTTP-SERVER echo -e $GREEN "Install Http-Server" $NC sudo npm install http-server -g -timeout=9999999 ###################################### Local Maps echo -e $GREEN "Install Local Maps" $NC mkdir ~/map ~/map/cachedMap pushd ~/map/cachedMap echo -e $YELLOW "Put cached IMAGES at ${PWD}" $NC sudo pm2 startup sudo pm2 start http-server -n map_server -x -- ~/map/cachedMap -p 88 -C ~/ssl/fullchain.pem -K ~/ssl/privkey.pem --ssl sudo pm2 save sudo pm2 list echo -e $YELLOW "Images are exposed as https://${DOMAIN_NAME}:88/." $NC echo -e $YELLOW "You need to make webclient uses these images as a map. Please checl WebClient help at https://cloud.ardupilot.org" $NC echo -e $YELLOW "for mode info check this video: https://youtu.be/ppwuUqomxXY" $NC popd read -p "Press any key to proceed " k ###################################### DroneEngage-Authenticator echo -e $GREEN "DroneEngage-Authenticator" $NC echo -e $BLUE "downloading release code" $NC cd ~ git clone -b release --single-branch ${REPOSITORY_AUTH} --depth 1 ./droneengage_authenticator pushd ~/droneengage_authenticator echo -e $BLUE "installing nodejs modules" $NC npm install -timeout=9999999 echo -e $BLUE "linking ssl folder" $NC ln -s ~/ssl ./ssl echo -e $BLUE "register as a service in pm2" $NC sudo pm2 delete droneengage_auth sudo pm2 start server.js -n droneengage_auth sudo pm2 save popd ###################################### DroneEngage-Server echo -e $GREEN "DroneEngage-Server" $NC echo -e $BLUE "downloading release code" $NC cd ~ git clone -b release --single-branch ${REPOSITORY_SERVER} --depth 1 ./droneengage_server echo -e $BLUE "installing nodejs modules" $NC pushd ~/droneengage_server npm install -timeout=9999999 cd server echo -e $BLUE "linking ssl folder" $NC ln -s ~/ssl ./ssl cd .. echo -e $BLUE "register as a service in pm2" $NC sudo pm2 delete droneengage_server sudo pm2 start server.js -n droneengage_server sudo pm2 save popd ###################################### DroneEngage-WebClient echo -e $GREEN "DroneEngage-Webclient" $NC echo -e $BLUE "downloading release code" $NC cd ~ git clone -b release --single-branch ${REPOSITORY_WEBCLIENT} --depth 1 ./droneengage_webclient echo -e $BLUE "installing nodejs modules" $NC pushd ~/droneengage_webclient npm install -timeout=9999999 echo -e $BLUE "linking ssl folder" $NC ln -s ~/ssl ./ssl echo -e $BLUE "register as a service in pm2" $NC sudo pm2 delete webclient sudo pm2 start server.js -n webclient sudo pm2 save popd #git pull origin release --rebase