-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetup.sh
executable file
·40 lines (32 loc) · 933 Bytes
/
setup.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
#!/bin/bash
# Print work dir
pwd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Go install
go build -o infping infping.go
# Create infping.service
cat <<'EOF' > infping.service
[Unit]
Description=infPing
Requires=network-online.target
After=network-online.target consul.service
[Service]
Type=idle
User=root
Group=root
WorkingDirectory=$pwd
PIDFile=/var/run/infping.pid
ExecStart=$pwd/infping
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGINT
# Give a reasonable amount of time for the server to start up/shut down
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
sed -i "s|WorkingDirectory.*|WorkingDirectory=$pwd|g" $pwd/infping.service
sed -i "s|ExecStart.*|ExecStart=$pwd/infping|g" $pwd/infping.service
# Create systemd infping.service
sudo mv $pwd/infping.service /etc/systemd/system/infping.service
sudo systemctl daemon-reload
sudo systemctl enable infping.service
sudo systemctl start infping.service