mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-31 16:35:26 +00:00
prettify the entrypoint log output
Signed-off-by: Erik Hollensbe <git@hollensbe.org>
This commit is contained in:
parent
cade483a00
commit
8598f34ebf
@ -33,29 +33,57 @@ fi
|
|||||||
mkztfile zerotier-one.port 0600 "9993"
|
mkztfile zerotier-one.port 0600 "9993"
|
||||||
|
|
||||||
killzerotier() {
|
killzerotier() {
|
||||||
echo "Killing zerotier"
|
log "Killing zerotier"
|
||||||
kill $(cat /var/lib/zerotier-one/zerotier-one.pid 2>/dev/null)
|
kill $(cat /var/lib/zerotier-one/zerotier-one.pid 2>/dev/null)
|
||||||
exit 0
|
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
|
trap killzerotier INT TERM
|
||||||
|
|
||||||
echo "Configuring networks to join"
|
log "Configuring networks to join"
|
||||||
mkdir -p /var/lib/zerotier-one/networks.d
|
mkdir -p /var/lib/zerotier-one/networks.d
|
||||||
|
|
||||||
echo "joining networks: $@"
|
log_params "Joining networks:" $@
|
||||||
for i in "$@"
|
for i in "$@"
|
||||||
do
|
do
|
||||||
echo "Configuring join for $i"
|
log_detail_params "Configuring join:" "$i"
|
||||||
touch "/var/lib/zerotier-one/networks.d/${i}.conf"
|
touch "/var/lib/zerotier-one/networks.d/${i}.conf"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "starting zerotier"
|
log "Starting ZeroTier"
|
||||||
nohup /usr/sbin/zerotier-one &
|
nohup /usr/sbin/zerotier-one &
|
||||||
|
|
||||||
while ! grepzt
|
while ! grepzt
|
||||||
do
|
do
|
||||||
echo "zerotier hasn't started, waiting a second"
|
log_detail "ZeroTier hasn't started, waiting a second"
|
||||||
|
|
||||||
if [ -f nohup.out ]
|
if [ -f nohup.out ]
|
||||||
then
|
then
|
||||||
@ -65,7 +93,7 @@ do
|
|||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Writing healthcheck for networks: $@"
|
log_params "Writing healthcheck for networks:" $@
|
||||||
|
|
||||||
cat >/healthcheck.sh <<EOF
|
cat >/healthcheck.sh <<EOF
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
@ -77,9 +105,9 @@ EOF
|
|||||||
|
|
||||||
chmod +x /healthcheck.sh
|
chmod +x /healthcheck.sh
|
||||||
|
|
||||||
echo "zerotier-cli info: $(zerotier-cli info)"
|
log_params "zerotier-cli info:" "$(zerotier-cli info)"
|
||||||
|
|
||||||
echo "Sleeping infinitely"
|
log "Sleeping infinitely"
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
sleep 1
|
sleep 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user