]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
Added support for PostgreSQL DB on FreeBSD systems
authormanu <manu@pc.local>
Sat, 10 Aug 2019 19:47:38 +0000 (21:47 +0200)
committermanu <manu@pc.local>
Sat, 10 Aug 2019 19:47:38 +0000 (21:47 +0200)
hammer.py

index 9f2fa562a1a3a435328a123f7d928c83f22028ab..92ac5af78982367b76d25474a580ea13f09fae28 100755 (executable)
--- a/hammer.py
+++ b/hammer.py
@@ -877,6 +877,7 @@ def _configure_mysql(system, revision, features):
 
 
 def _configure_pgsql(system, features):
+    """ Configure PostgreSQL DB """
     if system in ['fedora', 'centos']:
         # https://fedoraproject.org/wiki/PostgreSQL
         exitcode = execute('sudo ls /var/lib/pgsql/data/postgresql.conf', raise_error=False)
@@ -885,8 +886,18 @@ def _configure_pgsql(system, features):
                 execute('sudo postgresql-setup initdb')
             else:
                 execute('sudo postgresql-setup --initdb --unit postgresql')
-    execute('sudo systemctl start postgresql.service')
-    execute('sudo systemctl enable postgresql.service')
+    elif system == 'freebsd':
+        # pgsql must be enabled before runnig initdb
+        execute('sudo sysrc postgresql_enable="yes"')
+        execute('sudo /usr/local/etc/rc.d/postgresql initdb')
+
+    if system == 'freebsd':
+        # echo or redirection to stdout is needed otherwise the script will hang at "line = p.stdout.readline()"
+        execute('sudo service postgresql start && echo "PostgreSQL started"')
+    else:
+        execute('sudo systemctl enable postgresql.service')
+        execute('sudo systemctl start postgresql.service')
+
     cmd = "bash -c \"cat <<EOF | sudo -u postgres psql postgres\n"
     cmd += "DROP DATABASE IF EXISTS keatest;\n"
     cmd += "DROP USER IF EXISTS keatest;\n"
@@ -1263,6 +1274,9 @@ def prepare_system_local(features, check_times):
         if 'mysql' in features:
             packages.extend(['mysql57-server', 'mysql57-client'])
 
+        if 'pgsql' in features:
+            packages.extend(['postgresql11-server', 'postgresql11-client'])
+
         if 'radius' in features:
             packages.extend(['git'])