From 2dffabd1f75912829d4ee7f6037a239dc5123d6c Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Fri, 20 Sep 2024 13:05:40 +0200
Subject: [PATCH] FIX: bad naming practices, ENH: make ready to act as root

---
 .handle/local_nas                           |   1 -
 Makefile                                    |   5 +-
 handle_server/Dockerfile                    |   4 +-
 handle_server/run_handle_server.sh          |  13 +-
 handle_server/templates/bdbje/00000000.jdb  | Bin 3047 -> 6249 bytes
 handle_server/templates/bdbje/je.config.csv |   1 +
 handle_server/templates/bdbje/je.stat.csv   |  15 ++
 handle_server/templates/bootstrap_handles   |  99 +++++++++++
 handle_server/templates/config.dct          |  10 +-
 handle_server/templates/setup.batch.hdl     |   8 +
 handle_server/templates/wait-for-it.sh      | 182 ++++++++++++++++++++
 11 files changed, 326 insertions(+), 12 deletions(-)
 delete mode 100644 .handle/local_nas
 create mode 100644 handle_server/templates/bootstrap_handles
 create mode 100644 handle_server/templates/setup.batch.hdl
 create mode 100755 handle_server/templates/wait-for-it.sh

diff --git a/.handle/local_nas b/.handle/local_nas
deleted file mode 100644
index 72e8ffc..0000000
--- a/.handle/local_nas
+++ /dev/null
@@ -1 +0,0 @@
-*
diff --git a/Makefile b/Makefile
index 4632eb9..52547c0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,14 @@
 start:
 	@echo "Start Handle System"
 	docker compose up --build --detach
+	docker exec test-handle-net-hs_server-1 /hs/templates/wait-for-it.sh 172.27.0.2:8000 -t 500 -- echo "HANDLE SERVICE ONLINE"
+	docker exec test-handle-net-hs_server-1 bin/hdl-genericbatch /hs/setup.batch.hdl
 
 stop:
 	@echo "Stop Handle System"
-	docker compose rm -vsf
+	docker compose down
 
 clean:
 	@echo "Clean-up Handle System"
 	docker compose down -v --rmi all
+	docker compose rm -vsf
diff --git a/handle_server/Dockerfile b/handle_server/Dockerfile
index 107b32b..615c801 100644
--- a/handle_server/Dockerfile
+++ b/handle_server/Dockerfile
@@ -1,5 +1,7 @@
 FROM eclipse-temurin:21-jre-alpine
 
+RUN apk add bash
+
 RUN mkdir -p /hs/srv_1
 
 WORKDIR /hs
@@ -17,4 +19,4 @@ COPY ./run_handle_server.sh ./
 
 COPY ./templates /hs/templates
 
-CMD ["./run_handle_server.sh", "/hs/srv_1"]
+CMD ["./run_handle_server.sh"]
diff --git a/handle_server/run_handle_server.sh b/handle_server/run_handle_server.sh
index 0b818d7..39eeca4 100755
--- a/handle_server/run_handle_server.sh
+++ b/handle_server/run_handle_server.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-SRV_DIR=$1
+SRV_DIR=/hs/srv_1
 
 # ### Copy configuration and empty database ###
 if [ ! -e "${SRV_DIR}/config.dct" ] ; then
@@ -8,20 +8,21 @@ if [ ! -e "${SRV_DIR}/config.dct" ] ; then
 fi
 
 # ### Update configuration ###
-
 # update config.dct
 sed "s/HANDLE_SERVER_IPV4_ADDRESS/${HANDLE_SERVER_IPV4_ADDRESS}/g" /hs/templates/config.dct > "$SRV_DIR/config.dct"
 
 # update siteinfo.json
 sed "s/HANDLE_SERVER_IPV4_ADDRESS/${HANDLE_SERVER_IPV4_ADDRESS}/g" /hs/templates/siteinfo.json > "$SRV_DIR/siteinfo.json"
 
+# update batch file
+sed "s/HANDLE_SERVER_IPV4_ADDRESS/${HANDLE_SERVER_IPV4_ADDRESS}/g" /hs/templates/setup.batch.hdl > "/hs/setup.batch.hdl"
 
 # ### Configure private handle network ###
-# See Technical Manual, Section 10.1
-# https://hdl.handle.net/20.1000/113
 mkdir -p /root/.handle
-cp "$SRV_DIR/siteinfo.json" /root/.handle/resolver_site
-echo '*' > /root/.handle/local_nas
+sed "s/HANDLE_SERVER_IPV4_ADDRESS/${HANDLE_SERVER_IPV4_ADDRESS}/g" /hs/templates/bootstrap_handles > /root/.handle/bootstrap_handles
+echo '{' > /root/.handle/config.dct
+echo '"auto_update_root_info" = "no"' >> /root/.handle/config.dct
+echo '}' >> /root/.handle/config.dct
 
 # actually run the server
 bin/hdl-server "$SRV_DIR"
