diff --git a/entrypoint.sh.release b/entrypoint.sh.release index 71d3a7cf2..bb0744e82 100644 --- a/entrypoint.sh.release +++ b/entrypoint.sh.release @@ -33,29 +33,57 @@ fi mkztfile zerotier-one.port 0600 "9993" killzerotier() { - echo "Killing zerotier" + log "Killing zerotier" kill $(cat /var/lib/zerotier-one/zerotier-one.pid 2>/dev/null) exit 0 } +log_header() { + echo -n "\r=>" +} + +log_detail_header() { + echo -n "\r===>" +} + +log() { + echo "$(log_header)" "$@" +} + +log_params() { + title=$1 + shift + log "$title" "[$@]" +} + +log_detail() { + echo "$(log_detail_header)" "$@" +} + +log_detail_params() { + title=$1 + shift + log_detail "$title" "[$@]" +} + trap killzerotier INT TERM -echo "Configuring networks to join" +log "Configuring networks to join" mkdir -p /var/lib/zerotier-one/networks.d -echo "joining networks: $@" +log_params "Joining networks:" $@ for i in "$@" do - echo "Configuring join for $i" + log_detail_params "Configuring join:" "$i" touch "/var/lib/zerotier-one/networks.d/${i}.conf" done -echo "starting zerotier" +log "Starting ZeroTier" nohup /usr/sbin/zerotier-one & while ! grepzt do - echo "zerotier hasn't started, waiting a second" + log_detail "ZeroTier hasn't started, waiting a second" if [ -f nohup.out ] then @@ -65,7 +93,7 @@ do sleep 1 done -echo "Writing healthcheck for networks: $@" +log_params "Writing healthcheck for networks:" $@ cat >/healthcheck.sh <