-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
68 lines (55 loc) · 1.88 KB
/
install.sh
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
#!/bin/bash
echo "Installing sentinel agent"
# Check if the directory exists
if [ -d "/opt/sentinel-agent" ]; then
echo "Directory /opt/sentinel-agent already exists."
exit 1
fi
# Check CPU architecture
arch=$(uname -m)
if [[ "$arch" == "x86_64" ]]; then
echo "AMD architecture detected."
wget https://github.com/SumanSynth/sentinel-agent-setup/releases/download/v1.0.2/sentinel-agent-linux-amd64
elif [[ "$arch" == "arm64" || "$arch" == "aarch64" ]]; then
echo "ARM architecture detected."
wget https://github.com/SumanSynth/sentinel-agent-setup/releases/download/v1.0.2/sentinel-agent-linux-arm64
sudo mv sentinel-agent-linux-arm64 sentinel-agent-linux-amd64
else
echo "Unknown architecture: $arch"
exit 1
fi
sudo mkdir /opt/sentinel-agent
sudo mv sentinel-agent-linux-amd64 /opt/sentinel-agent/
sudo chmod +x /opt/sentinel-agent/sentinel-agent-linux-amd64
device_id=$(uuidgen)
echo "device_id: $device_id"
# Define variables
SERVICE_FILE="/etc/systemd/system/sentinel-agent.service"
SERVICE_CONTENT="[Unit]
Description=Sentinel Agent Service
After=network-online.target
[Service]
ExecStart=/opt/sentinel-agent/sentinel-agent-linux-amd64 $device_id
WorkingDirectory=/opt/sentinel-agent/
Restart=always
RestartSec=10s
User=root
Group=root
[Install]
WantedBy=multi-user.target
"
# Create the service file
echo "Creating service file at $SERVICE_FILE"
sudo bash -c "echo '$SERVICE_CONTENT' > $SERVICE_FILE"
# Reload systemd to recognize the new service file
echo "Reloading systemd configuration"
sudo systemctl daemon-reload
# Enable the service to start on boot
echo "Enabling the sentinel service to start on boot"
sudo systemctl enable sentinel-agent.service
# Start the service
echo "Starting the sentinel service"
sudo systemctl start sentinel-agent.service
# Check the status of the service
echo "Checking the status of the sentinel service"
sudo systemctl status sentinel-agent.service