Update entrypoint.sh
Browse files- entrypoint.sh +9 -24
entrypoint.sh
CHANGED
@@ -1,26 +1,11 @@
|
|
1 |
#!/bin/bash
|
2 |
|
3 |
-
#
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
# Create a table and insert sample data
|
14 |
-
su - postgres -c "psql -d $POSTGRES_DB -c \"
|
15 |
-
CREATE TABLE users (
|
16 |
-
id SERIAL PRIMARY KEY,
|
17 |
-
name VARCHAR(50) NOT NULL,
|
18 |
-
email VARCHAR(50) UNIQUE NOT NULL
|
19 |
-
);
|
20 |
-
INSERT INTO users (name, email) VALUES
|
21 |
-
('John Doe', '[email protected]'),
|
22 |
-
('Jane Smith', '[email protected]');
|
23 |
-
\""
|
24 |
-
|
25 |
-
# Start the PostgreSQL service
|
26 |
-
exec postgres
|
|
|
1 |
#!/bin/bash
|
2 |
|
3 |
+
# Check if the PostgreSQL data directory is empty
|
4 |
+
if [ -z "$(ls -A /var/lib/postgresql/data)" ]; then
|
5 |
+
echo "Initializing PostgreSQL database..."
|
6 |
+
/usr/lib/postgresql/*/bin/initdb -D /var/lib/postgresql/data
|
7 |
+
fi
|
8 |
+
|
9 |
+
# Start the PostgreSQL server
|
10 |
+
exec /usr/bin/postgres -D /var/lib/postgresql/data
|
11 |
+
echo "server started successfully............."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|