Dhurgh commited on
Commit
50be83e
·
unverified ·
1 Parent(s): c4d6451

Update FireTech Messenger deployment script

Browse files
Files changed (1) hide show
  1. gh +29 -24
gh CHANGED
@@ -1,40 +1,45 @@
1
  #!/bin/bash
2
- # FireTech Messenger - Linux Lite Final Fix
3
 
4
  echo "Starting FireTech Deployment..."
5
 
6
- # 1. Install dependencies
7
  sudo apt update
8
  sudo apt install -y git nodejs npm postgresql postgresql-contrib
9
 
10
- # 2. Fix the "Role" and "Database" issue
11
- echo "Configuring Database Permissions..."
12
  sudo systemctl start postgresql
 
 
 
 
 
 
 
13
 
14
- # This part is the 'Magic Fix':
15
- # It creates a database user that matches his Linux name so he has permission.
16
- USER_NAME=$(whoami)
17
- sudo -u postgres psql -c "CREATE USER $USER_NAME WITH SUPERUSER;" 2>/dev/null
18
- sudo -u postgres psql -c "ALTER USER $USER_NAME WITH PASSWORD 'password';" 2>/dev/null
19
 
20
- # Now we create the railway database safely
21
- sudo -u postgres psql -c "CREATE DATABASE railway;" 2>/dev/null || echo "Database 'railway' already exists, moving on..."
22
 
23
- # 3. App Setup
24
  cd ~
25
- if [ ! -d "FireTech-Messager-Server" ]; then
26
- git clone https://github.com/dhurghamCreation/FireTech-Messager-Server.git
27
- fi
28
  cd FireTech-Messager-Server
29
  npm install
30
 
31
- # 4. Create .env (Updated with a safe local URL)
32
- cat <<EOF > .env
33
- DATABASE_URL=postgresql://$USER_NAME:password@localhost:5432/railway
34
- JWT_SECRET=firetech_secret_123
35
- PORT=3000
36
- EOF
37
-
38
- # 5. Launch
39
- echo "FireTech Server is ready!"
 
 
40
  node server.js
 
1
  #!/bin/bash
2
+ # FireTech Messenger - Linux Lite GUARANTEED FIX
3
 
4
  echo "Starting FireTech Deployment..."
5
 
6
+ # 1. System Prep
7
  sudo apt update
8
  sudo apt install -y git nodejs npm postgresql postgresql-contrib
9
 
10
+ # 2. Database Service Start
 
11
  sudo systemctl start postgresql
12
+ sudo systemctl enable postgresql
13
+
14
+ # 3. Secure User & Database Creation
15
+ # We use 'firetech_user' instead of $(whoami) to prevent string errors
16
+ DB_USER="firetech_admin"
17
+ DB_PASS="firetech_password_123"
18
+ DB_NAME="railway"
19
 
20
+ echo "Configuring Database Permissions..."
21
+ sudo -u postgres psql -c "CREATE USER $DB_USER WITH SUPERUSER PASSWORD '$DB_PASS';" 2>/dev/null || \
22
+ sudo -u postgres psql -c "ALTER USER $DB_USER WITH PASSWORD '$DB_PASS';"
 
 
23
 
24
+ sudo -u postgres psql -c "CREATE DATABASE $DB_NAME;" 2>/dev/null
 
25
 
26
+ # 4. App Setup
27
  cd ~
28
+ # Remove old folder to ensure a clean install
29
+ rm -rf FireTech-Messager-Server
30
+ git clone https://github.com/dhurghamCreation/FireTech-Messager-Server.git
31
  cd FireTech-Messager-Server
32
  npm install
33
 
34
+ # 5. Create .env (The "String Fix")
35
+ # We use single quotes around the URL to ensure it is treated as a string
36
+ echo "DATABASE_URL=\"postgresql://$DB_USER:$DB_PASS@localhost:5432/$DB_NAME\"" > .env
37
+ echo "JWT_SECRET=\"firetech_secret_123\"" >> .env
38
+ echo "PORT=3000" >> .env
39
+
40
+ # 6. Final Launch
41
+ echo "--------------------------------------"
42
+ echo "Fix Applied: Client password is now a string."
43
+ echo "FIRETECH SERVER IS STARTING..."
44
+ echo "--------------------------------------"
45
  node server.js