Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

156
LINES

< > BotCompany Repo | #4000805 // ubaTaeCJ

User-supplied dialog

!7

// NOTE: make sure the SOA is correct!

static double refreshEvery = 0 /*60*/;
static int smartBotTimeOut = 60*30;

sS zone = [[
botcompany.de. IN    SOA   ns1.stefantrades.me.  stefan\.reich\.maker\.of\.eye.gmail.com.  (
                                        20190925     ; Serial
                                        60M     ; Refresh
                                        15M     ; Retry
                                        7D      ; Expiry
                                        30M )   ; Minimum
@                       IN      NS      ns1.stefantrades.me.
@                       IN      NS      ns2.stefantrades.me.
@                       IN      A       167.86.121.181
c8                      IN      A       167.86.121.181
home                300 IN      A       2.203.147.51
oldmain                 IN      A       185.183.156.46
coffee                  IN      A       195.154.179.147
*.coffee                IN      A       195.154.179.147
vnc-coffee              IN      A       195.154.179.147
transpile-coffee        IN      A       195.154.179.147
avor                    IN      A       195.154.179.147
robin-avor              IN      A       195.154.179.147
christian-avor          IN      A       195.154.179.147
avor-qa                 IN      A       195.154.179.147
*.avor-qa               IN      A       195.154.179.147
cruddie                 IN      A       195.154.179.147
*.cruddie               IN      A       195.154.179.147
stripe-test             IN      A       195.154.179.147
meta-bot                IN      A       195.154.179.147
ada-v2                  IN      A       195.154.179.147
fia                     IN      A       195.154.179.147
e-buck                  IN      A       195.154.179.147
ada-aws                 IN      A       18.233.63.26
; sometimes the * entry doesn't work? vnc.botcompany.de caused NXDOMAIN
*                       IN      A       167.86.121.181
vnc                     IN      A       167.86.121.181
code                    IN      A       167.86.121.181
www                     IN      A       167.86.121.181
butter                  IN      A       167.86.121.181
stefans-os              IN      A       167.86.121.181
smartbot                IN      A       167.86.121.181
create                  IN      A       167.86.121.181
mail                    IN      A       167.86.121.181
javax                   IN      A       167.86.121.181
ada                     IN      A       167.86.121.181
mech                    IN      A       167.86.121.181
theadmi                 IN      A       176.58.127.141
theadmi2                IN      A       176.58.127.141
tester                  IN      A       144.126.145.56
gazellebot              IN      A       173.212.209.120
;pays5-bot               IN      A       173.212.209.120
pays5-bot               IN      A       195.154.179.147
bea-bot                 IN      A       173.212.209.120
tlc                     IN      A       195.154.179.147
big                     IN      A       192.99.13.227
;@                       MX      10      mail1.domainssaubillig.de.
@                       MX      10      mail.botcompany.de.
mail                    MX      10      mail.botcompany.de.
_acme-challenge.botcompany.de. IN      TXT   "aWAwa7cLpPcFoIylAqQn13tmNyfZ6H36GUt2dFyt-eM"
botcompany.de.          IN      TXT     "google-site-verification=YL5Hu5zvww8np30b4LLv_fgK0rppl2uzUKe8-14Gk98"
]];

// Note: zone2 not active yet

sS zone2 = [[
gazelle.rocks. IN    SOA   ns1.stefantrades.me.  stefan\.reich\.maker\.of\.eye.gmail.com.  (
                                        20190101     ; Serial
                                        5M     ; Refresh
                                        15M     ; Retry
                                        7D      ; Expiry
                                        30M )   ; Minimum
@                       IN      NS      ns1.stefantrades.me.
@                       IN      NS      ns2.stefantrades.me.
@                       IN      A       173.212.209.120
*                       IN      A       173.212.209.120
;@                       MX      10      mail1.domainssaubillig.de.
]];

lib 1008223 // dnsjava
lib 1010766 // EagleDNS
lib 1004911 // log4j

import se.unlogic.eagledns.EagleDNS;

static File zonesDir;
static EagleDNS eagleDNS;

p {
  tryToAcquirePort5000();
  
  S conf = loadSnippet(#1010767);
  zonesDir = programFile("zones");
  saveZones();
  
  conf = conf.replace(
    [[<Property name="zoneFileDirectory">zones</Property>]],
    [[<Property name="zoneFileDirectory">]] + f2s(zonesDir) + [[</Property>]]);
  File configFile = saveProgramTextFile("config.xml", conf);
  
  //eagleDNS = nuObject("se.unlogic.eagledns.EagleDNS", f2s(configFile));
  print("Making EagleDNS.");
  pcall {
    eagleDNS = new EagleDNS(f2s(configFile));
  }
  
  // For some weird reason, on the servers, no lines are printed
  // after this point... but they still execute!? (Auto-reload works.)
  
  printAndProgramLog("Made EagleDNS." + (eagleDNS == null ? "..not" : ""));
  bot("Eagle DNS.");
  if (refreshEvery != 0) doEvery_daemon(refreshEvery, r refresh);
  
  // Restart after successful transpile
  
  print("Making SnippetUpdateConnector.");
  ownResource(snippetUpdateConnector(verbose := true));
  
  ownResource(vmBus_onMessage snippetUpdate(voidfunc(L l) {
    print("Got snippet update: " + l);
    S uri = getString(l, 1);
    new Matches m;
    if (swic(uri, "/transpileOK/", m))
      if (sameSnippetID(programID(), firstIntAsString(m.rest()))) {
        programLog("Restarting");
        restart();
      }
  }));
}

answer {
  if "test" ret "OK";
  if "refresh" {
    refresh();
    ret "OK";
  }
}

static void refresh() {
  saveZones();
  eagleDNS.reloadZones();
}

static void saveZones {
  S acmeChallenge = loadTextFileTrim(userFile("acme-challenge.txt")); // Note: not used anymore, just edit this source
  if (nempty(acmeChallenge))
    zone = jreplace(zone,
      "_acme-challenge.botcompany.de. IN TXT <quoted>",
      "_acme-challenge.botcompany.de. IN TXT " + quote(unnull(acmeChallenge)));
  print(zone);
  saveTextFile(newFile(zonesDir, "botcompany.de"), zone);
  saveTextFile(newFile(zonesDir, "gazelle.rocks"), zone2);
}

Author comment

1

download  show line numbers   

Travelled to 1 computer(s): mqqgnosmbjvj

No comments. add comment

Snippet ID: #4000805
Snippet name: ubaTaeCJ
Eternal ID of this version: #4000805/1
Text MD5: bbdc4a3c243bdf1a146801f8fd8b2c96
Author: ubataecj
Category: 1
Type: User-supplied dialog
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2024-05-01 03:37:13
Source code size: 6387 bytes / 156 lines
Pitched / IR pitched: No / No
Views / Downloads: 11 / 3
Referenced in: [show references]