Browse Source

Merge pull request #2445 from zerotier/docker-local-conf

Allow setting local.conf content from Docker environment variable
Grant Limberg 4 months ago
parent
commit
cadfa0bc4d
2 changed files with 9 additions and 2 deletions
  1. 1 0
      README.docker.md
  2. 8 2
      entrypoint.sh.release

+ 1 - 0
README.docker.md

@@ -64,6 +64,7 @@ You can control a few settings including the identity used and the authtoken use
 - `ZEROTIER_API_SECRET`: replaces the `authtoken.secret` before booting and allows you to manage the control socket's authentication key.
 - `ZEROTIER_API_SECRET`: replaces the `authtoken.secret` before booting and allows you to manage the control socket's authentication key.
 - `ZEROTIER_IDENTITY_PUBLIC`: the `identity.public` file for zerotier-one. Use `zerotier-idtool` to generate one of these for you.
 - `ZEROTIER_IDENTITY_PUBLIC`: the `identity.public` file for zerotier-one. Use `zerotier-idtool` to generate one of these for you.
 - `ZEROTIER_IDENTITY_SECRET`: the `identity.secret` file for zerotier-one. Use `zerotier-idtool` to generate one of these for you.
 - `ZEROTIER_IDENTITY_SECRET`: the `identity.secret` file for zerotier-one. Use `zerotier-idtool` to generate one of these for you.
+- `ZEROTIER_LOCAL_CONF`: Sets the the `local.conf` file content for zerotier-one
 
 
 ### Tips
 ### Tips
 
 

+ 8 - 2
entrypoint.sh.release

@@ -9,15 +9,16 @@ mkztfile() {
   file=$1
   file=$1
   mode=$2
   mode=$2
   content=$3
   content=$3
-
+  echo "creating $file"
   mkdir -p /var/lib/zerotier-one
   mkdir -p /var/lib/zerotier-one
-  echo "$content" > "/var/lib/zerotier-one/$file"
+  echo -n "$content" > "/var/lib/zerotier-one/$file"
   chmod "$mode" "/var/lib/zerotier-one/$file"
   chmod "$mode" "/var/lib/zerotier-one/$file"
 }
 }
 
 
 if [ "x$ZEROTIER_API_SECRET" != "x" ]
 if [ "x$ZEROTIER_API_SECRET" != "x" ]
 then
 then
   mkztfile authtoken.secret 0600 "$ZEROTIER_API_SECRET"
   mkztfile authtoken.secret 0600 "$ZEROTIER_API_SECRET"
+  mkztfile metricstoken.secret 0600 "$ZEROTIER_API_SECRET"
 fi
 fi
 
 
 if [ "x$ZEROTIER_IDENTITY_PUBLIC" != "x" ]
 if [ "x$ZEROTIER_IDENTITY_PUBLIC" != "x" ]
@@ -30,6 +31,11 @@ then
   mkztfile identity.secret 0600 "$ZEROTIER_IDENTITY_SECRET"
   mkztfile identity.secret 0600 "$ZEROTIER_IDENTITY_SECRET"
 fi
 fi
 
 
+if [ "x$ZEROTIER_LOCAL_CONF" != "x" ]
+then
+  mkztfile local.conf 0644 "$ZEROTIER_LOCAL_CONF"
+fi
+
 mkztfile zerotier-one.port 0600 "9993"
 mkztfile zerotier-one.port 0600 "9993"
 
 
 killzerotier() {
 killzerotier() {