zerotier.spec 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. # add --with controller option to build controller (builds zerotier-controller package)
  2. %bcond_with controller
  3. # add --with miniupnpc option to enable the miniupnpc option during build
  4. %bcond_with miniupnpc
  5. # add --with cluster option to enable the cluster option during build
  6. %bcond_with cluster
  7. # add --with debug option to enable the debug option during build
  8. %bcond_with debug
  9. %if %{with controller}
  10. Name:zerotier-controller
  11. Conflicts:zerotier
  12. %else
  13. Name:zerotier
  14. Conflicts:zerotier-controller
  15. %endif
  16. Version: 1.1.4
  17. Release: 1
  18. Summary: Network Virtualization Everywhere https://www.zerotier.com/
  19. Group: network
  20. License: GPLv3
  21. BuildRoot: %{_tmppath}/%{name}-root
  22. Provides: zerotier-one
  23. Source0: http:///download/%{name}-%{version}.tar.gz
  24. BuildRequires: gcc-c++
  25. BuildRequires: make
  26. BuildRequires: gcc
  27. %if %{with server}
  28. BuildRequires: sqlite-devel
  29. BuildRequires: wget
  30. BuildRequires: unzip
  31. Requires: sqlite
  32. %endif
  33. %description
  34. ZeroTier One creates virtual Ethernet networks that work anywhere and everywhere.
  35. Visit https://www.zerotier.com/ for more information.
  36. %prep
  37. cd `mktemp -d`
  38. wget -O master.zip https://github.com/zerotier/ZeroTierOne/archive/master.zip
  39. unzip master.zip
  40. mv ZeroTierOne-master zerotier-1.1.4
  41. ln -s zerotier-1.1.4 zerotier-controller-1.1.4
  42. tar zcvf zerotier-1.1.4.tar.gz zerotier-1.1.4 zerotier-controller-1.1.4
  43. ln -s zerotier-1.1.4.tar.gz zerotier-controller-1.1.4.tar.gz
  44. mv zero*.tar.gz ~/rpmbuild/SOURCES
  45. cd -
  46. %setup -q
  47. %build
  48. %if %{with miniupnpc}
  49. ZT_USE_MINIUPNPC=1; export ZT_USE_MINIUPNPC;
  50. %endif
  51. %if %{with controller}
  52. ZT_ENABLE_NETWORK_CONTROLLER=1; export ZT_ENABLE_NETWORK_CONTROLLER;
  53. %endif
  54. %if %{with cluster}
  55. export ZT_ENABLE_CLUSTER=1
  56. %endif
  57. %if %{with debug}
  58. export ZT_DEBUG=1
  59. %endif
  60. make
  61. %install
  62. rm -rf $RPM_BUILD_ROOT
  63. rm -f $RPM_BUILD_ROOT%{_prefix}/bin/zerotier-idtool $RPM_BUILD_ROOT%{_prefix}/bin/zerotier-idtool
  64. echo 'Install...'
  65. mkdir -p $RPM_BUILD_ROOT%{_vardir}/lib/zerotier-one/initfiles/{init.d,systemd}
  66. install -m 0755 -D zerotier-one -t $RPM_BUILD_ROOT%{_vardir}/lib/zerotier-one/
  67. install -m 0755 -D ext/installfiles/linux/init.d/* -t $RPM_BUILD_ROOT%{_vardir}/lib/zerotier-one/initfiles/init.d/
  68. install -m 0755 -D ext/installfiles/linux/systemd/* -t $RPM_BUILD_ROOT%{_vardir}/lib/zerotier-one/initfiles/systemd/
  69. %posttrans
  70. echo -n 'Getting version of new install... '
  71. newVersion=`/var/lib/zerotier-one/zerotier-one -v`
  72. echo $newVersion
  73. echo 'Creating symlinks...'
  74. rm -f /usr/bin/zerotier-cli /usr/bin/zerotier-idtool
  75. ln -sf /var/lib/zerotier-one/zerotier-one /usr/bin/zerotier-cli
  76. ln -sf /var/lib/zerotier-one/zerotier-one /usr/bin/zerotier-idtool
  77. echo 'Installing zerotier-one service...'
  78. SYSTEMDUNITDIR=
  79. if [ -e /bin/systemctl -o -e /usr/bin/systemctl -o -e /usr/local/bin/systemctl -o -e /sbin/systemctl -o -e /usr/sbin/systemctl ]; then
  80. # Second check: test if systemd appears to actually be running. Apparently Ubuntu
  81. # thought it was a good idea to ship with systemd installed but not used. Issue #133
  82. if [ -d /var/run/systemd/system -o -d /run/systemd/system ]; then
  83. if [ -e /usr/bin/pkg-config ]; then
  84. SYSTEMDUNITDIR=`/usr/bin/pkg-config systemd --variable=systemdsystemunitdir`
  85. fi
  86. if [ -z "$SYSTEMDUNITDIR" -o ! -d "$SYSTEMDUNITDIR" ]; then
  87. if [ -d /usr/lib/systemd/system ]; then
  88. SYSTEMDUNITDIR=/usr/lib/systemd/system
  89. fi
  90. if [ -d /etc/systemd/system ]; then
  91. SYSTEMDUNITDIR=/etc/systemd/system
  92. fi
  93. fi
  94. fi
  95. fi
  96. if [ -n "$SYSTEMDUNITDIR" -a -d "$SYSTEMDUNITDIR" ]; then
  97. # SYSTEMD
  98. # If this was updated or upgraded from an init.d based system, clean up the old
  99. # init.d stuff before installing directly via systemd.
  100. if [ -f /etc/init.d/zerotier-one ]; then
  101. if [ -e /sbin/chkconfig -o -e /usr/sbin/chkconfig -o -e /bin/chkconfig -o -e /usr/bin/chkconfig ]; then
  102. chkconfig zerotier-one off
  103. fi
  104. rm -f /etc/init.d/zerotier-one
  105. fi
  106. cp -f /var/lib/zerotier-one/initfiles/systemd/zerotier-one.service "$SYSTEMDUNITDIR/zerotier-one.service"
  107. chown 0 "$SYSTEMDUNITDIR/zerotier-one.service"
  108. chgrp 0 "$SYSTEMDUNITDIR/zerotier-one.service"
  109. chmod 0755 "$SYSTEMDUNITDIR/zerotier-one.service"
  110. systemctl enable zerotier-one.service
  111. echo
  112. echo 'Done! Installed and service configured to start at system boot.'
  113. echo
  114. echo "To start now or restart the service if it's already running:"
  115. echo ' sudo systemctl restart zerotier-one.service'
  116. else
  117. # SYSV INIT -- also covers upstart which supports SysVinit backward compatibility
  118. cp -f /var/lib/zerotier-one/initfiles/init.d/zerotier-one /etc/init.d/zerotier-one
  119. chmod 0755 /etc/init.d/zerotier-one
  120. if [ -f /sbin/chkconfig -o -f /usr/sbin/chkconfig -o -f /usr/bin/chkconfig -o -f /bin/chkconfig ]; then
  121. chkconfig zerotier-one on
  122. else
  123. # Yes Virginia, some systems lack chkconfig.
  124. if [ -d /etc/rc0.d ]; then
  125. rm -f /etc/rc0.d/???zerotier-one
  126. ln -sf /etc/init.d/zerotier-one /etc/rc0.d/K89zerotier-one
  127. fi
  128. if [ -d /etc/rc1.d ]; then
  129. rm -f /etc/rc1.d/???zerotier-one
  130. ln -sf /etc/init.d/zerotier-one /etc/rc1.d/K89zerotier-one
  131. fi
  132. if [ -d /etc/rc2.d ]; then
  133. rm -f /etc/rc2.d/???zerotier-one
  134. ln -sf /etc/init.d/zerotier-one /etc/rc2.d/S11zerotier-one
  135. fi
  136. if [ -d /etc/rc3.d ]; then
  137. rm -f /etc/rc3.d/???zerotier-one
  138. ln -sf /etc/init.d/zerotier-one /etc/rc3.d/S11zerotier-one
  139. fi
  140. if [ -d /etc/rc4.d ]; then
  141. rm -f /etc/rc4.d/???zerotier-one
  142. ln -sf /etc/init.d/zerotier-one /etc/rc4.d/S11zerotier-one
  143. fi
  144. if [ -d /etc/rc5.d ]; then
  145. rm -f /etc/rc5.d/???zerotier-one
  146. ln -sf /etc/init.d/zerotier-one /etc/rc5.d/S11zerotier-one
  147. fi
  148. if [ -d /etc/rc6.d ]; then
  149. rm -f /etc/rc6.d/???zerotier-one
  150. ln -sf /etc/init.d/zerotier-one /etc/rc6.d/K89zerotier-one
  151. fi
  152. fi
  153. echo
  154. echo 'Done! Installed and service configured to start at system boot.'
  155. echo
  156. echo "To start now or restart the service if it's already running:"
  157. echo ' sudo service zerotier-one restart'
  158. fi
  159. %preun
  160. /sbin/chkconfig --del zerotier-one
  161. rm -f /usr/bin/zerotier-cli /usr/bin/zerotier-idtool
  162. %clean
  163. rm -rf $RPM_BUILD_ROOT
  164. %files
  165. %{_vardir}/lib/zerotier-one/zerotier-one
  166. %{_vardir}/lib/zerotier-one/initfiles/systemd/zerotier-one.service
  167. %{_vardir}/lib/zerotier-one/initfiles/init.d/zerotier-one
  168. %changelog
  169. * Fri Feb 26 2016 Kristof Imre Szabo <kristof.szabo@lxsystems.de> 1.1.4-1
  170. - initial package