Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
128 lines (105 loc) · 3.01 KB
/
Copy pathinstall.sh
File metadata and controls
128 lines (105 loc) · 3.01 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
set -e
# Colors for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
RED='\033[0;31m'
NC='\033[0m'
echo -e "${BLUE}NestOS Installation Script${NC}"
echo "=============================="
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}Please run as root${NC}"
exit 1
fi
# Function to print status
print_status() {
echo -e "${BLUE}[*] $1...${NC}"
}
# Function to print success
print_success() {
echo -e "${GREEN}[✓] $1${NC}"
}
# Update system
print_status "Updating system packages"
apt-get update
apt-get upgrade -y
# Install Node.js 20
print_status "Setting up Node.js 20 repository"
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
# Install required packages
print_status "Installing required packages"
apt-get install -y \
docker.io \
nodejs \
curl \
wget \
git \
mdadm \
smartmontools \
samba \
nfs-kernel-server \
network-manager \
openssh-server
# Verify Node.js version
NODE_VERSION=$(node --version)
MAJOR_VERSION=$(echo "$NODE_VERSION" | cut -d. -f1 | tr -d 'v')
if (( MAJOR_VERSION < 20 )); then
echo -e "${RED}Node.js 20 or higher is required. Got version: $NODE_VERSION${NC}"
exit 1
fi
# Clone NestOS repository
print_status "Cloning NestOS repository"
mkdir -p /opt/nestos
git clone https://github.com/moderniselife/nestos.git /opt/nestos
# Build components
print_status "Building NestOS components"
cd /opt/nestos
npm install
npm run build
# Setup Docker
print_status "Setting up Docker"
systemctl enable docker
systemctl start docker
# Create systemd service file
print_status "Creating systemd service file"
cat > /etc/systemd/system/nestos.service << EOL
[Unit]
Description=NestOS Service
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/opt/nestos
Environment=NODE_OPTIONS=--openssl-legacy-provider
ExecStart=/usr/bin/npm run dev
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOL
# Enable and start service
print_status "Enabling and starting NestOS service"
systemctl daemon-reload
systemctl enable nestos.service
systemctl start nestos.service
# Configure network
print_status "Configuring network"
systemctl enable NetworkManager
systemctl start NetworkManager
# Generate SSL certificates for Vite
print_status "Generating SSL certificates for the control panel"
mkdir -p /opt/nestos/packages/control-panel/ssl
openssl req -x509 -newkey rsa:4096 -keyout /opt/nestos/packages/control-panel/ssl/private.key \
-out /opt/nestos/packages/control-panel/ssl/certificate.crt -days 365 -nodes \
-subj "/C=US/ST=State/L=City/O=Organization/CN=localhost"
# Ensure proper permissions
chmod 600 /opt/nestos/packages/control-panel/ssl/private.key
chmod 644 /opt/nestos/packages/control-panel/ssl/certificate.crt
# Final setup
print_status "Performing final setup"
# Set hostname
hostnamectl set-hostname nestos
print_success "NestOS installation completed!"
echo -e "${BLUE}You can access the control panel at http://localhost:8443${NC}"
echo -e "${BLUE}System service is running on port 3000${NC}"