Commit 29ac9b5a79c14fecf86517674df68ea7bd485046
1 parent
6e770809
Exists in
design_41_backup
Adding kalibro_configurations to actual structure
Showing
1 changed file
with
97 additions
and
0 deletions
Show diff stats
src/pkg-rpm/kalibro-configurations/kalibro-configurations.spec
0 → 100644
| ... | ... | @@ -0,0 +1,97 @@ |
| 1 | +Name: kalibro-configurations | |
| 2 | +Version: 1.0.0.backport | |
| 3 | +Release: 2%{?dist} | |
| 4 | +Summary: Mezuro metrics management backend | |
| 5 | +Group: Development/Tools | |
| 6 | +License: AGPLv3 | |
| 7 | +URL: https://github.com/mezuro/kalibro_configurations | |
| 8 | +Source0: %{name}-%{version}.tar.gz | |
| 9 | +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) | |
| 10 | +BuildArch: noarch | |
| 11 | +BuildRequires: kalibro-configurations-deps | |
| 12 | +Requires: kalibro-configurations-deps, rubygem-bundler | |
| 13 | + | |
| 14 | +%description | |
| 15 | + | |
| 16 | +%prep | |
| 17 | +%setup -q | |
| 18 | + | |
| 19 | +%build | |
| 20 | +ln -sf /usr/lib/kalibro_configurations/Gemfile . | |
| 21 | +ln -sf /usr/lib/kalibro_configurations/Gemfile.lock . | |
| 22 | +ln -sf /usr/lib/kalibro_configurations/.bundle . | |
| 23 | +ln -sfT /usr/lib/kalibro_configurations/vendor/bundle vendor/bundle | |
| 24 | +rm -f Gemfile Gemfile.lock .bundle vendor/bundle | |
| 25 | +rm -rf tmp log | |
| 26 | + | |
| 27 | +%install | |
| 28 | +mkdir -p %{buildroot}/usr/lib/kalibro-configurations | |
| 29 | +cp -r * %{buildroot}/usr/lib/kalibro-configurations | |
| 30 | +rm -rf %{buildroot}/usr/lib/kalibro-configurations/log | |
| 31 | +ln -sfT /var/log/kalibro-configurations %{buildroot}/usr/lib/kalibro-configurations/log | |
| 32 | +ln -sfT /etc/kalibro-configurations/database.yml %{buildroot}/usr/lib/kalibro-configurations/config/database.yml | |
| 33 | +ln -sfT /etc/kalibro-configurations/secrets.yml %{buildroot}/usr/lib/kalibro-configurations/config/secrets.yml | |
| 34 | + | |
| 35 | +mkdir -p %{buildroot}/lib/systemd/system | |
| 36 | +cat > %{buildroot}/lib/systemd/system/kalibro_configurations.service <<EOF | |
| 37 | +[Unit] | |
| 38 | +Description=kalibro_configurations | |
| 39 | +After=network.target | |
| 40 | + | |
| 41 | +[Service] | |
| 42 | +Type=simple | |
| 43 | +EnvironmentFile=-/etc/sysconfig/kalibro_configurations | |
| 44 | +User=kalibro_configurations | |
| 45 | +WorkingDirectory=/usr/lib/kalibro-configurations | |
| 46 | +ExecStart=/usr/bin/env bundle exec rails s -p 8083 -e production | |
| 47 | + | |
| 48 | +[Install] | |
| 49 | +WantedBy=multi-user.target | |
| 50 | +EOF | |
| 51 | + | |
| 52 | +mkdir -p %{buildroot}/etc/kalibro-configurations | |
| 53 | +cat > %{buildroot}/etc/kalibro-configurations/database.yml <<EOF | |
| 54 | +production: | |
| 55 | + adapter: postgresql | |
| 56 | + encoding: unicode | |
| 57 | + database: kalibro_configurations_production | |
| 58 | + pool: 10 | |
| 59 | + username: kalibro_configurations | |
| 60 | + password: | |
| 61 | +EOF | |
| 62 | + | |
| 63 | +cat > %{buildroot}/etc/kalibro-configurations/secrets.yml <<EOF | |
| 64 | +production: | |
| 65 | + secret_key_base: $(bundle exec rake secret) | |
| 66 | +EOF | |
| 67 | + | |
| 68 | +#FIXME HACK, REMOVE LATER | |
| 69 | +sed -i -e "s/require.*database_cleaner/# &/" %{buildroot}/usr/lib/kalibro-configurations/app/controllers/tests_controller.rb | |
| 70 | + | |
| 71 | +%post | |
| 72 | +groupadd kalibro_configurations || true | |
| 73 | +if ! id kalibro_configurations; then | |
| 74 | + adduser kalibro_configurations --system -g kalibro_configurations --shell /bin/sh --home-dir /usr/lib/kalibro-configurations | |
| 75 | +fi | |
| 76 | +mkdir -p /var/log/kalibro-configurations | |
| 77 | +chown -R kalibro_configurations:kalibro_configurations /var/log/kalibro-configurations | |
| 78 | +chown -R kalibro_configurations:kalibro_configurations /usr/lib/kalibro-configurations | |
| 79 | + | |
| 80 | +if [ $1 -gt 1 ]; then | |
| 81 | + echo 'Restarting kalibro_configurations' | |
| 82 | + systemctl daemon-reload | |
| 83 | + systemctl try-restart kalibro_configurations | |
| 84 | +fi | |
| 85 | + | |
| 86 | +%clean | |
| 87 | +rm -rf %{buildroot} | |
| 88 | + | |
| 89 | +%files | |
| 90 | +%defattr(-,root,root,-) | |
| 91 | +%doc | |
| 92 | +/usr/lib/kalibro-configurations | |
| 93 | +/lib/systemd/system/kalibro_configurations.service | |
| 94 | +%config(noreplace) /etc/kalibro-configurations/database.yml | |
| 95 | +%config(noreplace) /etc/kalibro-configurations/secrets.yml | |
| 96 | + | |
| 97 | +%changelog | ... | ... |