Skip to content

For machines connected to UPS. This script shuts down the machine if no network is detected for x amount of time

Notifications You must be signed in to change notification settings

Czino/graceful-shutdown

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

graceful-shutdown

For machines connected to UPS without ability to send shutdown signal.

This script shuts down the machine if no network is detected for x amount of time.

Set it up as a service

  • Create a service file sudo nano /etc/systemd/system/gracefulShutdown.service Content:

    [Unit]
    Description=Graceful shutdown
    
    [Service]
    ExecStart=/PATH/TO/graceful-shutdown/gracefulShutdown.sh
    RuntimeDirectory=checkPowerSupply
    Restart=on-failure
    User=USER
    
    [Install]
    WantedBy=multi-user.target
    
  • rename /PATH/TO the the location of shell script

  • replace USER with actual user

  • start and enable service sudo systemctl enable gracefulShutdown.service sudo systemctl start gracefulShutdown.service

Options

The script contains 2 important variables INTERFACE & MINUTES

INTERFACE (default eth0): the interface your device is connected with (see full list with ip link show)

MINUTES (default 10): the minutes the script waits until it sends the shutdown signal

About

For machines connected to UPS. This script shuts down the machine if no network is detected for x amount of time

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages