-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·79 lines (49 loc) · 2.13 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·79 lines (49 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
echo "========== [1/4] Building frontend =========="
# Step 1: Build frontend static resources
cd ui || { echo "❌ Error: 'ui' directory not found."; exit 1; }
echo "➡ Setting OpenSSL legacy provider for compatibility..."
export NODE_OPTIONS=--openssl-legacy-provider
echo "➡ Running 'npm run build'..."
npm run build
echo "➡ Ensuring target directory /var/www/pki-internet-platform exists..."
sudo mkdir -p /var/www/pki-internet-platform
echo "➡ Removing old dist directory (if exists)..."
sudo rm -rf /var/www/pki-internet-platform/dist
echo "➡ Copying new build to /var/www/pki-internet-platform/dist..."
sudo cp -r dist /var/www/pki-internet-platform/dist
cd ..
echo "✅ Frontend build and deployment complete."
echo -e "\n========== [2/4] Installing Nginx & uWSGI =========="
# Step 2: Install Nginx and uWSGI
echo "➡ Updating package list..."
sudo apt update
echo "➡ Installing nginx, uwsgi, and uwsgi-plugin-python3..."
sudo apt -y install nginx uwsgi uwsgi-plugin-python3
echo "➡ Enabling and starting Nginx..."
sudo systemctl enable nginx
sudo systemctl start nginx
echo "✅ Nginx & uWSGI installation complete."
echo -e "\n========== [3/4] Configuring Nginx =========="
echo "➡ Removing default site config and symlink..."
sudo rm -f /etc/nginx/sites-available/default
sudo rm -f /etc/nginx/sites-enabled/default
echo "➡ Copying new Nginx config to sites-available..."
sudo cp nginx.conf /etc/nginx/sites-available/flask
echo "➡ Creating symlink to sites-enabled..."
sudo ln -sf /etc/nginx/sites-available/flask /etc/nginx/sites-enabled/
echo "➡ Testing Nginx configuration..."
sudo nginx -t
echo "➡ Reloading Nginx..."
sudo systemctl reload nginx
echo "✅ Nginx configured successfully."
echo -e "\n========== [4/4] Starting uWSGI =========="
# Step 4: Start uWSGI
# TODO: check if there are already uwsgi running, and make it to the system service
echo "➡ Starting uWSGI with uwsgi.ini..."
mkdir -p /data/platform_log
uwsgi --ini uwsgi.ini
echo "✅ uWSGI started."
echo -e "\n🎉 [✓] Deployment completed successfully!"