diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-12-03 23:25:06 +0000 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-12-03 23:25:06 +0000 |
commit | 1b6af7836e65e45e810a3aabb1491f8a8320148b (patch) | |
tree | 5ab3595bd934607ab8058e190335023771af7cdd | |
parent | 638ae153cc4286041fd2cf835161ceac449232d4 (diff) | |
download | infinitytier-1b6af7836e65e45e810a3aabb1491f8a8320148b.tar.gz infinitytier-1b6af7836e65e45e810a3aabb1491f8a8320148b.zip |
Don't restart ZeroTier One service if version has not changed.
-rw-r--r-- | ext/installfiles/linux/install.tmpl.sh | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/ext/installfiles/linux/install.tmpl.sh b/ext/installfiles/linux/install.tmpl.sh index c31bd233..e063b7a5 100644 --- a/ext/installfiles/linux/install.tmpl.sh +++ b/ext/installfiles/linux/install.tmpl.sh @@ -62,6 +62,13 @@ if [ "$blobStart" -le "$endMarkerIndex" ]; then exit 2 fi +echo -n 'Getting version of existing install... ' +origVersion=NONE +if [ -x /var/lib/zerotier-one/zerotier-one ]; then + origVersion=`/var/lib/zerotier-one/zerotier-one -v` +fi +echo $origVersion + echo 'Extracting files...' if [ $dryRun -gt 0 ]; then echo ">> tail -c +$blobStart \"$scriptPath\" | gunzip -c | tar -xvop -C / -f -" @@ -70,18 +77,22 @@ else tail -c +$blobStart "$scriptPath" | gunzip -c | tar -xvop --no-overwrite-dir -C / -f - fi -if [ $dryRun -eq 0 -a ! -d "/var/lib/zerotier-one" ]; then +if [ $dryRun -eq 0 -a ! -x "/var/lib/zerotier-one/zerotier-one" ]; then echo 'Archive extraction failed, cannot find zerotier-one binary in "/var/lib/zerotier-one".' exit 2 fi +echo -n 'Getting version of new install... ' +newVersion=`/var/lib/zerotier-one/zerotier-one -v` +echo $newVersion + echo 'Installing zerotier-cli command line utility...' rm -f /usr/bin/zerotier-cli /usr/bin/zerotier-idtool ln -sf /var/lib/zerotier-one/zerotier-one /usr/bin/zerotier-cli ln -sf /var/lib/zerotier-one/zerotier-one /usr/bin/zerotier-idtool -echo 'Installing and (re-)starting zerotier-one daemon...' +echo 'Installing zerotier-one service...' # Note: ensure that service restarts are the last thing this script actually # does, since these may kill the script itself. Also note the & to allow @@ -100,7 +111,10 @@ if [ -n "$SYSTEMDUNITDIR" -a -d "$SYSTEMDUNITDIR" ]; then rm -f /tmp/systemd_zerotier-one.service /tmp/init.d_zerotier-one systemctl enable zerotier-one - systemctl restart zerotier-one & + if [ "$origVersion" != "$newVersion" ]; then + echo 'Version has changed, starting...' + systemctl restart zerotier-one & + fi else cp -f /tmp/init.d_zerotier-one /etc/init.d/zerotier-one chmod 0755 /etc/init.d/zerotier-one @@ -139,10 +153,13 @@ else fi fi - if [ -f /sbin/service -o -f /usr/sbin/service ]; then - service zerotier-one restart & - else - /etc/init.d/zerotier-one restart & + if [ "$origVersion" != "$newVersion" ]; then + echo 'Version has changed, starting...' + if [ -f /sbin/service -o -f /usr/sbin/service ]; then + service zerotier-one restart & + else + /etc/init.d/zerotier-one restart & + fi fi fi |