Merge pull request #299 from monotek/develop

.pkgr.yml changes - creates postgresql db / debian 8...
This commit is contained in:
André Bauer 2016-10-25 18:34:06 +02:00 committed by GitHub
commit 63b1568120
4 changed files with 67 additions and 134 deletions

View file

@ -1,3 +1,4 @@
notifications: false
targets: targets:
centos-6: centos-6:
dependencies: dependencies:
@ -11,9 +12,11 @@ targets:
- postgresql - postgresql
- postgresql-server - postgresql-server
- postgresql-devel - postgresql-devel
debian-8:
dependencies:
- postgresql
ubuntu-16.04: ubuntu-16.04:
dependencies: dependencies:
- httpd
- postgresql - postgresql
before: before:
- uname -a - uname -a
@ -22,14 +25,11 @@ before:
- cp config/database.yml.pkgr config/database.yml - cp config/database.yml.pkgr config/database.yml
- echo "gem 'mysql2'" >> Gemfile.local - echo "gem 'mysql2'" >> Gemfile.local
- "cat Gemfile.lock" - "cat Gemfile.lock"
- contrib/cleanup.sh - contrib/packager.io/cleanup.sh
env: env:
- RAILS_ENV=production - RAILS_ENV=production
- PORT=3000 - PORT=3000
- RAILS_SERVE_STATIC_FILES=true - RAILS_SERVE_STATIC_FILES=true
services: services:
- postgres - postgres
after_install: contrib/packager.io/postinstall.sh
notifications: false

View file

@ -1,128 +0,0 @@
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
error_log /var/log/nginx/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 256;
}
http {
include mime.types;
default_type application/octet-stream;
include sites-enabled/*.conf;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
client_max_body_size 50M;
#keepalive_timeout 0;
keepalive_timeout 65;
proxy_cache_path /tmp/nginx/cache/ levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /tmp/nginx/proxy/;
gzip on;
gzip_comp_level 6;
gzip_vary on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/html text/css text/xml application/json application/x-javascript application/xml application/xml+rss text/javascript;
gzip_buffers 16 8k;
server {
listen 8080;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}

View file

@ -0,0 +1,61 @@
#!/bin/bash
#
# packager.io postinstall script
#
PATH=/opt/zammad/bin:/opt/zammad/vendor/bundle/bin:/sbin:/bin:/usr/sbin:/usr/bin:
ZAMMAD_DIR="/opt/zammad"
DB="zammad_production"
DB_USER="zammad"
# get existing db pass
DB_PASS="$(grep "password:" < ${ZAMMAD_DIR}/config/database.yml | sed 's/.*password://')"
# check if db pass exists
if [ -z "${DB_PASS}" ]; then
# create new db pass
DB_PASS="$(tr -dc A-Za-z0-9 < /dev/urandom | head -c10)"
# create database
cd /tmp
su - postgres -c "createdb -E UTF8 ${DB}"
# create postgres user
echo "CREATE USER \"${DB_USER}\" WITH PASSWORD '${DB_PASS}';" | su - postgres -c psql
# grant privileges
echo "GRANT ALL PRIVILEGES ON DATABASE \"${DB}\" TO \"${DB_USER}\";" | su - postgres -c psql
# update configfile
sed -e "s/ password:/ password: ${DB_PASS}/" < ${ZAMMAD_DIR}/config/database.yml.pkgr > ${ZAMMAD_DIR}/config/database.yml
# zammad config set
zammad config:set DATABASE_URL=postgres://${DB_USER}:${DB_PASS}@127.0.0.1/${DB}
# fill database
zammad run rake db:migrate
zammad run rake db:seed
fi
# create init scripts
zammad scale web=1 websocket=1 worker=1
# stop zammad
systemctl stop zammad
# db migration
zammad run rake db:migrate
# start zammad
systemctl start zammad
# nginx config
if [ -d /etc/nginx/sites-enabled ]; then
# copy nginx config
cp ${ZAMMAD_DIR}/contrib/nginx/sites-available/zammad.conf /etc/nginx/sites-available/zammad.conf
# creating symlink
test -h /etc/nginx/sites-available/zammad.conf || ln -s /etc/nginx/sites-available/zammad.conf /etc/nginx/sites-enabled/zammad.conf
# restart nginx
systemctl restart nginx
fi