buildinstaller.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. esac
  33. echo "Assembling Linux installer for $machine and version $vmajor.$vminor.$revision"
  34. mkdir -p 'build-installer/var/lib/zerotier-one'
  35. cp -fp 'ext/installfiles/linux/uninstall.sh' 'build-installer/var/lib/zerotier-one'
  36. cp -fp 'zerotier-one' 'build-installer/var/lib/zerotier-one'
  37. mkdir -p 'build-installer/tmp'
  38. cp -fp 'ext/installfiles/linux/init.d/zerotier-one' 'build-installer/tmp/init.d_zerotier-one'
  39. cp -fp 'ext/installfiles/linux/systemd/zerotier-one.service' 'build-installer/tmp/systemd_zerotier-one.service'
  40. targ="ZeroTierOneInstaller-linux-${machine}-${vmajor}_${vminor}_${revision}"
  41. # Use gzip in Linux since some minimal Linux systems do not have bunzip2
  42. rm -f build-installer-tmp.tar.gz
  43. cd build-installer
  44. tar -cf - * | gzip -9 >../build-installer-tmp.tar.gz
  45. cd ..
  46. rm -f $targ
  47. cat ext/installfiles/linux/install.tmpl.sh build-installer-tmp.tar.gz >$targ
  48. chmod 0755 $targ
  49. rm -f build-installer-tmp.tar.gz
  50. ls -l $targ
  51. ;;
  52. Darwin)
  53. echo "Assembling mac installer for x86/x64 (combined) version $vmajor.$vminor.$revision"
  54. mkdir -p 'build-installer/Applications'
  55. cp -a 'build-ZeroTierUI-release/ZeroTier One.app' 'build-installer/Applications'
  56. mkdir -p 'build-installer/Library/Application Support/ZeroTier/One'
  57. cp -fp 'ext/installfiles/mac/uninstall.sh' 'build-installer/Library/Application Support/ZeroTier/One'
  58. cp -fp 'ext/installfiles/mac/launch.sh' 'build-installer/Library/Application Support/ZeroTier/One'
  59. cp -fp 'zerotier-one' 'build-installer/Library/Application Support/ZeroTier/One'
  60. cp -fRp ext/bin/tap-mac/* 'build-installer/Library/Application Support/ZeroTier/One'
  61. mkdir -p 'build-installer/Library/LaunchDaemons'
  62. cp -fp 'ext/installfiles/mac/com.zerotier.one.plist' 'build-installer/Library/LaunchDaemons'
  63. targ="ZeroTierOneInstaller-mac-combined-${vmajor}_${vminor}_${revision}"
  64. rm -f build-installer-tmp.tar.bz2
  65. cd build-installer
  66. find . -type f -name .DS_Store -print0 | xargs -0 rm -f
  67. tar -cf - * | bzip2 -9 >../build-installer-tmp.tar.bz2
  68. cd ..
  69. rm -f $targ
  70. cat ext/installfiles/mac/install.tmpl.sh build-installer-tmp.tar.bz2 >$targ
  71. chmod 0755 $targ
  72. rm -f build-installer-tmp.tar.bz2
  73. ls -l $targ
  74. ;;
  75. *)
  76. echo "Unsupported platform: $system"
  77. exit 2
  78. esac
  79. exit 0