apiVersion: batch/v1
kind: Job
metadata:
  name: domain2ip-BBS_PROJECT_CODE
  labels:
    app: domain2ip-BBS_PROJECT_CODE
spec:
  ttlSecondsAfterFinished: 100
  template:
    metadata:
      labels:
        app: domain2ip-BBS_PROJECT_CODE
    spec:
      volumes:
      - name: data-volume
        hostPath: 
          path: /mnt/volume_lon1_01
          type: Directory
      containers:
      - name: domain2ip-BBS_PROJECT_CODE
        image: smokingcaterpillar/bbs-osintel-github-subs
        volumeMounts:
        - name: data-volume
          mountPath: /optdata
        command: 
        - /bin/bash
        - -c
        - |
          echo domain2ip v1
          echo Code: BBS_PROJECT_CODE
          echo Id: BBS_PROJECT_ID
          echo List: BBS_PROJECT_LIST
       
          
          ## BBRF SETUP ##
          echo setting up BBRF...
          cp /optdata/BBS/output/private/bbrs-config.json /root/.bbrf/config.json
          bbrf use BBS_PROJECT_CODE
          ## BBRF SETUP ##
          
          echo installing dnsx
          GO111MODULE=on go get -v github.com/projectdiscovery/dnsx/cmd/dnsx
          
          mkdir -p /optdata/BBS/output/project-data/BBS_PROJECT_CODE/data/scanner/domain2ip/
          cd /optdata/BBS/output/project-data/BBS_PROJECT_CODE/data/scanner/domain2ip/
          
          
          bbrf domains --view unresolved -p "BBS_PROJECT_CODE" > unresolved.txt 
          cat unresolved.txt | dnsx -silent -a -resp | tr -d '[]' > dnsx.log.txt
          cat dnsx.log.txt | awk '{print $1":"$2}' > domain-ip.txt
          cat domain-ip.txt | bbrf domain update - -p "BBS_PROJECT_CODE" -s dnsx
          cat domain-ip.txt | bbrf domain add - -p "BBS_PROJECT_CODE" -s dnsx
          cat dnsx.log.txt | awk '{print $2":"$1}' > ip-domain.txt
          cat ip-domain.txt | bbrf ip add - -p "BBS_PROJECT_CODE" -s dnsx
          cat ip-domain.txt | bbrf ip update - -p "BBS_PROJECT_CODE" -s dnsx
          
          
          echo all done
      restartPolicy: Never

