/client/autognosis.spec.rb

https://bitbucket.org/winebarrel/autognosis · Ruby · 66 lines · 49 code · 14 blank · 3 comment · 1 complexity · 3417cf3c720d8ae8e1e0648088c7b996 MD5 · raw file

  1. #!/usr/bin/env ruby
  2. require 'erb'
  3. mercurial_hash = 'f38ca0bd5b22'
  4. spec_path = File.join(File.expand_path(File.dirname(__FILE__)), 'autognosis.spec')
  5. conf_path = File.join(File.expand_path(File.dirname(__FILE__)), 'etc/sysconfig/autognosis')
  6. open(spec_path, 'wb') do |spec|
  7. spec.puts(ERB.new(DATA.read).result(binding))
  8. end
  9. __END__
  10. Name: autognosis
  11. Version: 0.3.0
  12. Release: 3
  13. Summary: autognosis is a tool which processes when a spot instance is terminated compulsorily.
  14. Group: Development/Tools
  15. License: BSD
  16. URL: https://bitbucket.org/winebarrel/autognosis
  17. # wget https://bitbucket.org/winebarrel/autognosis/get/<%= mercurial_hash %>.tar.gz -O $RPM_SOURCE_DIR/
  18. Source0: <%= mercurial_hash %>.tar.gz
  19. BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
  20. BuildArch: noarch
  21. #Requires: cronexec, jq, curl, bc, libmemcached, describe-spot-price-history
  22. Requires: cronexec, jq, curl, bc, libmemcached
  23. %description
  24. autognosis is a tool which processes when a spot instance is terminated compulsorily.
  25. %prep
  26. %setup -q -n winebarrel-autognosis-<%= mercurial_hash %>
  27. %install
  28. rm -rf %{buildroot}
  29. install -d -m 0755 %{buildroot}%{_sbindir}
  30. install -d -m 0755 %{buildroot}/etc/init
  31. install -m 0755 client/usr/sbin/autognosis %{buildroot}%{_sbindir}
  32. install -m 0755 client/etc/init/autognosis.conf %{buildroot}/etc/init
  33. %clean
  34. rm -rf %{buildroot}
  35. %post
  36. if [ ! -e /etc/sysconfig/autognosis ]; then
  37. touch /etc/sysconfig/autognosis
  38. chmod 0600 /etc/sysconfig/autognosis
  39. cat > /etc/sysconfig/autognosis <<'EOF'
  40. <%= open(conf_path) {|f| f.read }.strip %>
  41. EOF
  42. fi
  43. initctl reload-configuration
  44. echo "Please execute 'sudo initctl start autognosis'"
  45. %postun
  46. initctl stop autognosis 2> /dev/null
  47. rm -f /var/tmp/autognosis.executed
  48. initctl reload-configuration
  49. %files
  50. %defattr(-,root,root,-)
  51. %{_sbindir}/autognosis
  52. /etc/init/autognosis.conf