diff --git a/handle_server/templates/bdbje/00000000.jdb b/handle_server/templates/bdbje/00000000.jdb
index 2047fe523121cd76027f6fe9055a238236051f23..25685c8e12e520921756a5561dce45f9136f783c 100644
GIT binary patch
delta 1969
zcmb_dU2Icj7=FLgb58%)wcENz7&~J)8LmHT*%$*iN;X}GYzk~JT{6a6=Hgfh8{-^E
z(|IKukO-ZiV)OzMqGIAQF$TTR2pBI&kd4GdO$6f*e{ftd!AOqJIo(*nD-%!FzWv^x
z=X<~R`JS`u`8NU|T(>4ma+mJ&&{-?d3L;7@A6)(IVdmcu>xvJ?b}7>CzG!UMo=&Aq
z8tm-tiAu4)s1)BW^~SrUC!~NJ@CW2=u@!eye;g~K>i}tIKoM-Jd<7Q2SsgxQ+kbG}
zfPHo-3tn@>#*SxN)~>5>gKIn@mayce`i-0X;kxyarYe3<iId7~M0TVqXRNlwy3!i7
zM6}U(wY`vz!k>$fBq*;5c2y1d=8Ny~-Q`XiLxx^lZMP?`Hl~Z;KJ1w+q6zrh^bWH!
zJ2dJoX8XoNVhwu=XYvI+!q!SB-JFBkW6w&AR@Ul$ct@vxDW(<&Q3s&V#~G_56D<uE
z0oZD`dcL{G1b@&;J5i=LcQ?zC2)#9nSQVP^(D&IyM{%;my4o-{lHIA(#**+0oqf^X
zn72Q+3w-!zS1WxXU%B7s)BbwnU7fw&fmr{*wpi4!S?^qp(mxQ}k(x4=B$?=~$)P*g
zL1Q4%tnXkDx_aaNF_z;Uu@AlJB&tS?QzlHRDw^<<lBznzbIOP+o3)|Qobxm4uoCzD
z+;WQgd7|b|Yzr3K=wslNB9~KaW>uI?Np0pmNkq5`ep4NCT||W%Akr8q!%j{jlFbfA
zqI`vuL&(4r6kX@`*@spjxfV-7iJMi`WSO66W@|=prtzjx#>vweS=z`sd1klMcDv6;
zQJ|IUXk+G7wWYKc4(^U{awkt?2rbq&#$M>E+Lh6jDkv=iZ%|(13`7+j*{xzWO(VbI
zh&kWgV<G8&|L>dSOFS<x<WphmqU3G!E6c1T<q$<QT#lZ^_bDtru#*Cj8}>U)X$J-j
zcF2g&0qmh!lgS~jGOUC!%V;fTa9$??q@0LYPoK}FLEva(Ow*WX)k#$zbu#507mVpo
zF}Z)(F=J@YJNu=FE+V@M*@<h?C0wt-f01~3XnSW5-@K}b{sIclO`MRY>NEv>O<@ea
zDg3oC8FJDZXj8x6U*+T_ZniaE)+Muqzfe|0TM<jwx-)7uJ`03{UMKCFtL1auiDlQ)
zrT3~HiFoKZLb^7l3Mc<>ZA^%-*XPhj*g@CEulf#rdZ-)RZyd4@J(ri}k5j_V2ee`M
zw>C~_v~Zi}w4qCd9+t{En_Oz6LBN)hsA*-`nQG#TlJIa}@LM{0x`>#BIpfhJ(wcYw
zGMbbwW{^ivh9_9yIda@S#N!%uV<{-VqrnF>!q2yusS%Q=v+h%;A(=s4HM!DGjgzz!
zoVXqm6Uj60SwC&IQ4qVPwN&lWw3LK{^NLM)8=OL@SVKr_Dd5g%f1DYWR|Qc}KIb5S
ziY3-#Kih|<P*9_#D+Lx+<ynvy_Kv7*_Qk`3gd=i37NV07K>=G%0;kyuLLpbqDydI^
zP70zz{6!n(=Myc|!FnvJfdv`cdms}FaqeBmhqtn+3z?13u;;hT4vU#p@iS4B6;W3)
zXPJK7N{5g;tKuyHcSFL9U=Kp73t%ss(<;V62>%FaDdeG9lWElQG<_pBpg%9I*WYFO
ktM%mz_EUf7(ocZRQ1LDO`YAu=GR2(_0~HJVhut&$KY=^RE&u=k

delta 7
OcmaE9@LYVub8Y|-P6N6C

diff --git a/handle_server/templates/bdbje/je.config.csv b/handle_server/templates/bdbje/je.config.csv
index 01f1a2b..50b4e5b 100644
--- a/handle_server/templates/bdbje/je.config.csv
+++ b/handle_server/templates/bdbje/je.config.csv
@@ -1,2 +1,3 @@
 time,envcfg:com.sleepycat.je.util.ConsoleHandler.level,envcfg:com.sleepycat.je.util.FileHandler.level,envcfg:je.adler32.chunkSize,envcfg:je.checkpointer.bytesInterval,envcfg:je.checkpointer.deadlockRetry,envcfg:je.checkpointer.highPriority,envcfg:je.checkpointer.wakeupInterval,envcfg:je.cleaner.adjustUtilization,envcfg:je.cleaner.backgroundProactiveMigration,envcfg:je.cleaner.bytesInterval,envcfg:je.cleaner.calc.initialAdjustments,envcfg:je.cleaner.calc.maxProbeSkipFiles,envcfg:je.cleaner.calc.minProbeSkipFiles,envcfg:je.cleaner.calc.minUncountedLNs,envcfg:je.cleaner.cluster,envcfg:je.cleaner.clusterAll,envcfg:je.cleaner.deadlockRetry,envcfg:je.cleaner.detailMaxMemoryPercentage,envcfg:je.cleaner.expunge,envcfg:je.cleaner.fetchObsoleteSize,envcfg:je.cleaner.forceCleanFiles,envcfg:je.cleaner.foregroundProactiveMigration,envcfg:je.cleaner.gradualExpiration,envcfg:je.cleaner.lazyMigration,envcfg:je.cleaner.lockTimeout,envcfg:je.cleaner.lookAheadCacheSize,envcfg:je.cleaner.maxBatchFiles,envcfg:je.cleaner.minAge,envcfg:je.cleaner.minFileUtilization,envcfg:je.cleaner.minFilesToDelete,envcfg:je.cleaner.minUtilization,envcfg:je.cleaner.readSize,envcfg:je.cleaner.restartRetries,envcfg:je.cleaner.retries,envcfg:je.cleaner.rmwFix,envcfg:je.cleaner.threads,envcfg:je.cleaner.trackDetail,envcfg:je.cleaner.twoPassGap,envcfg:je.cleaner.twoPassThreshold,envcfg:je.cleaner.upgradeToLogVersion,envcfg:je.cleaner.useDeletedDir,envcfg:je.cleaner.wakeupInterval,envcfg:je.compressor.deadlockRetry,envcfg:je.compressor.lockTimeout,envcfg:je.compressor.wakeupInterval,envcfg:je.deferredWrite.temp,envcfg:je.env.backgroundReadLimit,envcfg:je.env.backgroundSleepInterval,envcfg:je.env.backgroundWriteLimit,envcfg:je.env.checkLeaks,envcfg:je.env.comparatorsRequired,envcfg:je.env.dbCacheClearCount,envcfg:je.env.dbEviction,envcfg:je.env.diskOrderedScanLockTimeout,envcfg:je.env.dupConvertPreloadAll,envcfg:je.env.expirationEnabled,envcfg:je.env.exposeUserData,envcfg:je.env.fairLatches,envcfg:je.env.forcedYield,envcfg:je.env.isLocking,envcfg:je.env.isReadOnly,envcfg:je.env.isTransactional,envcfg:je.env.latchTimeout,envcfg:je.env.logTrace,envcfg:je.env.recovery,envcfg:je.env.recoveryForceCheckpoint,envcfg:je.env.recoveryForceNewFile,envcfg:je.env.runCheckpointer,envcfg:je.env.runCleaner,envcfg:je.env.runEvictor,envcfg:je.env.runINCompressor,envcfg:je.env.runOffHeapEvictor,envcfg:je.env.runVerifier,envcfg:je.env.setupLogger,envcfg:je.env.sharedLatches,envcfg:je.env.startupThreshold,envcfg:je.env.terminateTimeout,envcfg:je.env.ttlClockTolerance,envcfg:je.env.ttlLnPurgeDelay,envcfg:je.env.ttlMaxTxnTime,envcfg:je.env.verifyBtree,envcfg:je.env.verifyBtreeBatchDelay,envcfg:je.env.verifyBtreeBatchSize,envcfg:je.env.verifyDataRecords,envcfg:je.env.verifyLog,envcfg:je.env.verifyLogReadDelay,envcfg:je.env.verifyMaxTardiness,envcfg:je.env.verifyObsoleteRecords,envcfg:je.env.verifySchedule,envcfg:je.env.verifySecondaries,envcfg:je.evictor.allowBinDeltas,envcfg:je.evictor.coreThreads,envcfg:je.evictor.criticalPercentage,envcfg:je.evictor.deadlockRetry,envcfg:je.evictor.evictBytes,envcfg:je.evictor.evictionBatchPercentage,envcfg:je.evictor.forcedYield,envcfg:je.evictor.keepAlive,envcfg:je.evictor.lruOnly,envcfg:je.evictor.maxThreads,envcfg:je.evictor.mutateBins,envcfg:je.evictor.nLRULists,envcfg:je.evictor.nodeScanPercentage,envcfg:je.evictor.nodesPerScan,envcfg:je.evictor.useDirtyLRU,envcfg:je.evictor.useMemoryFloor,envcfg:je.evictor.wakeupInterval,envcfg:je.freeDisk,envcfg:je.haltOnCommitAfterChecksumException,envcfg:je.lock.deadlockDetect,envcfg:je.lock.deadlockDetectDelay,envcfg:je.lock.nLockTables,envcfg:je.lock.oldLockExceptions,envcfg:je.lock.timeout,envcfg:je.log.bufferSize,envcfg:je.log.checksumRead,envcfg:je.log.chunkedNIO,envcfg:je.log.detectFileDelete,envcfg:je.log.detectFileDeleteInterval,envcfg:je.log.directNIO,envcfg:je.log.faultReadSize,envcfg:je.log.fileCacheSize,envcfg:je.log.fileMax,envcfg:je.log.fileWarmUpReadSize,envcfg:je.log.fileWarmUpSize,envcfg:je.log.flushNoSyncInterval,envcfg:je.log.flushSyncInterval,envcfg:je.log.fsyncTimeLimit,envcfg:je.log.fsyncTimeout,envcfg:je.log.groupCommitInterval,envcfg:je.log.groupCommitThreshold,envcfg:je.log.iteratorMaxSize,envcfg:je.log.iteratorReadSize,envcfg:je.log.memOnly,envcfg:je.log.nDataDirectories,envcfg:je.log.numBuffers,envcfg:je.log.totalBufferBytes,envcfg:je.log.useNIO,envcfg:je.log.useODSYNC,envcfg:je.log.useWriteQueue,envcfg:je.log.verifyChecksums,envcfg:je.log.writeQueueSize,envcfg:je.maxDisk,envcfg:je.maxMemory,envcfg:je.maxMemoryPercent,envcfg:je.maxOffHeapMemory,envcfg:je.nodeDupTreeMaxEntries,envcfg:je.nodeMaxEntries,envcfg:je.offHeap.checksum,envcfg:je.offHeap.coreThreads,envcfg:je.offHeap.evictBytes,envcfg:je.offHeap.keepAlive,envcfg:je.offHeap.maxThreads,envcfg:je.rep.logFlushTaskInterval,envcfg:je.rep.runLogFlushTask,envcfg:je.sharedCache,envcfg:je.stats.collect,envcfg:je.stats.collect.interval,envcfg:je.stats.file.directory,envcfg:je.stats.file.row.count,envcfg:je.stats.max.files,envcfg:je.tree.binDelta,envcfg:je.tree.binDeltaBlindOps,envcfg:je.tree.binDeltaBlindPuts,envcfg:je.tree.compactMaxKeyLength,envcfg:je.tree.maxDelta,envcfg:je.tree.maxEmbeddedLN,envcfg:je.tree.minMemory,envcfg:je.txn.deadlockStackTrace,envcfg:je.txn.dumpLocks,envcfg:je.txn.durability,envcfg:je.txn.serializableIsolation,envcfg:je.txn.timeout,java:args,java:maxMemory,java:minMemory,java:vendor,java:version,je:version,mc:arch,mc:processors,os:name,os:version
 2024-08-23 21:10:39.878 UTC,"OFF","INFO","0","20000000","3","false","0","false","false","0","5","20","5","1000","false","false","3","2","true","false","","false","true","false","500 ms","8192","0","2","5","5","50","0","5","10","true","1","true","10","0","0","false","10 s","3","500 ms","5 s","false","0","1 ms","0","true","false","100","true","10 seconds","true","true","false","false","false","true","false","true","5 min","true","true","false","false","true","true","true","true","true","true","false","true","5 min","10 s","2 h","5 s","24 h","true","10 ms","1000","false","true","100 ms","5 min","false","0 0 * * *","true","true","1","0","3","524288","10","false","10 min","true","10","true","4","10","10","true","95","5 s","0","false","true","0","1","false","0 MICROSECONDS","1048576","true","0","true","1000 ms","false","2048","100","10000000","10485760","0","5 s","20 s","5 s","500 ms","0 ns","0","16777216","8192","false","0","3","0","false","false","true","false","1048576","0","0","60","0","128","128","false","1","52428800","10 min","3","5 min","true","true","true","1 min","","1440","10","25","true","true","16","10","16","512000","false","false","SYNC,NO_SYNC,SIMPLE_MAJORITY","false","0","","8287944704","520093696","Red Hat, Inc.","17.0.12","7.5.11","amd64","8","Linux","6.9.9-200.fc40.x86_64"
+2024-09-10 09:20:58.511 UTC,"OFF","INFO","0","20000000","3","false","0","false","false","0","5","20","5","1000","false","false","3","2","true","false","","false","true","false","500 ms","8192","0","2","5","5","50","0","5","10","true","1","true","10","0","0","false","10 s","3","500 ms","5 s","false","0","1 ms","0","true","false","100","true","10 seconds","true","true","false","false","false","true","false","true","5 min","true","true","false","false","true","true","true","true","true","true","false","true","5 min","10 s","2 h","5 s","24 h","true","10 ms","1000","false","true","100 ms","5 min","false","0 0 * * *","true","true","1","0","3","524288","10","false","10 min","true","10","true","4","10","10","true","95","5 s","0","false","true","0","1","false","0 MICROSECONDS","1048576","true","0","true","1000 ms","false","2048","100","10000000","10485760","0","5 s","20 s","5 s","500 ms","0 ns","0","16777216","8192","false","0","3","0","false","false","true","false","1048576","0","0","60","0","128","128","false","1","52428800","10 min","3","5 min","true","true","true","1 min","","1440","10","25","true","true","16","10","16","512000","false","false","SYNC,NO_SYNC,SIMPLE_MAJORITY","false","0","","8287944704","520093696","Red Hat, Inc.","17.0.12","7.5.11","amd64","8","Linux","6.10.7-200.fc40.x86_64"
diff --git a/handle_server/templates/bdbje/je.stat.csv b/handle_server/templates/bdbje/je.stat.csv
index eb8548d..2b3f01e 100644
--- a/handle_server/templates/bdbje/je.stat.csv
+++ b/handle_server/templates/bdbje/je.stat.csv
@@ -3,3 +3,18 @@ time,Cache:DOSBytes,Cache:adminBytes,Cache:cacheTotalBytes,Cache:dataAdminBytes,
 2024-08-23 21:11:39.942 UTC, ,125,3162749,1208,16672,224, ,3, ,6, , , , , , , , , ,3,3, , , , ,1,3, , , , , , , , , , , ,1, , , ,3162749,1218,1,573,573, , , , ,1446,206759624704,54,54, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,1446, ,1724447439700, , , , ,3145728,1419, , , ,5,2,6,2,2,2, , ,3,3, , , , , , , , , , , ,4096,2,180,2, , , , , , ,1,5,34192584, , , , , , , ,6, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 
 2024-08-23 21:12:39.945 UTC, ,125,3162749,1208,16672,224, ,3, , , , , , , , , , , ,3,3, , , , ,1,3, , , , , , , , , , , ,1, , , ,3162749,1218,1,573,573, , , , ,1446,206759571456,54,54, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,1446, ,1724447439700, , , , ,3145728,1419, , , ,0, , , , , , , ,3, , , , , , , , , , , , , , , , , , , , , , , , ,34192584, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 
 2024-08-23 21:13:38.588 UTC, ,125,3165661,1312,19808, , ,4, ,2, , , , , , , , , ,4,4, , , , ,1,5, ,1, , , , , , , , , ,1, , , ,3165661,1218,1,573,573, , , , ,1942,206759608320,65,65, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,1942, ,1724447439700, , , , ,3145728,1915, , , ,1,1,2,1, ,1, , ,3,2, , , , , , , , , , , , , ,496,1, , , , , , , , ,34192584, , , , , , , ,2, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,1, ,1, , , , , , , , , 
+2024-09-10 09:20:58.574 UTC, ,125,3160261,1184,14408, , ,3, ,24,3,0.13, , , , , , , ,3,3, ,2, ,2,1,5, ,22,10, , , , , , , , ,1, , , ,3160261,3002,2, ,2060, , , , ,3047,189099925504,47,47, , , , , ,1,41, , , , , , , , , , , , , , , , , , , , , , , , , ,3047, ,1725960058265, , , , ,3145728,3002, , ,18,0, , , ,2, , , ,3, , , , ,18, ,2048,1, , , , ,100892,29, , , , , , , , ,1,3,18021376, , , , , , , ,16, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 
+2024-09-10 09:21:58.581 UTC, ,125,3165373,1312,19296,224, ,4, ,6, , , , , , , , , ,4,4, , , ,2,1,5, ,5,4, , , , , , , , ,1, , , ,3165373,3002,2, ,2060, , , , ,3047,189099917312,47,47, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,3047, ,1725960058265, , , , ,3145728,3002, , ,6,0, , , ,1, , , ,3, , , , ,6,1, , , , , , ,6605,7, , , , , , , , ,1,4,34955968, , , , , , , ,7, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,1, , , , , , , , , 
+2024-09-10 09:22:58.584 UTC, ,589,3165837,1312,19296,224, ,4, ,4, , , , , , , , , ,4,4, , , ,2,1,5, ,1, , , , , , , , , ,1, , , ,3165837,3002,2, ,2060, , , , ,3047,189099900928,47,47, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,3047, ,1725960058265, , , , ,3145728,3539, , , ,2,2,3,2,2,2, , ,3,3, , , , ,1, , , , , , ,4096,2,519,2, , , , , , , , ,39150272, , , , , , , ,3, , , , , , , , , , , , , , , , , , , , , , , , , , , , ,1, ,1, , , , , , , , , , , 
+2024-09-10 09:23:58.588 UTC, ,589,3165837,1312,19296,224, ,4, , , , , , , , , , , ,4,4, , , ,2,1,5, , , , , , , , , , , ,1, , , ,3165837,3002,2, ,2060, , , , ,3566,189099892736,40,40, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,3566, ,1725960058265, , , , ,3145728,3539, , , ,0, , , , , , , ,3, , , , , ,1, , , , , , , , , , , , , , , , , , ,43344576, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 
+2024-09-10 09:24:58.594 UTC, ,589,3165837,1312,19296,224, ,4, ,6, , , , , , , , , ,4,4, , , ,2,1,5, ,3, , , , , , , , , ,1, , , ,3165837,3002,2, ,2060, , , , ,4344,189099896832,41,41, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,4344, ,1725960058265, , , , ,3145728,4317, , , ,3,2,6,2, ,2, , ,3,4, , , , ,1, , , , , , , , ,778,2, , , , , , ,1,16,28226624, , , , , , , ,6, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,1, ,2,2, ,1, , , , , , 
+2024-09-10 09:25:58.600 UTC, ,589,3165837,1312,19296,224, ,4, , , , , , , , , , , ,4,4, , , ,2,1,5, , , , , , , , , , , ,1, , , ,3165837,3002,2, ,2060, , , , ,4344,189099892736,41,41, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,4344, ,1725960058265, , , , ,3145728,4317, , , ,0, , , , , , , ,3, , , , , ,1, , , , , , , , , , , , , , , , , , ,28226624, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 
+2024-09-10 09:26:12.165 UTC, ,589,3165613,1312,19296, , ,4, , , , , , , , , , , ,4,4, , , ,2,1,5, , , , , , , , , , , ,1, , , ,3165613,3002,2, ,2060, , , , ,4344,189099892736,41,41, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,4344, ,1725960058265, , , , ,3145728,4317, , , ,0, , , , , , , ,3, , , , , ,1, , , , , , , , , , , , , , , , , , ,28226624, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 
+2024-09-10 10:52:13.275 UTC, ,125,3160285,1184,14432, , ,3, ,24,3,0.13, , , , , , , ,3,3, ,2, ,2,1,5, ,24,11, , , , , , , , ,1, , , ,3160285,5069,3, ,4508, , , , ,5114,189024944128,37,37, , , , , ,1,53, , , , , , , , , , , , , , , , , , , , , , , , , ,5114, ,1725965533025, , , , ,3145728,5069, , ,19,0, , , ,2, , , ,3, , , , ,19, ,2048,1, , , , ,100979,30, , , , , , , , ,1,3,17752576, , , , , , , ,16, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 
+2024-09-10 10:52:41.119 UTC, ,125,3165197,1312,19344, , ,4, ,7, , , , , , , , , ,4,4, , , ,2,1,5, ,7,5, , , , , , , , ,1, , , ,3165197,5069,3, ,4508, , , , ,5114,189024944128,37,37, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,5114, ,1725965533025, , , , ,3145728,5069, , ,7,0, , , ,1, , , ,3, , , , ,7,1, , , , , , ,6965,8, , , , , , , , ,1,4,29953832, , , , , , , ,9, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,2,1, , , , , , , , 
+2024-09-10 12:02:16.073 UTC, ,125,3160285,1184,14432, , ,3, ,24,3,0.13, , , , , , , ,3,3, ,2, ,2,1,5, ,24,11, , , , , , , , ,1, , , ,3160285,5069,3, ,4508, , , , ,5114,189003874304,37,37, , , , , ,1,53, , , , , , , , , , , , , , , , , , , , , , , , , ,5114, ,1725969735784, , , , ,3145728,5069, , ,19,0, , , ,2, , , ,3, , , , ,19, ,2048,1, , , , ,100979,30, , , , , , , , ,1,3,17767936, , , , , , , ,16, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 
+2024-09-10 12:03:16.078 UTC, ,125,3165421,1312,19344,224, ,4, ,6, , , , , , , , , ,4,4, , , ,2,1,5, ,6,5, , , , , , , , ,1, , , ,3165421,5069,3, ,4508, , , , ,5114,189003866112,37,37, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,5114, ,1725969735784, , , , ,3145728,5069, , ,7,0, , , ,1, , , ,3, , , , ,7,1, , , , , , ,6965,8, , , , , , , , ,1,4,34179632,1, , , , , , ,8, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,2, , , , , , , , , 
+2024-09-10 12:04:16.080 UTC, ,125,3165421,1312,19344,224, ,4, ,2, , , , , , , , , ,4,4, , , ,2,1,5, ,2, , , , , , , , , ,1, , , ,3165421,5069,3, ,4508, , , , ,5114,189003767808,37,37, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,5114, ,1725969735784, , , , ,3145728,5069, , , ,0, , , , , , , ,3, , , , , ,1, , , , , , , , , , , , , , , , , , ,34179632, , , , , , , ,2, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,2, , , , , , , , , 
+2024-09-10 12:05:16.084 UTC, ,125,3165421,1312,19344,224, ,4, ,3, , , , , , , , , ,4,4, , , ,2,1,5, ,2, , , , , , , , , ,1, , , ,3165421,5069,3, ,4508, , , , ,5243,189003767808,36,36, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,5243, ,1725969735784, , , , ,3145728,5216, , , ,2,1,2,1,2,1, , ,3,2, , , , ,1, , , , , , ,4096,2,129,1, , , , , , , , ,38373936, , , , , , , ,4, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,1, ,3, , , , , , , , , 
+2024-09-10 12:06:16.088 UTC, ,125,3165421,1312,19344,224, ,4, ,4, , , , , , , , , ,4,4, , , ,2,1,5, ,3, , , , , , , , , ,1, , , ,3165421,5069,3, ,4508, , , , ,5302,189003763712,35,35, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,5302, ,1725969735784, , , , ,3145728,5275, , , ,2,1,2,1, ,1, , ,3,2, , , , ,1, , , , , , , , ,59,1, , , , , , , , ,42568240, , , , , , , ,6, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,1, ,4,1, , , , , , , , 
+2024-09-10 12:06:37.921 UTC, ,125,3165197,1312,19344, , ,4, , , , , , , , , , , ,4,4, , , ,2,1,5, , , , , , , , , , , ,1, , , ,3165197,5069,3, ,4508, , , , ,5302,189003743232,35,35, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,5302, ,1725969735784, , , , ,3145728,5275, , , ,0, , , , , , , ,3, , , , , ,1, , , , , , , , , , , , , , , , , , ,42568240, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 
diff --git a/handle_server/templates/bootstrap_handles b/handle_server/templates/bootstrap_handles
new file mode 100644
index 0000000..914cc05
--- /dev/null
+++ b/handle_server/templates/bootstrap_handles
@@ -0,0 +1,99 @@
+{
+  "lastUpdate": 1725884218416,
+  "handles": {
+    "0.0/0.0": {
+      "handle": "0.0/0.0",
+      "values": [
+        {
+          "index": 100,
+          "type": "HS_ADMIN",
+          "data": {
+            "format": "admin",
+            "value": {
+              "handle": "0.TEST/ADMIN",
+              "index": 200,
+              "permissions": "011111110011"
+            }
+          },
+          "ttl": 86400,
+          "timestamp": "2014-09-18T15:55:32Z"
+        }
+      ]
+    },
+    "0.NA/0.NA": {
+      "handle": "0.NA/0.NA",
+      "values": [
+        {
+          "index": 100,
+          "type": "HS_ADMIN",
+          "data": {
+            "format": "admin",
+            "value": {
+              "handle": "0.TEST/ADMIN",
+              "index": 200,
+              "permissions": "111111111111"
+            }
+          },
+          "ttl": 86400,
+          "timestamp": "2015-12-08T22:00:05Z"
+        },
+        {
+          "index": 5,
+          "type": "HS_SITE",
+          "data": {
+            "format": "site",
+            "value": {
+  "version": 1,
+  "protocolVersion": "2.11",
+  "serialNumber": 1,
+  "primarySite": true,
+  "multiPrimary": false,
+  "attributes": [
+    {
+      "name": "desc",
+      "value": ""
+    }
+  ],
+  "servers": [
+    {
+      "serverId": 1,
+      "address": "HANDLE_SERVER_IPV4_ADDRESS",
+      "publicKey": {
+        "format": "key",
+        "value": {
+          "kty": "RSA",
+          "n": "wqkCd9QfFxYwMhQM72k-nQ5yL0lbxz9OTOTgR2eFj6dz5YZzoDg3t4MauMVUt5pkByWScle-7mdVJHuEp1GErqyzW3dPagTgmzc1R1i2gQF5fUiJFx90hkAzh88PW4qFs_YBwOsChGanGzsqn6cbKV3VQn5K2QZHF7rxeKdstF72lFN7ewkk-Kw5i0I3akpGYu9YJ_Is8k7rDQ5P_KKfrn_N_0_seQO-IT9vW_u0IvK75_6VwNjU5wU6SDF9dgivSk-qv7R_rpl8eAow0zUkllsFqJxEEn63koK5gSsKitfN7Jt_71b_Nwmjpv2gEydh42bEOSHx0dFeALwY1rl74w",
+          "e": "AQAB"
+        }
+      },
+      "interfaces": [
+        {
+          "query": true,
+          "admin": true,
+          "protocol": "TCP",
+          "port": 2641
+        },
+        {
+          "query": true,
+          "admin": false,
+          "protocol": "UDP",
+          "port": 2641
+        },
+        {
+          "query": true,
+          "admin": true,
+          "protocol": "HTTP",
+          "port": 8000
+        }
+      ]
+    }
+  ]
+            }
+          },
+          "ttl": 86400,
+          "timestamp": "2023-04-18T08:07:14Z"
+        }
+      ]
+    }
+  }
+}
diff --git a/handle_server/templates/config.dct b/handle_server/templates/config.dct
index 6a1ee17..3540cab 100644
--- a/handle_server/templates/config.dct
+++ b/handle_server/templates/config.dct
@@ -35,22 +35,26 @@
 
   "server_config" = {
     "server_admins" = (
-      "300:0.TEST/ADMIN"
+      "300:TEST/ADMIN"
     )
 
     "replication_admins" = (
-      "300:0.TEST/ADMIN"
+      "300:TEST/ADMIN"
     )
 
+    "enable_monitor_daemon" = "yes"
     "max_session_time" = "86400000"
     "this_server_id" = "1"
     "max_auth_time" = "60000"
     "server_admin_full_access" = "yes"
     "case_sensitive" = "no"
     "allow_na_admins" = "no"
+    "allow_recursion" = "yes"
     "template_ns_override" = "yes"
     "auto_homed_prefixes" = (
-      "0.NA/0.TEST"
+      "0.NA/TEST"
+      "0.NA/0.NA"
+      "0.NA/0.0"
     )
 
   }
diff --git a/handle_server/templates/setup.batch.hdl b/handle_server/templates/setup.batch.hdl
new file mode 100644
index 0000000..e01606d
--- /dev/null
+++ b/handle_server/templates/setup.batch.hdl
@@ -0,0 +1,8 @@
+AUTHENTICATE PUBKEY:300:TEST/ADMIN
+/hs/templates/admpriv.bin
+
+ADD 0.NA/0.NA
+5 HS_SITE 86000 1110 FILE /hs/srv_1/siteinfo.json
+
+ADD 0.NA/TEST
+5 HS_SITE 86000 1110 FILE /hs/srv_1/siteinfo.json
diff --git a/handle_server/templates/wait-for-it.sh b/handle_server/templates/wait-for-it.sh
new file mode 100755
index 0000000..d69e99f
--- /dev/null
+++ b/handle_server/templates/wait-for-it.sh
@@ -0,0 +1,182 @@
+#!/usr/bin/env bash
+# License: 
+# From https://github.com/vishnubob/wait-for-it
+# The MIT License (MIT)
+# Use this script to test if a given TCP host/port are available
+
+WAITFORIT_cmdname=${0##*/}
+
+echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
+
+usage()
+{
+    cat << USAGE >&2
+Usage:
+    $WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args]
+    -h HOST | --host=HOST       Host or IP under test
+    -p PORT | --port=PORT       TCP port under test
+                                Alternatively, you specify the host and port as host:port
+    -s | --strict               Only execute subcommand if the test succeeds
+    -q | --quiet                Don't output any status messages
+    -t TIMEOUT | --timeout=TIMEOUT
+                                Timeout in seconds, zero for no timeout
+    -- COMMAND ARGS             Execute command with args after the test finishes
+USAGE
+    exit 1
+}
+
+wait_for()
+{
+    if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
+        echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
+    else
+        echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout"
+    fi
+    WAITFORIT_start_ts=$(date +%s)
+    while :
+    do
+        if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then
+            nc -z $WAITFORIT_HOST $WAITFORIT_PORT
+            WAITFORIT_result=$?
+        else
+            (echo > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1
+            WAITFORIT_result=$?
+        fi
+        if [[ $WAITFORIT_result -eq 0 ]]; then
+            WAITFORIT_end_ts=$(date +%s)
+            echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds"
+            break
+        fi
+        sleep 1
+    done
+    return $WAITFORIT_result
+}
+
+wait_for_wrapper()
+{
+    # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
+    if [[ $WAITFORIT_QUIET -eq 1 ]]; then
+        timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
+    else
+        timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
+    fi
+    WAITFORIT_PID=$!
+    trap "kill -INT -$WAITFORIT_PID" INT
+    wait $WAITFORIT_PID
+    WAITFORIT_RESULT=$?
+    if [[ $WAITFORIT_RESULT -ne 0 ]]; then
+        echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
+    fi
+    return $WAITFORIT_RESULT
+}
+
+# process arguments
+while [[ $# -gt 0 ]]
+do
+    case "$1" in
+        *:* )
+        WAITFORIT_hostport=(${1//:/ })
+        WAITFORIT_HOST=${WAITFORIT_hostport[0]}
+        WAITFORIT_PORT=${WAITFORIT_hostport[1]}
+        shift 1
+        ;;
+        --child)
+        WAITFORIT_CHILD=1
+        shift 1
+        ;;
+        -q | --quiet)
+        WAITFORIT_QUIET=1
+        shift 1
+        ;;
+        -s | --strict)
+        WAITFORIT_STRICT=1
+        shift 1
+        ;;
+        -h)
+        WAITFORIT_HOST="$2"
+        if [[ $WAITFORIT_HOST == "" ]]; then break; fi
+        shift 2
+        ;;
+        --host=*)
+        WAITFORIT_HOST="${1#*=}"
+        shift 1
+        ;;
+        -p)
+        WAITFORIT_PORT="$2"
+        if [[ $WAITFORIT_PORT == "" ]]; then break; fi
+        shift 2
+        ;;
+        --port=*)
+        WAITFORIT_PORT="${1#*=}"
+        shift 1
+        ;;
+        -t)
+        WAITFORIT_TIMEOUT="$2"
+        if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi
+        shift 2
+        ;;
+        --timeout=*)
+        WAITFORIT_TIMEOUT="${1#*=}"
+        shift 1
+        ;;
+        --)
+        shift
+        WAITFORIT_CLI=("$@")
+        break
+        ;;
+        --help)
+        usage
+        ;;
+        *)
+        echoerr "Unknown argument: $1"
+        usage
+        ;;
+    esac
+done
+
+if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then
+    echoerr "Error: you need to provide a host and port to test."
+    usage
+fi
+
+WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15}
+WAITFORIT_STRICT=${WAITFORIT_STRICT:-0}
+WAITFORIT_CHILD=${WAITFORIT_CHILD:-0}
+WAITFORIT_QUIET=${WAITFORIT_QUIET:-0}
+
+# check to see if timeout is from busybox?
+WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
+WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
+if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
+        WAITFORIT_ISBUSY=1
+        WAITFORIT_BUSYTIMEFLAG="-t"
+
+else
+        WAITFORIT_ISBUSY=0
+        WAITFORIT_BUSYTIMEFLAG=""
+fi
+
+if [[ $WAITFORIT_CHILD -gt 0 ]]; then
+    wait_for
+    WAITFORIT_RESULT=$?
+    exit $WAITFORIT_RESULT
+else
+    if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
+        wait_for_wrapper
+        WAITFORIT_RESULT=$?
+    else
+        wait_for
+        WAITFORIT_RESULT=$?
+    fi
+fi
+
+if [[ $WAITFORIT_CLI != "" ]]; then
+    if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then
+        echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess"
+        exit $WAITFORIT_RESULT
+    fi
+    exec "${WAITFORIT_CLI[@]}"
+else
+    exit $WAITFORIT_RESULT
+fi
+
-- 
GitLab