Permalink
Browse files

[services-ng] add postgresql initialized data dir to blobstore

Change-Id: I595eb79d312ac1743bfea838434a701696a5e57c
  • Loading branch information...
1 parent 7d06101 commit 96217b61408f6a46c08e365265a02b34b2c631e2 Frank Lu committed Nov 25, 2012
View
8 config/blobs.yml
@@ -671,3 +671,11 @@ mongodb/mongodb-linux-i686-2.2.1.tgz:
object_id: eyJvaWQiOiI0ZTRlNzhiY2EyMWUxMjIwMDRlNGU4ZWM2NDdhNTQwNTBhMDkz%0AN2FlNmI3ZiIsInNpZyI6Ik1jWlp4M2syekd3Wjlpd2prNUs2VzFndVZ0ND0i%0AfQ==%0A
sha: f06a37c29504f6f92d8a59acf49d86512bc5a2ae
size: 54552128
+postgresql/postgresql-initdb-9.0-x86_64.tar.gz:
+ object_id: eyJvaWQiOiI0ZTRlNzhiY2E0MWUxMjIyMDRlNGU5ODYzZDA3NjMwNTBiMzNl%0AMDUwYzIzMyIsInNpZyI6InVkUTM2QkVZbWNtaGpUT3luQ1VjaWpEOC9taz0i%0AfQ==%0A
+ sha: 181900c6346f718ccd7cfbb8813e7c00f760bc55
+ size: 3467921
+postgresql/postgresql-initdb-9.1-x86_64.tar.gz:
+ object_id: eyJvaWQiOiI0ZTRlNzhiY2ExMWUxMjEwMDRlNGU3ZDUxMWY4MjEwNTBiMzNl%0AMDgwNWZmOCIsInNpZyI6IjhsL2ZWQXhRWFZrSTF5TmpBY3M2ME13VnlHTT0i%0AfQ==%0A
+ sha: c51a45f5a6011a6bb22407c164ea9b77f77cddad
+ size: 3911161
View
24 jobs/postgresql_node_ng/templates/warden_ctl
@@ -32,34 +32,30 @@ case $1 in
case "$version" in
"9.0")
PG_DIR=/var/vcap/packages/postgresql
- TMPDB_DIR=/var/vcap/data/initdb_tmp
;;
"9.1")
PG_DIR=/var/vcap/packages/postgresql91
- TMPDB_DIR=/var/vcap/data/initdb91_tmp
;;
esac
+ INITDB_DIR=$ROOT_DIR/$PG_DIR/initdb
+
echo "Initialize the postgresql $version database cluster"
install -m 0755 -d $ROOT_DIR/$PG_DIR
+
+ echo "Sync binaries and initialized data"
+ rm -rf $INITDB_DIR
rsync -arl $PG_DIR/* $ROOT_DIR/$PG_DIR/
- rm -rf $ROOT_DIR/$PG_DIR/initdb
- mkdir -p $TMPDB_DIR
- chmod -R 1777 $TMPDB_DIR
- if test ! -d $TMPDB_DIR/initdb/base
- then
- rm -rf $TMPDB_DIR/initdb
- su - vcap -c "LD_LIBRARY_PATH=$ROOT_DIR/$PG_DIR/lib:$LD_LIBRARY_PATH $ROOT_DIR/$PG_DIR/bin/initdb -E utf8 -D $TMPDB_DIR/initdb"
- fi
- if test ! -d $TMPDB_DIR/initdb/base
+ if test ! -d $INITDB_DIR/base
then
echo "Fail to initialize the postgresql $version database cluster, check the error log."
exit 1
fi
- rsync -arl $TMPDB_DIR/initdb $ROOT_DIR/$PG_DIR
- mkdir -p $ROOT_DIR/$PG_DIR/initdb/pg_log
- chmod -R 777 $ROOT_DIR/$PG_DIR/initdb
+
+ mkdir -p $INITDB_DIR/pg_log
+ # initdb direcotry cloud not be modified by non-root users.
+ chmod -R 755 $INITDB_DIR
done
install -m 0755 -t $ROOT_DIR/usr/sbin $JOB_DIR/bin/pre_service_start.sh
rsync -arl $JOB_DIR/bin/warden_service_ctl $ROOT_DIR/usr/bin/warden_service_ctl
View
7 jobs/postgresql_node_ng/templates/warden_service_ctl
@@ -28,6 +28,7 @@ case "$version" in
;;
esac
+INITDB_DIR=$PACKAGE_DIR/initdb
FIRST_TIME=0
case $1 in
@@ -39,10 +40,8 @@ case $1 in
mkdir -p $DATA_DIR
chown vcap:vcap $DATA_DIR
- # not to initdb
- #LD_LIBRARY_PATH=$PACKAGE_DIR/lib:$LD_LIBRARY_PATH $PACKAGE_DIR/bin/initdb -E utf8 -D $DATA_DIR >> $LOG_DIR/postgresql_ctl.log
# copy initdb
- rsync -arl $PACKAGE_DIR/initdb/* $DATA_DIR
+ rsync -arl $INITDB_DIR/* $DATA_DIR
if [ $? != 0 ]; then
echo "ERROR: Unable to initialize PostgreSQL DB" >> $LOG_DIR/postgresql_ctl.log
@@ -52,7 +51,7 @@ case $1 in
sed -i "s/#listen_addresses\( *\)=\( *\)'localhost'/listen_addresses\1=\2'*'/" $DATA_DIR/postgresql.conf
fi
- rsync -arl $PACKAGE_DIR/initdb/pg_hba.conf $DATA_DIR/pg_hba.conf
+ rsync -arl $INITDB_DIR/pg_hba.conf $DATA_DIR/pg_hba.conf
chown -R vcap:vcap $DATA_DIR
chmod -R 700 $DATA_DIR
View
4 packages/postgresql/packaging
@@ -7,4 +7,8 @@ tar xzf postgresql/postgresql-9.0-x86_64.tar.gz
cp -a * ${BOSH_INSTALL_TARGET}
+tar xzf postgresql/postgresql-initdb-9.0-x86_64.tar.gz
+
+cp -a initdb ${BOSH_INSTALL_TARGET}
+
rm ${BOSH_INSTALL_TARGET}/packaging
View
1 packages/postgresql/spec
@@ -2,3 +2,4 @@
name: postgresql
files:
- postgresql/postgresql-9.0-x86_64.tar.gz
+- postgresql/postgresql-initdb-9.0-x86_64.tar.gz
View
4 packages/postgresql91/packaging
@@ -7,4 +7,8 @@ tar xzf postgresql/postgresql-9.1-x86_64.tar.gz
cp -a * ${BOSH_INSTALL_TARGET}
+tar xzf postgresql/postgresql-initdb-9.1-x86_64.tar.gz
+
+cp -a initdb ${BOSH_INSTALL_TARGET}
+
rm ${BOSH_INSTALL_TARGET}/packaging
View
1 packages/postgresql91/spec
@@ -2,3 +2,4 @@
name: postgresql91
files:
- postgresql/postgresql-9.1-x86_64.tar.gz
+- postgresql/postgresql-initdb-9.1-x86_64.tar.gz

0 comments on commit 96217b6

Please sign in to comment.