Skip to content

How to use shutdowns

seriousm4x edited this page Aug 21, 2023 · 7 revisions

Shutdown consist out of two fields: Shutdown Cron and Shutdown Cmd.

upsnap-shutdown

  • Shutdown command is the shell command which is triggered by cron which is ran inside the container (if you use docker) or on your host (if you use the binary). This command will also be executed when you click the green power button on the homepage to shutdown your device.

  • Shutdown Cron is a common cron expression when to trigger the shutdown command. You can easily create your expression at crontab.guru. This can either be enabled or disabled with the toggle to the right.

Testing the command

To test the shutdown command you can exec into your container with docker exec -it upsnap sh, then run your command. Default packages to use are sshpass to shutdown linux computers or net rpc to shutdown windows computers.

Adding custom alpine packages to the container

If you need additional packages to shutdown computers, that do not ship by default with the container, add the following line to your docker-compose.yml:

entrypoint: /bin/sh -c "apk update && apk add --no-cache <YOUR_PACKAGE> && rm -rf /var/cache/apk/* && ./upsnap serve --http 0.0.0.0:8090"

You can search for your package here.

Examples

Example 1

Shutdown computer at 04:05.

  • Cron set to 5 4 * * *
  • Cmd set to net rpc shutdown -I 192.168.1.13 -U "user%password"

Example 2

Shutdown computer at 22:00 on every day-of-week from Monday through Friday.

  • Cron set to 0 22 * * 1-5
  • Cmd set to sshpass -p your_password ssh -o "StrictHostKeyChecking=no" user@hostname "sudo poweroff"

Example 3

Shutdown computer at 00:00 every day.

  • Cron set to @daily
  • Cmd set to sshpass -p password1234 ssh -o "StrictHostKeyChecking=no" root@192.168.0.50 "sudo poweroff"