Closed vantech14 closed 4 months ago
@vantech14
Did you give your "apcupsd" user the necessary permissions to initiate a shutdown?
My user is called "shutdown" and has these permissions:
@vantech14
Did you give your "apcupsd" user the necessary permissions to initiate a shutdown?
My user is called "shutdown" and has these permissions:
@bnhf
Here is my api setup:
and
I cant see why this isnt working. I also tried to disable apparmor on the host to no avail? The user is setup as a proxmox PVE realm rather than a PAM but i dont think this should make a difference?
Thanks.
@vantech14
Have you tried executing the curl command to initiate a shutdown from another computer? Here's what it looks like in the script, and you can just sub-in your values in place of the env vars (everything inside and including the ${} for each HOSTS, NODES, and TOKENS):
curl "https://${HOSTS[$i]}:8006/api2/extjs/nodes/${NODES[$i]}/status" -H "Authorization: PVEAPIToken=${TOKENS[$i]}" -H "Content-Type: application/x-www-form-urlencoded" --data "command=shutdown" --insecure
If that doesn't work, I'd suggest going to the Proxmox forum, as whatever is going on is Proxmox related. I'm pretty sure there are one or two threads on the subject of API token shutdowns.
@vantech14
Have you tried executing the curl command to initiate a shutdown from another computer? Here's what it looks like in the script, and you can just sub-in your values in place of the env vars (everything inside and including the ${} for each HOSTS, NODES, and TOKENS):
curl "https://${HOSTS[$i]}:8006/api2/extjs/nodes/${NODES[$i]}/status" -H "Authorization: PVEAPIToken=${TOKENS[$i]}" -H "Content-Type: application/x-www-form-urlencoded" --data "command=shutdown" --insecure
If that doesn't work, I'd suggest going to the Proxmox forum, as whatever is going on is Proxmox related. I'm pretty sure there are one or two threads on the subject of API token shutdowns.
@bnhf
root@ubuntu-rpi:~# curl "https://192.168.100.3:8006/api2/extjs/nodes/pve/status" -H "Authorization: PVEAPIToken=apcupsd@pve!apcupsd=bf79bae8-e061-4466-a6b5-redacted" -H "Content-Type: application/x-www-form-urlencoded" --data "command=shutdown" --insecure -bash: !apcupsd=bf79bae8: event not found
Suggests there is an issue with the format of the username?
Command issued:
curl "https://192.168.100.3:8006/api2/extjs/nodes/pve/status" -H "Authorization: PVEAPIToken=apcupsd@pve!apcupsd=bf79bae8-e061-4466-a6b5-redacted" -H "Content-Type: application/x-www-form-urlencoded" --data "command=shutdown" --insecure
Hmm?
@vantech14
Try replacing the double quotes with single quotes for use on the command line.
@bnhf i resolved. The issue was that the user needed the same permissions as the API token. I at first only setup access for the API token.
` - PVE_SHUTDOWN_HOSTS=192.168.100.3 # Ordered list of pve hostnames (or IPs) to be used for API shutdown. Used with matching lists of $PVE_SHUTDOWN_NODES and $PVE_SHUTDOWN_TOKENS
Thanks for your help!
Hi There,
Hope you can help me. The APCUPSD works fine, and integrated with home assistant. I have it running on an Ubuntu host, running on Proxmox. I am trying to shut down the Proxmox OS as follows:
I have also tried the full proxmox URL https://192.168.100.3:8006 and various other combinations.
However i get this error message in the logs each time:
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: 192.168.100.3 Failed to open connection to "system" message bus: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender="(null)" (inactive) interface="org.freedesktop.DBus" member="Hello" error name="(unset)" requested_reply="0" destination="org.freedesktop.DBus" (bus)
Any ideas? The Ubuntu host OS can ping this IP successfully.
Thanks.