ruv commited on
Commit
2a5899a
1 Parent(s): ebd398e

updated install_sql.sh

Browse files
Files changed (2) hide show
  1. sql/install_sql.sh +41 -5
  2. sql/readme.md +41 -5
sql/install_sql.sh CHANGED
@@ -1,14 +1,50 @@
1
  #!/bin/bash
2
 
3
- # Load environment variables
4
- source .env
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- # Check if environment variables are set
7
- if [ -z "$SUPABASE_URL" ] || [ -z "$SUPABASE_DB" ] || [ -z "$SUPABASE_USER" ] || [ -z "$SUPABASE_PASSWORD" ]; then
8
- echo "Please set the SUPABASE_URL, SUPABASE_DB, SUPABASE_USER, and SUPABASE_PASSWORD environment variables in the .env file."
 
 
9
  exit 1
10
  fi
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  # Function to execute a SQL file
13
  execute_sql() {
14
  local file=$1
 
1
  #!/bin/bash
2
 
3
+ # Check if psql is installed
4
+ if ! command -v psql &> /dev/null; then
5
+ echo "psql could not be found. Installing it now..."
6
+
7
+ # Check OS and install psql accordingly
8
+ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
9
+ sudo apt update
10
+ sudo apt install postgresql-client -y
11
+ elif [[ "$OSTYPE" == "darwin"* ]]; then
12
+ brew install postgresql
13
+ elif [[ "$OSTYPE" == "msys" ]]; then
14
+ echo "Please install psql manually from: https://www.postgresql.org/download/windows/"
15
+ exit 1
16
+ else
17
+ echo "Unsupported OS. Please install psql manually."
18
+ exit 1
19
+ fi
20
+ fi
21
 
22
+ # Load environment variables
23
+ if [ -f ".env" ]; then
24
+ source .env
25
+ else
26
+ echo ".env file not found. Please create one with your Supabase configuration."
27
  exit 1
28
  fi
29
 
30
+ # Prompt for environment variables if not set
31
+ if [ -z "$SUPABASE_URL" ]; then
32
+ read -p "Enter your Supabase URL: " SUPABASE_URL
33
+ fi
34
+
35
+ if [ -z "$SUPABASE_DB" ]; then
36
+ read -p "Enter your Supabase database name: " SUPABASE_DB
37
+ fi
38
+
39
+ if [ -z "$SUPABASE_USER" ]; then
40
+ read -p "Enter your Supabase username: " SUPABASE_USER
41
+ fi
42
+
43
+ if [ -z "$SUPABASE_PASSWORD" ]; then
44
+ read -s -p "Enter your Supabase password: " SUPABASE_PASSWORD
45
+ echo
46
+ fi
47
+
48
  # Function to execute a SQL file
49
  execute_sql() {
50
  local file=$1
sql/readme.md CHANGED
@@ -298,15 +298,51 @@ Create a file named `install_sql.sh` in your project directory and add the follo
298
  ```bash
299
  #!/bin/bash
300
 
301
- # Load environment variables
302
- source .env
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
 
304
- # Check if environment variables are set
305
- if [ -z "$SUPABASE_URL" ] || [ -z "$SUPABASE_DB" ] || [ -z "$SUPABASE_USER" ] || [ -z "$SUPABASE_PASSWORD" ]; then
306
- echo "Please set the SUPABASE_URL, SUPABASE_DB, SUPABASE_USER, and SUPABASE_PASSWORD environment variables in the .env file."
 
 
307
  exit 1
308
  fi
309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  # Function to execute a SQL file
311
  execute_sql() {
312
  local file=$1
 
298
  ```bash
299
  #!/bin/bash
300
 
301
+ # Check if psql is installed
302
+ if ! command -v psql &> /dev/null; then
303
+ echo "psql could not be found. Installing it now..."
304
+
305
+ # Check OS and install psql accordingly
306
+ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
307
+ sudo apt update
308
+ sudo apt install postgresql-client -y
309
+ elif [[ "$OSTYPE" == "darwin"* ]]; then
310
+ brew install postgresql
311
+ elif [[ "$OSTYPE" == "msys" ]]; then
312
+ echo "Please install psql manually from: https://www.postgresql.org/download/windows/"
313
+ exit 1
314
+ else
315
+ echo "Unsupported OS. Please install psql manually."
316
+ exit 1
317
+ fi
318
+ fi
319
 
320
+ # Load environment variables
321
+ if [ -f ".env" ]; then
322
+ source .env
323
+ else
324
+ echo ".env file not found. Please create one with your Supabase configuration."
325
  exit 1
326
  fi
327
 
328
+ # Prompt for environment variables if not set
329
+ if [ -z "$SUPABASE_URL" ]; then
330
+ read -p "Enter your Supabase URL: " SUPABASE_URL
331
+ fi
332
+
333
+ if [ -z "$SUPABASE_DB" ]; then
334
+ read -p "Enter your Supabase database name: " SUPABASE_DB
335
+ fi
336
+
337
+ if [ -z "$SUPABASE_USER" ]; then
338
+ read -p "Enter your Supabase username: " SUPABASE_USER
339
+ fi
340
+
341
+ if [ -z "$SUPABASE_PASSWORD" ]; then
342
+ read -s -p "Enter your Supabase password: " SUPABASE_PASSWORD
343
+ echo
344
+ fi
345
+
346
  # Function to execute a SQL file
347
  execute_sql() {
348
  local file=$1