Spaces:
Runtime error
Runtime error
Finalize FireTech Messenger deployment script
Browse filesUpdated deployment script for FireTech Messenger with final fixes, including database user creation and .env configuration.
gh
CHANGED
|
@@ -1,41 +1,40 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
-
# FireTech Messenger - Linux Lite
|
| 3 |
|
| 4 |
echo "Starting FireTech Deployment..."
|
| 5 |
|
| 6 |
-
# 1.
|
| 7 |
-
sudo apt update
|
| 8 |
-
sudo apt install -y git nodejs npm postgresql postgresql-contrib
|
| 9 |
|
| 10 |
-
# 2.
|
| 11 |
-
echo "Configuring
|
| 12 |
-
# Linux Lite uses systemctl to manage services
|
| 13 |
sudo systemctl start postgresql
|
| 14 |
-
sudo systemctl enable postgresql
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
#
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
#
|
|
|
|
|
|
|
|
|
|
| 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
|
| 30 |
-
echo "Writing environment variables..."
|
| 31 |
cat <<EOF > .env
|
| 32 |
-
DATABASE_URL=postgresql://
|
| 33 |
JWT_SECRET=firetech_secret_123
|
| 34 |
PORT=3000
|
| 35 |
EOF
|
| 36 |
|
| 37 |
-
# 5.
|
| 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
|