-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
33 lines (25 loc) · 859 Bytes
/
install.sh
File metadata and controls
33 lines (25 loc) · 859 Bytes
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
#!/bin/bash
ROUTER_IP="${1}"
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <router_ip>"
exit 1
fi
SOURCE_DIR="$(dirname "$(readlink -f "$0")")"
SCRIPT_DEST="/usr/local/bin/haltoping"
SERVICE_DEST="/etc/systemd/system/"
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
cp "$SOURCE_DIR/haltoping" "$SCRIPT_DEST"
chmod +x "$SCRIPT_DEST"
echo "Installing haltoping service..."
cp "$SOURCE_DIR/haltoping.timer" "${SERVICE_DEST}/"
cp "$SOURCE_DIR/haltoping.service" "${SERVICE_DEST}/"
sed -i "s|ExecStart=.*|ExecStart=/usr/local/bin/haltoping ${ROUTER_IP}|g" "${SERVICE_DEST}/haltoping.service"
systemctl daemon-reload
systemctl disable haltoping.service
systemctl enable haltoping.timer
systemctl restart haltoping.service
systemctl status haltoping.service
echo "haltoping has been installed and started successfully."