buildinstaller.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/bin/bash
  2. # This script builds the installer for *nix systems. Windows must do everything
  3. # completely differently, as usual.
  4. export PATH=/bin:/usr/bin:/sbin:/usr/sbin
  5. if [ ! -f zerotier-one ]; then
  6. echo "Could not find 'zerotier-one' binary, please build before running this script."
  7. exit 2
  8. fi
  9. machine=`uname -m`
  10. system=`uname -s`
  11. vmajor=`cat version.h | grep -F ZEROTIER_ONE_VERSION_MAJOR | cut -d ' ' -f 3`
  12. vminor=`cat version.h | grep -F ZEROTIER_ONE_VERSION_MINOR | cut -d ' ' -f 3`
  13. revision=`cat version.h | grep -F ZEROTIER_ONE_VERSION_REVISION | cut -d ' ' -f 3`
  14. if [ -z "$vmajor" -o -z "$vminor" -o -z "$revision" ]; then
  15. echo "Unable to extract version info from version.h, aborting installer build."
  16. exit 2
  17. fi
  18. rm -rf build-installer
  19. mkdir build-installer
  20. case "$system" in
  21. Linux)
  22. # Canonicalize $machine for some architectures... we use x86
  23. # and x64 for Intel stuff. ARM and others should be fine if
  24. # we ever ship officially for those.
  25. case "$machine" in
  26. i386|i486|i586|i686)
  27. machine="x86"
  28. ;;
  29. x86_64|amd64|x64)
  30. machine="x64"
  31. ;;
  32. *)
  33. echo "Unsupported machine type: $machine"
  34. exit 2
  35. esac
  36. echo "Assembling Linux installer for $machine and version $vmajor.$vminor.$revision"
  37. mkdir -p 'build-installer/var/lib/zerotier-one'
  38. cp -fp 'ext/installfiles/linux/uninstall.sh' 'build-installer/var/lib/zerotier-one'
  39. cp -fp 'zerotier-one' 'build-installer/var/lib/zerotier-one'
  40. mkdir -p 'build-installer/tmp'
  41. cp -fp 'ext/installfiles/linux/init.d/zerotier-one' 'build-installer/tmp/init.d_zerotier-one'
  42. cp -fp 'ext/installfiles/linux/systemd/zerotier-one.service' 'build-installer/tmp/systemd_zerotier-one.service'
  43. targ="ZeroTierOneInstaller-linux-${machine}-${vmajor}_${vminor}_${revision}"
  44. # Use gzip in Linux since some minimal Linux systems do not have bunzip2
  45. rm -f build-installer-tmp.tar.gz
  46. cd build-installer
  47. tar -cf - * | gzip -9 >../build-installer-tmp.tar.gz
  48. cd ..
  49. rm -f $targ
  50. cat ext/installfiles/linux/install.tmpl.sh build-installer-tmp.tar.gz >$targ
  51. chmod 0755 $targ
  52. rm -f build-installer-tmp.tar.gz
  53. ls -l $targ
  54. ;;
  55. Darwin)
  56. echo "Assembling mac installer for x86/x64 (combined) version $vmajor.$vminor.$revision"
  57. mkdir -p 'build-installer/Applications'
  58. cp -a 'build-ZeroTierUI-release/ZeroTier One.app' 'build-installer/Applications'
  59. mkdir -p 'build-installer/Library/Application Support/ZeroTier/One'
  60. cp -fp 'ext/installfiles/mac/uninstall.sh' 'build-installer/Library/Application Support/ZeroTier/One'
  61. cp -fp 'ext/installfiles/mac/launch.sh' 'build-installer/Library/Application Support/ZeroTier/One'
  62. cp -fp 'zerotier-one' 'build-installer/Library/Application Support/ZeroTier/One'
  63. cp -fRp ext/bin/tap-mac/* 'build-installer/Library/Application Support/ZeroTier/One'
  64. mkdir -p 'build-installer/Library/LaunchDaemons'
  65. cp -fp 'ext/installfiles/mac/com.zerotier.one.plist' 'build-installer/Library/LaunchDaemons'
  66. targ="ZeroTierOneInstaller-mac-combined-${vmajor}_${vminor}_${revision}"
  67. rm -f build-installer-tmp.tar.bz2
  68. cd build-installer
  69. find . -type f -name .DS_Store -print0 | xargs -0 rm -f
  70. tar -cf - * | bzip2 -9 >../build-installer-tmp.tar.bz2
  71. cd ..
  72. rm -f $targ
  73. cat ext/installfiles/mac/install.tmpl.sh build-installer-tmp.tar.bz2 >$targ
  74. chmod 0755 $targ
  75. rm -f build-installer-tmp.tar.bz2
  76. ls -l $targ
  77. ;;
  78. *)
  79. echo "Unsupported platform: $system"
  80. exit 2
  81. esac
  82. exit 0