# Reboot/shutdown client from script

**URL:** <https://forum.inductiveautomation.com/t/reboot-shutdown-client-from-script/35369>\
**Category:** Ignition\
**Created:** [June 5, 2020, 8:36pm UTC](https://forum.inductiveautomation.com/t/reboot-shutdown-client-from-script/35369 "2020-06-05T20:36:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cbiela](https://avatars.discourse-cdn.com/v4/letter/c/a87d85/32.png) [@cbiela](https://forum.inductiveautomation.com/u/cbiela)\
**Post date:** [June 5, 2020, 8:36pm UTC](https://forum.inductiveautomation.com/t/reboot-shutdown-client-from-script/35369/1 "2020-06-05T20:36:33Z")

</div>

Architecture:

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:

```auto
ssh user@client1 '/sbin/reboot'
ssh user@client2 '/sbin/reboot'
...

```

Right now I can’t get `/root/rebootGuests.sh` to fire from the gateway.

Is there a way to do this?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 5, 2020, 9:02pm UTC](https://forum.inductiveautomation.com/t/reboot-shutdown-client-from-script/35369/2 "2020-06-05T21:02:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 6, 2020, 2:37pm UTC](https://forum.inductiveautomation.com/t/reboot-shutdown-client-from-script/35369/3 "2020-06-06T14:37:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cbiela](https://avatars.discourse-cdn.com/v4/letter/c/a87d85/32.png) [@cbiela](https://forum.inductiveautomation.com/u/cbiela)\
**Post date:** [June 8, 2020, 6:11pm UTC](https://forum.inductiveautomation.com/t/reboot-shutdown-client-from-script/35369/4 "2020-06-08T18:11:57Z")

</div>

Currently, the script `/root/rebootGuests.sh` just does contains

```auto
#!/bin/bash
wall TEST MESSAGE

```

I should see this when logged in via ssh to the server.  
It never seems to get called from Ignition via the gateway tag change script method.

I can’t run this from a client, as they are view only (no mouse / keyboard), and may not be running the software.

Basically I can’t seem to find a way to run a gateway shell script from within Ignition…

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 8, 2020, 6:59pm UTC](https://forum.inductiveautomation.com/t/reboot-shutdown-client-from-script/35369/5 "2020-06-08T18:59:49Z")

</div>

Show your script.

Consider trying to directly run `/usr/bin/wall` from the script, for starters.

---

<div class="post-metadata">

**Author:** ![cbiela](https://avatars.discourse-cdn.com/v4/letter/c/a87d85/32.png) [@cbiela](https://forum.inductiveautomation.com/u/cbiela)\
**Post date:** [June 8, 2020, 7:22pm UTC](https://forum.inductiveautomation.com/t/reboot-shutdown-client-from-script/35369/6 "2020-06-08T19:22:13Z")

</div>

Ok, I just changed this. Also forgot to save before testing, D’oh!

It appears to be working with the `wall` command. I’ll figure out ansible or some other method to do a shell reboot on the clients.

Thanks for all the help.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 9, 2020, 12:41am UTC](https://forum.inductiveautomation.com/t/reboot-shutdown-client-from-script/35369/7 "2020-06-09T00:41:37Z")

</div>

I ssh into the clients using sshpass

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.

```python
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)
```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 9, 2020, 12:34pm UTC](https://forum.inductiveautomation.com/t/reboot-shutdown-client-from-script/35369/8 "2020-06-09T12:34:24Z")

</div>

> [@JordanCClark](#):
>
> supersecretpassword

Ahhhhgg! No, just no.

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.
