samarth upadhyay commited on
Commit
902e19c
·
verified ·
1 Parent(s): 07d7799

Create start.sh

Browse files
Files changed (1) hide show
  1. start.sh +48 -0
start.sh ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # --- 1. Configure & Start PostgreSQL ---
4
+ echo "Starting PostgreSQL..."
5
+
6
+ # Start the service (as user 'postgres')
7
+ service postgresql start
8
+
9
+ # Wait a moment for it to boot
10
+ sleep 3
11
+
12
+ # Create a generic 'playground' user and database.
13
+ # We don't set a password because we will rely on local trust.
14
+ su - postgres -c "psql -c \"CREATE USER playground SUPERUSER;\""
15
+ su - postgres -c "psql -c \"CREATE DATABASE playground OWNER playground;\""
16
+
17
+ # Edit pg_hba.conf to trust ALL local connections (removes password requirement)
18
+ # This file location depends on the version installed by apt, usually /etc/postgresql/13/main/pg_hba.conf
19
+ # We use a wildcard find to locate it.
20
+ PG_CONF=$(find /etc/postgresql -name "pg_hba.conf")
21
+ echo "host all all 127.0.0.1/32 trust" > $PG_CONF
22
+ echo "local all all trust" >> $PG_CONF
23
+
24
+ # Restart Postgres to apply "trust" settings
25
+ service postgresql restart
26
+
27
+
28
+ # --- 2. Configure & Start MySQL (MariaDB) ---
29
+ echo "Starting MySQL..."
30
+
31
+ # Start the service
32
+ service mariadb start
33
+
34
+ # Wait a moment
35
+ sleep 3
36
+
37
+ # Create the playground database and a root user that can connect from localhost without password
38
+ # In MariaDB/MySQL on Debian, the unix socket authentication is default,
39
+ # but for Python we often want TCP. We'll create a wide-open user.
40
+ mysql -e "CREATE DATABASE playground;"
41
+ mysql -e "CREATE USER 'playground'@'localhost';"
42
+ mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'playground'@'localhost';"
43
+ mysql -e "FLUSH PRIVILEGES;"
44
+
45
+
46
+ # --- 3. Start Flask App ---
47
+ echo "Starting Flask API..."
48
+ python app.py