zerotier: abort on zerotier-idtool error
authorMoritz Warning <moritzwarning@web.de>
Thu, 12 Apr 2018 15:48:14 +0000 (17:48 +0200)
committerMoritz Warning <moritzwarning@web.de>
Thu, 12 Apr 2018 21:20:37 +0000 (23:20 +0200)
Signed-off-by: Moritz Warning <moritzwarning@web.de>
net/zerotier/files/zerotier.init

index 78fe87e9476066ad615a1dd96abe32ee486af92e..6d0f4f239dec776c40fc579b919ea2ee70f6e7f7 100644 (file)
@@ -44,10 +44,13 @@ start_instance() {
 
        if [ "$secret" = "generate" ]; then
                echo "Generate secret - please wait..."
-               local tmp="/tmp/zt.$cfg.secret"
-               zerotier-idtool generate "$tmp" > /dev/null
-               secret="$(cat $tmp)"
-               rm "$tmp"
+               local sf="/tmp/zt.$cfg.secret"
+
+               zerotier-idtool generate "$sf" > /dev/null
+               [ $? -ne 0 ] && return 1
+
+               secret="$(cat $sf)"
+               rm "$sf"
 
                uci set zerotier.$cfg.secret="$secret"
                uci commit zerotier