]> git.pld-linux.org Git - packages/postgresql.git/blobdiff - postgresql.init
- more things, reminder about password etc
[packages/postgresql.git] / postgresql.init
index cdc60bc1fa375374e7d3bc6856655b7d929afaff..11343041dca1609288816b5b0fee56e645135f87 100644 (file)
@@ -82,15 +82,8 @@ case "$1" in
                        exit 1
                    fi
                else
-                   # Create sample database
-                   if [ ! -d $POSTGRES_DATA_DIR ]; then
-                       mkdir -p $POSTGRES_DATA_DIR
-                       chown postgres.postgres $POSTGRES_DATA_DIR
-                       chmod 700 $POSTGRES_DATA_DIR
-                   fi
-                   TMPDIR=/tmp su - postgres -c "LD_LIBRARY_PATH=/usr/lib \
-                       initdb --pgdata=$POSTGRES_DATA_DIR \
-                       -L /usr/share/postgresql -E $ENCODING"
+                   echo "Postgresql database not initialized. Try \"$0 init\" before start."
+                   exit 1
                fi
                
                msg_starting PostgreSQL 
@@ -178,6 +171,34 @@ case "$1" in
                exit 1
        fi
        ;;
+    init)
+       if [ -f "$POSTGRES_DATA_DIR/PG_VERSION" ]; then
+           echo "Seems that database is initialized now. Remove by hand $POSTGRES_DATA_DIR"
+           echo "before initialize database."
+           exit 1
+       fi
+
+       echo -n "Specify encoding for pgsql database (eg: LATIN2, KOI8) [$ENCODING]: "
+       read new_encoding
+       ENCODING=${new_encoding:-$ENCODING}
+
+       show "Creating initial postgresql database using $ENCODING encoding"
+       started
+
+        # Create sample database
+       if [ ! -d $POSTGRES_DATA_DIR ]; then
+           mkdir -p $POSTGRES_DATA_DIR
+           chown postgres.postgres $POSTGRES_DATA_DIR
+           chmod 700 $POSTGRES_DATA_DIR
+       fi
+
+       
+       TMPDIR=/tmp su - postgres -s /bin/sh -c "LD_LIBRARY_PATH=/usr/lib \
+                       initdb --pgdata=$POSTGRES_DATA_DIR \
+                       -L /usr/share/postgresql -E $ENCODING"
+
+       echo "REMEMBER to setup password for user \"postgres\"!"
+       ;;
   *)
        msg_usage "$0 {start|stop|status|restart|reload}"
        exit 1
This page took 0.026387 seconds and 4 git commands to generate.