diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ae5aecd --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +root = true + +[*.{go}] +indent_style = tabs +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[{Makefile}] +indent_style = tabs +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cff8a42 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:14.04 +MAINTAINER Microfactory +RUN apt-get update; apt-get install -y curl unzip; + +# install golang runtime +RUN curl -L https://storage.googleapis.com/golang/go1.5.2.linux-amd64.tar.gz > /tmp/golang.tar.gz; tar -C /usr/local -xzf /tmp/golang.tar.gz; rm /tmp/golang.tar.gz + +#zerotier +RUN curl -L https://download.zerotier.com/dist/zerotier-one_1.1.2_amd64.deb > /tmp/ztier.deb; dpkg -i /tmp/ztier.deb; rm /tmp/ztier.deb + +# #setup go env +ENV GOPATH=/ GO15VENDOREXPERIMENT=1 PATH=$PATH:/usr/local/go/bin +ADD . /src/github.com/microfactory/zero +WORKDIR /src/github.com/microfactory/zero +RUN go build -ldflags="-X main.Version=`cat VERSION`" -o /usr/local/bin/zero main.go +ENTRYPOINT ["zero"] diff --git a/README.md b/README.md index f689ae3..1e151e4 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ -# zero-up -A single-binary utility for launching a machine into a ZeroTier network unattended +# zero +[ZeroTier](https://www.zerotier.com/) is an awesome zero-configuration vpn that runs almost anywhere. But the default CLI doesn't make particulary easy to join a network unattended. Manual intervention can be combersome in a cluster environment were machine are added and removed dynamically. + +*Zero* presents the simple function of joining a Zerotier network without manual intervention. It does this by using the ZeroTier API: + +``` +usage: zero zt_net zt_token +``` + +The `zt_net` (network ID) and `zt_token` (API access token) can both be retrieved from the ZeroTier web interface. A typical example looks like this: + +``` +zero e6df831e1c561fff ZkJelfeQ1dd2ffff +``` diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..6c6aa7c --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0 \ No newline at end of file diff --git a/main.go b/main.go new file mode 100644 index 0000000..d985ee1 --- /dev/null +++ b/main.go @@ -0,0 +1,14 @@ +package main + +import ( + "flag" + "log" +) + +func main() { + flag.Parse() + log.SetPrefix("zero: ") + log.SetFlags(0) + + log.Printf("Hello World!") +} diff --git a/make.sh b/make.sh new file mode 100755 index 0000000..685af30 --- /dev/null +++ b/make.sh @@ -0,0 +1,25 @@ +#! /bin/bash +set -e + +function print_help { + printf "Available Commands:\n"; + printf " run\n" +} + +function run_build_container { + docker build -t microfactory/zero:`cat VERSION` . +} + +# run a Linux test environment +function run_run { + run_build_container + docker run -it --rm \ + --device=/dev/net/tun \ + --cap-add=NET_ADMIN \ + microfactory/zero:`cat VERSION` +} + +case $1 in + "run") run_run ;; + *) print_help ;; +esac