Skip to content

Commit fda4cce

Browse files
committed
Changes to centos support
1 parent 678ffc1 commit fda4cce

5 files changed

Lines changed: 36 additions & 18 deletions

File tree

Vagrantfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
1818
v.cpus = 1
1919
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
2020
end
21+
config.vm.define "centos", autostart: false
2122
targets.each do |name, target|
2223
box = target["box"]
2324
config.vm.define name do |build|

deploy/lib.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,13 @@ function configure_nginx() {
113113
local __enabled="$__nginx/sites-enabled"
114114

115115
if [[ "$DISTRO" == "centos" ]]; then
116-
$__available="$__nginx/conf.d"
117-
$__enabled="$__nginx/conf.d"
116+
__available="$__nginx/conf.d"
117+
__enabled="$__nginx/conf.d"
118118
fi
119119

120120
sudo mkdir -p "$__available"
121121
sudo mkdir -p "$__enabled"
122122

123-
if [[ "$DISTRO" == "ubuntu" ]]; then
124-
125123
cat "$__conf" | sed "s|PUBLIC_PORT|$__pport|g" | sed "s|CER_FILE|$__cert|g" | sed "s|KEY_FILE|$__key|g" | sed "s|DHPARAM_FILE|$__dh|g" | sed "s|PRIVATE_PORT|$__iport|g" | sudo tee "$__available/$__out"
126124

127125
if [[ -f "$__enabled/default" ]]; then
@@ -263,20 +261,21 @@ function install_postgresql10_xenial() {
263261

264262
package "postgresql-$__pgversion"
265263

266-
configure_postgres "$__pgversion" "$__pgconf"
264+
configure_postgres "$__pgconf" "postgresql"
267265
}
268266

269267
# Create empty DB and username
270268
# string PostgreSQL_db_name
271269
# string PostgreSQL_system_user
272270
# string PostgreSQL_db_user
273271
# string PostgreSQL_db_pass
272+
# string PostgerSQL_psql
274273
function db_user_postgresql() {
275-
local __psql="/usr/lib/postgresql/10/bin/psql"
276274
local __pgdb=$1
277275
local __pguser=$2
278276
local __dbuser=$3
279277
local __dbpass=$4
278+
local __psql=$5
280279

281280
log "Creating user"
282281
local _dbstatementuser="CREATE USER $__dbuser;"
@@ -327,15 +326,19 @@ function repo_postgres_xenial() {
327326

328327
# Configure PostgreSQL
329328
# string postgres_conf_file_location
329+
# string postgres_service_name
330+
# string postgres_hba_file
330331
function configure_postgres() {
331332
local __conf=$1
333+
local __service=$2
334+
local __hba=$3
332335

333336
log "PostgreSQL permissions"
334337

335-
sudo cp "$__conf" "/etc/postgresql/10/main/pg_hba.conf"
338+
sudo cp "$__conf" "$__hba"
336339

337-
sudo systemctl restart postgresql
338-
sudo systemctl enable postgresql
340+
sudo systemctl restart "$__service"
341+
sudo systemctl enable "$__service"
339342
}
340343

341344
# Customize the MOTD in Ubuntu

deploy/osctrl-admin.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Unit]
2-
Description=Fast and efficient operative system management
2+
Description=osctrl-admin
33
ConditionPathExists=/opt/osctrl
44
After=network.target
55

@@ -16,7 +16,7 @@ ExecStart=/opt/osctrl/osctrl-admin
1616
# make sure log directory exists and owned by syslog
1717
PermissionsStartOnly=true
1818
ExecStartPre=/bin/mkdir -p /var/log/osctrl-admin
19-
ExecStartPre=/bin/chown syslog:adm /var/log/osctrl-admin
19+
ExecStartPre=/bin/chown osctrl:osctrl /var/log/osctrl-admin
2020
ExecStartPre=/bin/chmod 755 /var/log/osctrl-admin
2121
StandardOutput=syslog
2222
StandardError=syslog

deploy/osctrl-tls.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Unit]
2-
Description=Fast and efficient operative system management
2+
Description=osctrl-tls
33
ConditionPathExists=/opt/osctrl
44
After=network.target
55

@@ -16,7 +16,7 @@ ExecStart=/opt/osctrl/osctrl-tls
1616
# make sure log directory exists and owned by syslog
1717
PermissionsStartOnly=true
1818
ExecStartPre=/bin/mkdir -p /var/log/osctrl-tls
19-
ExecStartPre=/bin/chown syslog:adm /var/log/osctrl-tls
19+
ExecStartPre=/bin/chown osctrl:osctrl /var/log/osctrl-tls
2020
ExecStartPre=/bin/chmod 755 /var/log/osctrl-tls
2121
StandardOutput=syslog
2222
StandardError=syslog

deploy/provision.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ package gcc
354354
package make
355355
package openssl
356356
package tmux
357+
package bc
357358

358359
# nginx as TLS termination
359360
if [[ "$NGINX" == true ]]; then
@@ -408,12 +409,25 @@ fi
408409
# PostgreSQL - Backend
409410
if [[ "$DOCKER" == false ]]; then
410411
if [[ "$POSTGRES" == true ]]; then
411-
package postgresql
412-
package postgresql-contrib
413-
414412
POSTGRES_CONF="$SOURCE_PATH/deploy/postgres/pg_hba.conf"
415-
configure_postgres "$POSTGRES_CONF"
416-
db_user_postgresql "$_DB_NAME" "$_DB_SYSTEM_USER" "$_DB_USER" "$_DB_PASS"
413+
if [[ "$DISTRO" == "ubuntu" ]]; then
414+
package postgresql
415+
package postgresql-contrib
416+
configure_postgres "$POSTGRES_CONF" "postgresql"
417+
POSTGRES_SERVICE="postgresql"
418+
POSTGRES_HBA="/etc/postgresql/10/main/pg_hba.conf"
419+
POSTGRES_PSQL="/usr/lib/postgresql/10/bin/psql"
420+
elif [[ "$DISTRO" == "centos" ]]; then
421+
sudo rpm -Uvh "http://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm"
422+
package postgresql96-server
423+
package postgresql96-contrib
424+
sudo /usr/pgsql-9.6/bin/postgresql96-setup initdb
425+
POSTGRES_SERVICE="postgresql-9.6"
426+
POSTGRES_HBA="/var/lib/pgsql/9.6/data/pg_hba.conf"
427+
POSTGRES_PSQL="/usr/pgsql-9.6/bin/psql"
428+
fi
429+
configure_postgres "$POSTGRES_CONF" "$POSTGRES_SERVICE" "$POSTGRES_HBA"
430+
db_user_postgresql "$_DB_NAME" "$_DB_SYSTEM_USER" "$_DB_USER" "$_DB_PASS" "$POSTGRES_PSQL"
417431
fi
418432
fi
419433

0 commit comments

Comments
 (0)