domain and powercycle script

This commit is contained in:
2022-09-14 19:57:15 +02:00
parent 31274f3825
commit 94382ef7c7
2 changed files with 6 additions and 3 deletions

View File

@@ -1 +1,2 @@
hosts="pine01.wks pine02.wks pine03.wks pine04.wks pine05.wks adm01.wks ebin01.wks ebin02.wks"
domain="wks"

View File

@@ -1,10 +1,12 @@
#!/bin/bash
. hosts.conf
host=$1
hostname=$(echo ${host} | sed s/\.${domain}//)
MOSQ="mosquitto_pub -h mqtt.wks -t switch_cloud/switch/${hostname}/command -m"
echo "${host} turning it off"
mosquitto_pub -h mqtt.wks -t switch_cloud/switch/${host}/command -m OFF
${MOSQ} OFF
sleep 2
echo "${host} turning it on"
mosquitto_pub -h mqtt.wks -t switch_cloud/switch/${host}/command -m ON
${MOSQ} ON
ping -W 1 ${host}