Spaces:
Runtime error

Dhurgh commited on
Commit
c4d6451
·
unverified ·
1 Parent(s): 132a18f

Finalize FireTech Messenger deployment script

Browse files

Updated deployment script for FireTech Messenger with final fixes, including database user creation and .env configuration.

Files changed (1) hide show
  1. gh +19 -20
gh CHANGED
@@ -1,41 +1,40 @@
1
  #!/bin/bash
2
- # FireTech Messenger - Linux Lite Auto-Deployer
3
 
4
  echo "Starting FireTech Deployment..."
5
 
6
- # 1. Update and Install (Using apt instead of pacman)
7
- sudo apt update && sudo apt upgrade -y
8
- sudo apt install -y git nodejs npm postgresql postgresql-contrib sudo nano
9
 
10
- # 2. Setup Database
11
- echo "Configuring PostgreSQL..."
12
- # Linux Lite uses systemctl to manage services
13
  sudo systemctl start postgresql
14
- sudo systemctl enable postgresql
15
 
16
- # Create the 'railway' database
17
- # We use -u postgres to run the command as the database admin
18
- sudo -u postgres createdb railway || echo "Database 'railway' already exists."
 
 
19
 
20
- # 3. Clone and Install App
 
 
 
21
  cd ~
22
- # Only clone if the folder doesn't exist
23
  if [ ! -d "FireTech-Messager-Server" ]; then
24
  git clone https://github.com/dhurghamCreation/FireTech-Messager-Server.git
25
  fi
26
  cd FireTech-Messager-Server
27
  npm install
28
 
29
- # 4. Create .env Configuration
30
- echo "Writing environment variables..."
31
  cat <<EOF > .env
32
- DATABASE_URL=postgresql://postgres@localhost:5432/railway
33
  JWT_SECRET=firetech_secret_123
34
  PORT=3000
35
  EOF
36
 
37
- # 5. Start Server
38
- echo "-----------------------------------"
39
- echo "FIRETECH SERVER IS STARTING..."
40
- echo "-----------------------------------"
41
  node server.js
 
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