diff options
author | Tudor Florea <tudor.florea@enea.com> | 2015-10-08 22:51:41 +0200 |
---|---|---|
committer | Tudor Florea <tudor.florea@enea.com> | 2015-10-08 22:51:41 +0200 |
commit | 1219bf8a90a7bf8cd3a5363551ef635d51e8fc8e (patch) | |
tree | a21a5fc103bb3bd65ecd85ed22be5228fc54e447 /meta-oe/recipes-support/postgresql/files/postgresql-setup | |
download | meta-openembedded-1219bf8a90a7bf8cd3a5363551ef635d51e8fc8e.tar.gz |
initial commit for Enea Linux 5.0 arm
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'meta-oe/recipes-support/postgresql/files/postgresql-setup')
-rw-r--r-- | meta-oe/recipes-support/postgresql/files/postgresql-setup | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/meta-oe/recipes-support/postgresql/files/postgresql-setup b/meta-oe/recipes-support/postgresql/files/postgresql-setup new file mode 100644 index 000000000..75bb01e05 --- /dev/null +++ b/meta-oe/recipes-support/postgresql/files/postgresql-setup | |||
@@ -0,0 +1,73 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # postgresql-setup Initialization operation for PostgreSQL | ||
4 | |||
5 | # For SELinux we need to use 'runuser' not 'su' | ||
6 | if [ -x /sbin/runuser ] | ||
7 | then | ||
8 | SU=runuser | ||
9 | else | ||
10 | SU=su | ||
11 | fi | ||
12 | |||
13 | PGENGINE=/usr/bin | ||
14 | PGDATA=/var/lib/postgresql/data | ||
15 | PGLOG=/var/lib/postgresql/pgstartup.log | ||
16 | script_result=0 | ||
17 | |||
18 | initdb(){ | ||
19 | if [ -f "$PGDATA/PG_VERSION" ] | ||
20 | then | ||
21 | echo -n "Data directory is not empty!" | ||
22 | echo -n " [FAILED] " | ||
23 | echo | ||
24 | script_result=1 | ||
25 | else | ||
26 | echo -n "Initializing database: " | ||
27 | if [ ! -e "$PGDATA" -a ! -h "$PGDATA" ] | ||
28 | then | ||
29 | mkdir -p "$PGDATA" || exit 1 | ||
30 | chown postgres:postgres "$PGDATA" | ||
31 | chmod go-rwx "$PGDATA" | ||
32 | fi | ||
33 | # Clean up SELinux tagging for PGDATA | ||
34 | [ -x /sbin/restorecon ] && /sbin/restorecon "$PGDATA" | ||
35 | |||
36 | # Make sure the startup-time log file is OK, too | ||
37 | if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ] | ||
38 | then | ||
39 | touch "$PGLOG" || exit 1 | ||
40 | chown postgres:postgres "$PGLOG" | ||
41 | chmod go-rwx "$PGLOG" | ||
42 | [ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG" | ||
43 | fi | ||
44 | |||
45 | # Initialize the database | ||
46 | $SU -l postgres -c "$PGENGINE/initdb --pgdata='$PGDATA' --auth='ident'" >> "$PGLOG" 2>&1 < /dev/null | ||
47 | |||
48 | # Create directory for postmaster log | ||
49 | mkdir "$PGDATA/pg_log" | ||
50 | chown postgres:postgres "$PGDATA/pg_log" | ||
51 | chmod go-rwx "$PGDATA/pg_log" | ||
52 | |||
53 | if [ -f "$PGDATA/PG_VERSION" ] | ||
54 | then | ||
55 | echo -n " [ OK ] " | ||
56 | else | ||
57 | echo -n " [FAILED] " | ||
58 | script_result=1 | ||
59 | fi | ||
60 | echo | ||
61 | fi | ||
62 | } | ||
63 | |||
64 | case "$1" in | ||
65 | initdb) | ||
66 | initdb | ||
67 | ;; | ||
68 | *) | ||
69 | echo "Usage: $0 initdb" | ||
70 | exit 2 | ||
71 | esac | ||
72 | |||
73 | exit $script_result | ||