mirror of
https://github.com/wassname/docker-postgresql.git
synced 2026-07-24 13:00:18 +08:00
clean up init script, removed unnecessary stuff
This commit is contained in:
+1
-2
@@ -13,5 +13,4 @@ EXPOSE 5432
|
|||||||
|
|
||||||
VOLUME ["/var/lib/postgresql"]
|
VOLUME ["/var/lib/postgresql"]
|
||||||
|
|
||||||
ENTRYPOINT ["/app/init"]
|
CMD ["/app/init"]
|
||||||
CMD ["app:start"]
|
|
||||||
|
|||||||
+25
-57
@@ -2,64 +2,32 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
appStart () {
|
# fix permissions and ownership of /var/lib/postgresql
|
||||||
# fix permissions and ownership of /var/lib/postgresql
|
chown -R postgres:postgres /var/lib/postgresql
|
||||||
chown -R postgres:postgres /var/lib/postgresql
|
chmod 700 /var/lib/postgresql
|
||||||
chmod 700 /var/lib/postgresql
|
|
||||||
|
|
||||||
# initialize PostgreSQL data directory
|
# initialize PostgreSQL data directory
|
||||||
if [ ! -d /var/lib/postgresql/9.1/main ]; then
|
if [ ! -d /var/lib/postgresql/9.1/main ]; then
|
||||||
echo "Initializing database..."
|
echo "Initializing database..."
|
||||||
PG_PASSWORD=$(pwgen -c -n -1 14)
|
PG_PASSWORD=$(pwgen -c -n -1 14)
|
||||||
echo "${PG_PASSWORD}" > /var/lib/postgresql/pwfile
|
echo "${PG_PASSWORD}" > /var/lib/postgresql/pwfile
|
||||||
sudo -u postgres -H /usr/lib/postgresql/9.1/bin/initdb \
|
sudo -u postgres -H /usr/lib/postgresql/9.1/bin/initdb \
|
||||||
--pgdata=/var/lib/postgresql/9.1/main --pwfile=/var/lib/postgresql/pwfile \
|
--pgdata=/var/lib/postgresql/9.1/main --pwfile=/var/lib/postgresql/pwfile \
|
||||||
--username=postgres --encoding=unicode --auth=trust >/dev/null
|
--username=postgres --encoding=unicode --auth=trust >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Starting PostgreSQL server..."
|
echo "Starting PostgreSQL server..."
|
||||||
/etc/init.d/postgresql start
|
/etc/init.d/postgresql start
|
||||||
|
|
||||||
if [ -f /var/lib/postgresql/pwfile ]; then
|
if [ -f /var/lib/postgresql/pwfile ]; then
|
||||||
PG_PASSWORD=$(cat /var/lib/postgresql/pwfile)
|
PG_PASSWORD=$(cat /var/lib/postgresql/pwfile)
|
||||||
echo "|------------------------------------------------------------------|"
|
echo "|------------------------------------------------------------------|"
|
||||||
echo "| PostgreSQL User: postgres, Password: ${PG_PASSWORD} |"
|
echo "| PostgreSQL User: postgres, Password: ${PG_PASSWORD} |"
|
||||||
echo "| |"
|
echo "| |"
|
||||||
echo "| To remove the PostgreSQL login credentials from the logs, please |"
|
echo "| To remove the PostgreSQL login credentials from the logs, please |"
|
||||||
echo "| make a note of password and then delete the file pwfile |"
|
echo "| make a note of password and then delete the file pwfile |"
|
||||||
echo "| from the data store. |"
|
echo "| from the data store. |"
|
||||||
echo "|------------------------------------------------------------------|"
|
echo "|------------------------------------------------------------------|"
|
||||||
fi
|
fi
|
||||||
tail -F /var/log/postgresql/postgresql-9.1-main.log
|
|
||||||
}
|
|
||||||
|
|
||||||
appHelp () {
|
tail -F /var/log/postgresql/postgresql-9.1-main.log
|
||||||
echo "Available options:"
|
|
||||||
echo " app:start - Start the postgresql server and watch the log (default)"
|
|
||||||
echo " app:help - Displays the help"
|
|
||||||
echo " [command] - Execute the specified linux command eg. bash."
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
app:start)
|
|
||||||
appStart
|
|
||||||
;;
|
|
||||||
app:help)
|
|
||||||
appHelp
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if [ -x $1 ]; then
|
|
||||||
$1
|
|
||||||
else
|
|
||||||
prog=$(which $1)
|
|
||||||
if [ -n "${prog}" ] ; then
|
|
||||||
shift 1
|
|
||||||
$prog $@
|
|
||||||
else
|
|
||||||
appHelp
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|||||||
Reference in New Issue
Block a user