Server is running Debian 10, all clients are running debian/raspbian.
All clients have server(s)’ public key in their ssh authorized_keys file.
I’d like to be able to call a OS shell script on the gateway to reboot or shutdown the clients.
Sometimes the client will not be operational (raspberry pi3) if it reboots faster than the server. I’m using legacyLauncher.sh and a standalone jre for these.
Ideally, a tag change script on the gateway would watch for a memory tag (say, RebootGuests) and would trigger /root/rebootGuests.sh on the gateway.
/root/rebootGuests.sh would contain the following:
I’m not sure about your specific request, but look into Ansible. I have about 100 raspberry pis that run ignition clients. The RPis are setup to autorun the ignition client on boot up. With a single command I can reboot or shutdown all, or a subset, of the Pis. All of my Pis run on a PoE switch. If you shut the Pis down and need to turn them on, just reboot the switch.
Are you sure Ignition is running as root? I usually use the zip for custom installs, but I thought the regular installer set up a service user (“ignition”) by default. If so, you need that ssh identity in the ignition user’s ~/.ssh folder.
This is a sample script of what I use to reboot a set of Pis upon a gateway start. This is useful in the instance of upgrading a gateway, as the 32 bit clients don’t gracefully recover.
import os
import sys
ipList = [
'192.168.1.100',
'192.168.1.101',
'192.168.1.102',
'192.168.1.103',
'192.168.1.104',
'192.168.1.105',
]
for ip in ipList:
call = 'sshpass -p supersecretpassword ssh piuser@%s sudo reboot' % ip
print call
os.system(call)
Jordan, you really need to learn to use public/private keys in SSH. And in this case, use a dedicated reboot key where the RPis constrain the key to only execute the reboot.