Commit 5b9596780c3857ab3ecb24d72b9faff22d022bed
1 parent
d2114d14
Exists in
kalibro-configurations
Removing configurations for postgresql
SPB database will be on another machine, so we don't need to worry about creating local users and databases. Leave it to the chef script of SPB. To test if the service works locally, it is necessary to install postgresql service, create the user and the database and start postgresql via systemctl.
Showing
2 changed files
with
7 additions
and
28 deletions
Show diff stats
kalibro-configurations/kalibro-configurations.spec
... | ... | @@ -23,6 +23,7 @@ ln -sf /usr/lib/kalibro_configurations/.bundle . |
23 | 23 | ln -sfT /usr/lib/kalibro_configurations/vendor/bundle vendor/bundle |
24 | 24 | rm -f Gemfile Gemfile.lock .bundle vendor/bundle |
25 | 25 | rm -rf tmp log |
26 | + | |
26 | 27 | %install |
27 | 28 | mkdir -p %{buildroot}/usr/lib/kalibro-configurations |
28 | 29 | cp -r * %{buildroot}/usr/lib/kalibro-configurations |
... | ... | @@ -30,6 +31,7 @@ rm -rf %{buildroot}/usr/lib/kalibro-configurations/log |
30 | 31 | ln -sfT /var/log/kalibro-configurations %{buildroot}/usr/lib/kalibro-configurations/log |
31 | 32 | ln -sfT /etc/kalibro-configurations/database.yml %{buildroot}/usr/lib/kalibro-configurations/config/database.yml |
32 | 33 | ln -sfT /etc/kalibro-configurations/secrets.yml %{buildroot}/usr/lib/kalibro-configurations/config/secrets.yml |
34 | + | |
33 | 35 | mkdir -p %{buildroot}/lib/systemd/system |
34 | 36 | cat > %{buildroot}/lib/systemd/system/kalibro_configurations.service <<EOF |
35 | 37 | [Unit] |
... | ... | @@ -42,11 +44,13 @@ EnvironmentFile=-/etc/sysconfig/kalibro_configurations |
42 | 44 | User=kalibro_configurations |
43 | 45 | WorkingDirectory=/usr/lib/kalibro-configurations |
44 | 46 | ExecStart=/usr/bin/env bundle exec rails s -p 8083 -e production |
47 | + | |
45 | 48 | [Install] |
46 | 49 | WantedBy=multi-user.target |
47 | 50 | EOF |
51 | + | |
48 | 52 | mkdir -p %{buildroot}/etc/kalibro-configurations |
49 | -cat > %{buildroot}/etc/kalibro-configurations/database.yml << EOF | |
53 | +cat > %{buildroot}/etc/kalibro-configurations/database.yml <<EOF | |
50 | 54 | production: |
51 | 55 | adapter: postgresql |
52 | 56 | encoding: unicode |
... | ... | @@ -56,12 +60,11 @@ production: |
56 | 60 | password: |
57 | 61 | EOF |
58 | 62 | |
59 | -cat > %{buildroot}/etc/kalibro-configurations/secrets.yml << EOF | |
60 | -# Do not keep production secrets in the repository, | |
61 | -# instead read values from the environment. | |
63 | +cat > %{buildroot}/etc/kalibro-configurations/secrets.yml <<EOF | |
62 | 64 | production: |
63 | 65 | secret_key_base: $(bundle exec rake secret) |
64 | 66 | EOF |
67 | + | |
65 | 68 | #FIXME HACK, REMOVE LATER |
66 | 69 | sed -i -e "s/require.*database_cleaner/# &/" %{buildroot}/usr/lib/kalibro-configurations/app/controllers/tests_controller.rb |
67 | 70 | |
... | ... | @@ -73,27 +76,6 @@ fi |
73 | 76 | mkdir -p /var/log/kalibro-configurations |
74 | 77 | chown -R kalibro_configurations:kalibro_configurations /var/log/kalibro-configurations |
75 | 78 | chown -R kalibro_configurations:kalibro_configurations /usr/lib/kalibro-configurations |
76 | -if [ -x /usr/bin/psql ]; then | |
77 | - if [ `systemctl is-active postgresql`!="active" ]; then | |
78 | - postgresql-setup initdb || true | |
79 | - systemctl start postgresql | |
80 | - fi | |
81 | - if [ "$(sudo -u postgres -i psql --quiet --tuples-only -c "select count(*) from pg_user where usename = 'kalibro_configurations';")" -eq 0 ]; then | |
82 | - # create user | |
83 | - sudo -u postgres -i createuser kalibro_configurations | |
84 | - fi | |
85 | - | |
86 | - if [ "$(sudo -u postgres -i psql --quiet --tuples-only -c "select count(1) from pg_database where datname = 'kalibro_configurations_production';")" -eq 0 ]; then | |
87 | - # create database | |
88 | - sudo -u postgres -i createdb --owner=kalibro_configurations kalibro_configurations_production | |
89 | - fi | |
90 | - | |
91 | - cd /usr/lib/kalibro-configurations/ | |
92 | - su kalibro_configurations -c "RAILS_ENV=production bundle exec rake db:migrate" | |
93 | - if [ $1 -eq 1 ]; then | |
94 | - su kalibro_configurations -c "RAILS_ENV=production bundle exec rake db:seed" | |
95 | - fi | |
96 | -fi | |
97 | 79 | |
98 | 80 | if [ $1 -gt 1 ]; then |
99 | 81 | echo 'Restarting kalibro_configurations' | ... | ... |
remove_package.sh
... | ... | @@ -3,6 +3,3 @@ |
3 | 3 | sudo yum remove kalibro-configurations |
4 | 4 | sudo rm -rf /etc/kalibro-configurations |
5 | 5 | sudo rm -rf /var/log/kalibro-configurations |
6 | - | |
7 | -sudo -u postgres -i dropdb kalibro_configurations_production | |
8 | -sudo -u postgres -i dropuser kalibro_configurations_production | ... | ... |