Skip to content
Permalink
Browse files

passing masterkey as environment variable

  • Loading branch information
stremovsky committed Dec 15, 2019
1 parent 7c1e5d2 commit 96130295fcbf74c53cfa0b6b86ba738319b79be9
Showing with 19 additions and 7 deletions.
  1. +3 −1 Dockerfile
  2. +6 −2 create-test-user.sh
  3. +6 −4 run.sh
  4. +4 −0 src/bunker.go
@@ -37,12 +37,14 @@ COPY --from=builder /bin/busybox /bin/busybox
COPY --from=builder /bin/busybox /bin/sh
COPY --from=builder /lib/ld* /lib/
COPY --from=builder /go/bin/databunker /databunker/bin/databunker
COPY run.sh /databunker/bin/run.sh
COPY run.sh /databunker/bin/
#COPY create-test-user.sh /databunker/bin/
COPY databunker.yaml /databunker/conf/
RUN /bin/busybox mkdir -p /databunker/data
RUN /bin/busybox mkdir -p /databunker/certs
#RUN /bin/busybox ln -s /bin/busybox /bin/sh
# Run the hello binary.
#ENTRYPOINT ["/go/bin/databunker"]
EXPOSE 3000
ENTRYPOINT ["/bin/sh", "/databunker/bin/run.sh"]
#CMD ["/bin/sh", "-x", "-c", "/go/bin/databunker -init"]
@@ -1,6 +1,10 @@
#!/bin/bash
#!/bin/sh

DATABUNKER_APIKEY='689464cf-2485-b7e8-1c65-f2ce40ce507c'
DATABUNKER_APIKEY=$1
if [ -z $DATABUNKER_APIKEY ]; then
echo "missing api key parameter"
exit
fi

echo "Creating user."
RESULT=`curl -s http://localhost:3000/v1/user \
10 run.sh
@@ -2,19 +2,21 @@

/bin/busybox find /databunker

DATABUNKER_MASTERKEY=""
if [ ! -f /databunker/data/databunker.db ]; then
echo "-------------INIT------------"
/bin/busybox mkdir -p /tmp
RESULT=`/databunker/bin/databunker -init -db /databunker/data/databunker.db -conf /databunker/conf/databunker.yaml > /tmp/init.txt`
echo $RESULT
ROOT_TOKEN=`/bin/busybox awk '/API Root token:/ {print $4}' /tmp/init.txt`
DATABUNKER_ROOTTOKEN=`/bin/busybox awk '/API Root token:/ {print $4}' /tmp/init.txt`
DATABUNKER_MASTERKEY=`/bin/busybox awk '/Master key:/ {print $3}' /tmp/init.txt`
echo "DATABUNKER_ROOTTOKEN $ROOT_TOKEN"
echo "DATABUNKER_ROOTTOKEN $DATABUNKER_ROOTTOKEN"
echo "DATABUNKER_MASTERKEY $DATABUNKER_MASTERKEY"
/bin/busybox rm -rf /tmp/init.txt
fi
#echo "-------------ENV-------------"
#/bin/busybox env
echo "-------------FIND------------"
/bin/busybox find /databunker
echo "-------------RUN-------------"
/databunker/bin/databunker -masterkey $DATABUNKER_MASTERKEY -db /databunker/data/databunker.db -conf /databunker/conf/databunker.yaml
/databunker/bin/databunker -masterkey $DATABUNKER_MASTERKEY \
-db /databunker/data/databunker.db -conf /databunker/conf/databunker.yaml
@@ -252,6 +252,10 @@ func main() {
os.Exit(0)
}
if masterKeyPtr != nil && len(*masterKeyPtr) > 0 {
if len(*masterKeyPtr) != 48 {
fmt.Printf("Failed to decode master key: bad length\n")
os.Exit(0)
}
masterKey, err = hex.DecodeString(*masterKeyPtr)
if err != nil {
fmt.Printf("Failed to decode master key: %s\n", err)

0 comments on commit 9613029

Please sign in to comment.
You can’t perform that action at this time.