-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_web_ui.sh
More file actions
77 lines (63 loc) · 1.74 KB
/
install_web_ui.sh
File metadata and controls
77 lines (63 loc) · 1.74 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
#!/bin/bash
set -e # Break execution on errors
REPO_URL="https://github.com/Lineage2JS/web-ui.git"
PROJECT_DIR="web-ui"
TARGET_DIR="/var/www/html/lineage2js-web-ui"
BUILD_DIR="dist"
echo "=== Deploying web-ui ==="
# Checking rights
if [[ $EUID -ne 0 ]]; then
echo "Error: Run script with sudo"
exit 1
fi
# Checking Node.js
if ! command -v node &> /dev/null; then
echo "Error: Node.js is not installed"
exit 1
fi
# Checking npm
if ! command -v npm &> /dev/null; then
echo "Error: npm is not installed"
exit 1
fi
# Cloning/updating a repository
echo "Cloning a repository..."
if [ -d "$PROJECT_DIR" ]; then
echo "The $PROJECT_DIR folder already exists, delete it..."
rm -rf "$PROJECT_DIR"
fi
git clone "$REPO_URL"
cd "$PROJECT_DIR"
# Installing dependencies
echo "Installing dependencies..."
npm install
# Build
echo "Build..."
npm run build
# Creating a directory
echo "Creating a directory..."
sudo mkdir -p "$TARGET_DIR"
# Copying collected files
echo "Copying collected files..."
sudo cp -r "$BUILD_DIR"/* "$TARGET_DIR"/
# Deleting a project folder after deployment
echo "Deleting a project folder after deployment..."
cd ..
if [ -d "$PROJECT_DIR" ]; then
echo "Delete the $PROJECT_DIR folder..."
rm -rf "$PROJECT_DIR"
echo "The $PROJECT_DIR folder was successfully deleted."
else
echo "The $PROJECT_DIR folder has already been deleted or does not exist."
fi
# Checking the result
echo "Checking the result..."
if [ -d "$TARGET_DIR" ] && [ "$(ls -A "$TARGET_DIR")" ]; then
echo "Files successfully copied to $TARGET_DIR"
echo "Folder contents:"
ls -la "$TARGET_DIR"
else
echo "Error: The $TARGET_DIR folder is empty or does not exist."
exit 1
fi
echo "=== Deployment completed successfully! ==="