This commit is contained in:
Eliezer Croitoru 2024-11-19 18:48:46 +02:00
parent 16aad23d12
commit d9f57ef324
3 changed files with 24 additions and 0 deletions

View File

@ -1,3 +1,5 @@
all: all:
echo OK echo OK
install:
cp -vf ping-host.sh /usr/local/bin/

View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
HOST="$1"
set -x
echo "${HOST}" | egrep "^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$"
if [ "$?" -eq "0" ]
then
cat ping-host-target.service | sed -e "s@##TARGET##@${HOST}@g" > "/etc/systemd/system/ping-host-${HOST}.service"
systemctl daemon-reload
fi
set +x

9
ping-host-target.service Normal file
View File

@ -0,0 +1,9 @@
[Unit]
Description=Ping a host service
[Service]
Type=simple
ExecStart=/bin/bash /usr/local/bin/ping-host.sh ##TARGET##
[Install]
WantedBy=multi-user.target