-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
52 lines (32 loc) · 1015 Bytes
/
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
api_key=$1
echo $api_key
os=$(uname)
architecture=$(uname -m)
platform="$architecture-unknown-linux-musl"
if [[ "$os" == "Darwin" ]]; then
platform="$architecture-apple-darwin"
fi
username=$(whoami)
agent_download_url="$(curl -s https://api.github.com/repos/merklebot/robot-agent/releases/latest | grep /robot-agent-$platform | cut -d : -f 2,3 | tr -d \")"
echo "platform: $platform"
echo "download url: $agent_download_url"
curl -o robot-agent -L $agent_download_url
chmod +x robot-agent
agent_binary_location=$(realpath robot-agent)
echo "agent location: $agent_binary_location"
SERVICE_NAME=robot-agent.service
echo "Creating systemd service"
service_path=/etc/systemd/system/merklebot.service
sudo tee -a $service_path << EOF
[Unit]
Description=Merklebot robot agent
After=network.target
[Service]
ExecStart=$agent_binary_location -a $api_key
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable merklebot
sudo systemctl start merklebot
echo "Service Started"