diff options
-rw-r--r-- | meta-oe/recipes-support/postgresql/files/postgresql-setup | 73 | ||||
-rw-r--r-- | meta-oe/recipes-support/postgresql/files/postgresql.init | 52 | ||||
-rw-r--r-- | meta-oe/recipes-support/postgresql/postgresql.inc | 2 |
3 files changed, 77 insertions, 50 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 | ||
diff --git a/meta-oe/recipes-support/postgresql/files/postgresql.init b/meta-oe/recipes-support/postgresql/files/postgresql.init index ab4647760..4a4f0cd16 100644 --- a/meta-oe/recipes-support/postgresql/files/postgresql.init +++ b/meta-oe/recipes-support/postgresql/files/postgresql.init | |||
@@ -101,7 +101,7 @@ start(){ | |||
101 | else | 101 | else |
102 | # No existing PGDATA! Warn the user to initdb it. | 102 | # No existing PGDATA! Warn the user to initdb it. |
103 | echo | 103 | echo |
104 | echo "$PGDATA is missing. Use \"service postgresql initdb\" to initialize the cluster first." | 104 | echo "$PGDATA is missing. Use \"postgresql-setup initdb\" to initialize the cluster first." |
105 | echo -n " [FAILED] " | 105 | echo -n " [FAILED] " |
106 | echo | 106 | echo |
107 | exit 1 | 107 | exit 1 |
@@ -160,51 +160,6 @@ reload(){ | |||
160 | $SU -l postgres -c "$PGENGINE/pg_ctl reload -D '$PGDATA' -s" > /dev/null 2>&1 < /dev/null | 160 | $SU -l postgres -c "$PGENGINE/pg_ctl reload -D '$PGDATA' -s" > /dev/null 2>&1 < /dev/null |
161 | } | 161 | } |
162 | 162 | ||
163 | initdb(){ | ||
164 | if [ -f "$PGDATA/PG_VERSION" ] | ||
165 | then | ||
166 | echo -n "Data directory is not empty!" | ||
167 | echo -n " [FAILED] " | ||
168 | echo | ||
169 | script_result=1 | ||
170 | else | ||
171 | echo -n $"Initializing database: " | ||
172 | if [ ! -e "$PGDATA" -a ! -h "$PGDATA" ] | ||
173 | then | ||
174 | mkdir -p "$PGDATA" || exit 1 | ||
175 | chown postgres:postgres "$PGDATA" | ||
176 | chmod go-rwx "$PGDATA" | ||
177 | fi | ||
178 | # Clean up SELinux tagging for PGDATA | ||
179 | [ -x /sbin/restorecon ] && /sbin/restorecon "$PGDATA" | ||
180 | |||
181 | # Make sure the startup-time log file is OK, too | ||
182 | if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ] | ||
183 | then | ||
184 | touch "$PGLOG" || exit 1 | ||
185 | chown postgres:postgres "$PGLOG" | ||
186 | chmod go-rwx "$PGLOG" | ||
187 | [ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG" | ||
188 | fi | ||
189 | |||
190 | # Initialize the database | ||
191 | $SU -l postgres -c "$PGENGINE/initdb --pgdata='$PGDATA' --auth='ident'" >> "$PGLOG" 2>&1 < /dev/null | ||
192 | |||
193 | # Create directory for postmaster log | ||
194 | mkdir "$PGDATA/pg_log" | ||
195 | chown postgres:postgres "$PGDATA/pg_log" | ||
196 | chmod go-rwx "$PGDATA/pg_log" | ||
197 | |||
198 | if [ -f "$PGDATA/PG_VERSION" ] | ||
199 | then | ||
200 | echo -n " [ OK ] " | ||
201 | else | ||
202 | echo -n " [FAILED] " | ||
203 | script_result=1 | ||
204 | fi | ||
205 | echo | ||
206 | fi | ||
207 | } | ||
208 | 163 | ||
209 | # See how we were called. | 164 | # See how we were called. |
210 | case "$1" in | 165 | case "$1" in |
@@ -230,11 +185,8 @@ case "$1" in | |||
230 | force-reload) | 185 | force-reload) |
231 | restart | 186 | restart |
232 | ;; | 187 | ;; |
233 | initdb) | ||
234 | initdb | ||
235 | ;; | ||
236 | *) | 188 | *) |
237 | echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|initdb}" | 189 | echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" |
238 | exit 2 | 190 | exit 2 |
239 | esac | 191 | esac |
240 | 192 | ||
diff --git a/meta-oe/recipes-support/postgresql/postgresql.inc b/meta-oe/recipes-support/postgresql/postgresql.inc index a9b4a012c..774c8fd0c 100644 --- a/meta-oe/recipes-support/postgresql/postgresql.inc +++ b/meta-oe/recipes-support/postgresql/postgresql.inc | |||
@@ -29,6 +29,7 @@ SRC_URI = "http://ftp.postgresql.org/pub/source/v${PV}/${BP}.tar.bz2 \ | |||
29 | file://postgresql-bashprofile \ | 29 | file://postgresql-bashprofile \ |
30 | file://postgresql.pam \ | 30 | file://postgresql.pam \ |
31 | file://0001-Use-pkg-config-for-libxml2-detection.patch \ | 31 | file://0001-Use-pkg-config-for-libxml2-detection.patch \ |
32 | file://postgresql-setup \ | ||
32 | " | 33 | " |
33 | 34 | ||
34 | LEAD_SONAME = "libpq.so" | 35 | LEAD_SONAME = "libpq.so" |
@@ -171,6 +172,7 @@ do_install_append() { | |||
171 | install -d ${D}${sysconfdir}/init.d | 172 | install -d ${D}${sysconfdir}/init.d |
172 | install -m 0755 ${WORKDIR}/${BPN}.init ${D}${sysconfdir}/init.d/${BPN}-server | 173 | install -m 0755 ${WORKDIR}/${BPN}.init ${D}${sysconfdir}/init.d/${BPN}-server |
173 | sed -i -e "s/^PGVERSION=.*$/PGVERSION=${PV}/g" ${D}${sysconfdir}/init.d/${BPN}-server | 174 | sed -i -e "s/^PGVERSION=.*$/PGVERSION=${PV}/g" ${D}${sysconfdir}/init.d/${BPN}-server |
175 | install -m 0755 ${WORKDIR}/${BPN}-setup ${D}${bindir}/${BPN}-setup | ||
174 | install -d -m 700 ${D}${localstatedir}/lib/${BPN}/data | 176 | install -d -m 700 ${D}${localstatedir}/lib/${BPN}/data |
175 | install -d -m 700 ${D}${localstatedir}/lib/${BPN}/backups | 177 | install -d -m 700 ${D}${localstatedir}/lib/${BPN}/backups |
176 | install -m 644 ${WORKDIR}/${BPN}-bashprofile ${D}${localstatedir}/lib/${BPN}/.bash_profile | 178 | install -m 644 ${WORKDIR}/${BPN}-bashprofile ${D}${localstatedir}/lib/${BPN}/.bash_profile |