mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-18 05:34:20 +01:00
Delay shutting down the PC (#759)
* ## 2.0 - New option to delay shutting down the Windows PC - New option to send a message to the PC that is about to be shut down. If somebody is using the PC, you can warn them to save their work. * delay parameter is int. check for empty is not needed when we have a default
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
# Changelog
|
||||
|
||||
## 2.0
|
||||
|
||||
- New option to delay shutting down the Windows PC
|
||||
- New option to send a message to the PC that is about to be shut down. If somebody is using the PC, you can warn them to save their work.
|
||||
|
||||
## 1.0
|
||||
- Update samba 4.8.8
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "RPC Shutdown",
|
||||
"version": "1.0",
|
||||
"version": "2.0",
|
||||
"slug": "rpc_shutdown",
|
||||
"description": "Simple way for remote windows shutdowns",
|
||||
"url": "https://home-assistant.io/addons/rpc_shutdown/",
|
||||
@@ -14,7 +14,9 @@
|
||||
{
|
||||
"alias": "test-pc",
|
||||
"address": "192.168.0.1",
|
||||
"credentials": "user%password"
|
||||
"credentials": "user%password",
|
||||
"delay": 0,
|
||||
"message": "Home Assistant is shutting down this PC. This cannot be canceled. Please save your work!"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -23,7 +25,9 @@
|
||||
{
|
||||
"alias": "match(^[\\w-]*$)",
|
||||
"address": "str",
|
||||
"credentials": "match(^[^%]*(?:%[^%]*)?$)"
|
||||
"credentials": "match(^[^%]*(?:%[^%]*)?$)",
|
||||
"delay": "int(0,600)?",
|
||||
"message": "str?"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -16,6 +16,8 @@ while read -r input; do
|
||||
ALIAS=$(jq --raw-output ".computers[$i].alias" $CONFIG_PATH)
|
||||
ADDRESS=$(jq --raw-output ".computers[$i].address" $CONFIG_PATH)
|
||||
CREDENTIALS=$(jq --raw-output ".computers[$i].credentials" $CONFIG_PATH)
|
||||
DELAY=$(jq --raw-output ".computers[$i].delay" $CONFIG_PATH)
|
||||
MESSAGE=$(jq --raw-output ".computers[$i].message" $CONFIG_PATH)
|
||||
|
||||
# Not the correct alias
|
||||
if [ "$ALIAS" != "$input" ]; then
|
||||
@@ -23,8 +25,8 @@ while read -r input; do
|
||||
fi
|
||||
|
||||
echo "[Info] Shutdown $input -> $ADDRESS"
|
||||
if ! msg="$(net rpc shutdown -I "$ADDRESS" -U "$CREDENTIALS")"; then
|
||||
if ! msg="$(net rpc shutdown -I "$ADDRESS" -U "$CREDENTIALS" -t "$DELAY" -C "$MESSAGE")"; then
|
||||
echo "[Error] Shutdown fails -> $msg"
|
||||
fi
|
||||
done
|
||||
done
|
||||
done
|
||||
Reference in New Issue
Block a user