summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-support/postgresql/files/postgresql.init
diff options
context:
space:
mode:
authorChong.Lu@windriver.com <Chong.Lu@windriver.com>2014-09-16 17:36:35 +0800
committerMartin Jansa <Martin.Jansa@gmail.com>2014-09-26 05:41:53 +0200
commitdfa0b4c86d69c14a4fc8f3bda225526ead3bcd51 (patch)
treee9ad91fc155bbe79ea57c76f152944e97c59295b /meta-oe/recipes-support/postgresql/files/postgresql.init
parentcf2ab9ecbfcdac90c331509e9b5e25e51aa73248 (diff)
downloadmeta-openembedded-dfa0b4c86d69c14a4fc8f3bda225526ead3bcd51.tar.gz
postgresql: move initdb to postgresql-setup
We shouldn't use sysvinit init script to initialize database when use systemd as the init manager, so split initdb function to postgresql-setup. Before starting postgresql server, we can use "postgresql-setup initdb" to initialize the database cluster. Signed-off-by: Chong Lu <Chong.Lu@windriver.com> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Diffstat (limited to 'meta-oe/recipes-support/postgresql/files/postgresql.init')
-rw-r--r--meta-oe/recipes-support/postgresql/files/postgresql.init52
1 files changed, 2 insertions, 50 deletions
diff --git a/meta-oe/recipes-support/postgresql/files/postgresql.init b/meta-oe/recipes-support/postgresql/files/postgresql.init
index ab46477606..4a4f0cd168 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
163initdb(){
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.
210case "$1" in 165case "$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
239esac 191esac
240 192