Source

woocode / sa-auto / src / postgres_initdb.sh

Full commit
#!/bin/sh

. ./set_app_env.sh;

. $APP/sh/pg_env.sh

$APP_SVR/postgres/bin/initdb -D $APP_DBDAT/pg_data -U postgres -E UTF8;

rm -f  $APP_DBDAT/pg_data/pg_hba.conf;
rm -f  $APP_DBDAT/pg_data/postgresql.conf;
rm -f  $APP_DBDAT/pg_data/pg_log;

ln -s  $APP/conf/postgres/pg_hba.conf     $APP_DBDAT/pg_data/pg_hba.conf;
ln -s  $APP/conf/postgres/postgresql.conf $APP_DBDAT/pg_data/postgresql.conf;
ln -s  $APP/logs/postgres $APP_DBDAT/pg_data/pg_log;

echo "=====================  begin Start ============================="
$APP_SVR/postgres/bin/pg_ctl  -D $APP_DBDAT/pg_data start;

sleep 15

$APP_SVR/postgres/bin/psql -U postgres -A -q -c "CREATE USER cms WITH PASSWORD 'qwer1234' NOCREATEDB  NOCREATEUSER;"
$APP_SVR/postgres/bin/psql -U postgres -A -q -c "CREATE USER fetip WITH PASSWORD 'qwer1234' NOCREATEDB  NOCREATEUSER;"
$APP_SVR/postgres/bin/createdb -U postgres -E UTF8 -O cms  cmsdb;
$APP_SVR/postgres/bin/createdb -U postgres -E UTF8 -O fetip  fetip001;

sleep 10

$APP_SVR/postgres/bin/pg_ctl -D $APP_DBDAT/pg_data stop;

echo "=====================  begin Stop ============================="

sleep 10

$APP_SVR/postgres/bin/initdb -D $APP_DBDAT/pg_data_bk -U postgres -E UTF8;

rm -f  $APP_DBDAT/pg_data_bk/pg_hba.conf;
rm -f  $APP_DBDAT/pg_data_bk/postgresql.conf;
rm -f  $APP_DBDAT/pg_data_bk/pg_log;

ln -s  $APP/conf/postgres_bk/pg_hba.conf     $APP_DBDAT/pg_data_bk/pg_hba.conf;
ln -s  $APP/conf/postgres_bk/postgresql.conf $APP_DBDAT/pg_data_bk/postgresql.conf;
ln -s  $APP/logs/postgres_bk $APP_DBDAT/pg_data_bk/pg_log;


$APP_SVR/postgres/bin/pg_ctl  -D $APP_DBDAT/pg_data_bk start;

sleep 15

$APP_SVR/postgres/bin/psql -U postgres -A -q -c "CREATE USER cms WITH PASSWORD 'qwer1234' NOCREATEDB  NOCREATEUSER;"

$APP_SVR/postgres/bin/createdb -U postgres -E UTF8 -O cms  cmsdb;

sleep 15;

$APP_SVR/postgres/bin/pg_ctl  -D $APP_DBDAT/pg_data_bk stop;

#createdb -E UTF8 -O username  dbname