Reboot a machine without interrupting ongoing work

Smart Reboot

GitHub go.mod Go version GitHub License

What?

Smart Reboot is a daemon(smartrebootd) and CLI(smartreboot) that allow for a Linux machine to be rebooted without interrupting any work that may be happening at the current time. This is accomplished by using user-defined scripts to determine when a reboot is required and if it can accomplished at the current time.

Why?

Smart Reboot was designed as a way to confidently let a server handle its own rebooting while not compromising the work being done.

For example: A Jellyfin server shouldn't restart itself while a stream is currently playing, but updates to the kernel and other services still require that the machine be rebooted once in a while. Instead of requiring the manual intervention of the sysadmin, Smart Reboot can be configured to reboot when the system needs to, but only when the Jellyfin instance is idle.

Installing

Debian (and derivatives)

Download and install the .deb file for your architecture from the latest release.

Arch Linux (and derivatives)

SmartReboot is available on the Arch User Repository as the smartreboot package.

Manual installation

You will need a Go compiler(>=1.17) and the Make command(preferably GNU Make) to begin.

First, clone BrenekH/smartreboot like so: git clone https://github.com/BrenekH/smartreboot.git.

Then, change into the directory containing the source files: cd smartreboot.

Next, build using Make: make.

Lastly, install Smart Reboot as follows: sudo make install.

If everything worked, you should now be able to use Smart Reboot!

Usage

Basics

In order to determine whether or not to reboot, Smart Reboot runs the scripts located in /etc/smartreboot/rebootchecks and /etc/smartreboot/blockchecks and evaluates the exit codes. If any of the reboot checks return a 0 exit code, the machine is considered to need a reboot. However, the reboot can be blocked if any one of the block checks return an exit code that is not 0, which indicates that the system is still working on something and cannot be rebooted at this time.

Each of the scripts must be a valid "executable" which includes, but isn't limited to, the following:

  • The script must have the executable bit set(using chmod +x), ideally for all users as to not cause issues when switching from the daemon to the cli.

  • If the script is a text file (Bash, Python, Perl, etc.), it must have a proper shebang at the very beginning of the file.

  • If the script is a compiled binary, it must be an ELF file or equivalent runnable file for your system.

Automatic mode (via the daemon)

Smart Reboot provides a daemon called smartrebootd who's startup and shutdown should be managed by your distro's init system(most likely SystemD). Since the SystemD service should already be installed, you can run sudo systemctl enable smartrebootd && sudo systemctl start smartrebootd to start the Smart Reboot Daemon. If you use a different init system, we welcome any contributions to add support.

By default, smartrebootd only checks for reboots every 15 minutes. This value can be changed by modifying /etc/smartreboot/smartreboot.conf and restarting the daemon(sudo systemctl restart smartrebootd).

Manual mode (via the CLI)

Smart Reboot also provides a cli which can be invoked using the smartreboot command. smartreboot can be used to manually run through the same process that the daemon does using the reboot command like so smartreboot reboot.

If you want to skip the reboot checks, you can use the --force, -f flag which will only check the block scripts before issuing a reboot. Example: smartreboot reboot --force.

Other CLI tricks

In addition to the reboot command, smartreboot can show the current status of the executable scripts that you have setup, which is very useful for setting up the script directories.

Simply run smartreboot check to view each script and its exit code.

License

Smart Reboot is licensed under the GNU General Public License Version 3, a copy of which can be found in LICENSE.

Future plans

  • Allow community scripts to be uploaded so that others don't need to rewrite common scripts.
    • Add some sort of download command to smartreboot which can automatically download and enable these community scripts.
Owner
Brenek Harrison
Go/Python/Kotlin fanboy. Interested in all things development.
Brenek Harrison
Similar Resources

Machine controller manager provider local

Out of tree (controller-based) implementation for local as a new provider. The local out-of-tree provider implements the interface defined at MCM OOT driver.

Feb 20, 2022

A deadly simple state machine for Golang

go-litefsm A deadly simple state machine for Golang, within 100 LOC. Example // Create accepted transitions transitions := NewTransitions() transition

Jul 13, 2022

WIP Go implementation of CSIRAC as a virtual machine.

CSIRAC A work-in-progress Go implementation of CSIRAC, as described in The Last of the First - CSIRAC: Australia's First Computer. The intention is to

Jan 4, 2022

Cluster machine approver

cluster-machine-approver This controller provides the following functionality: Watch the CSR endpoint for CSR requests Decide if the CSR should be all

May 24, 2022

Tool for creating identical machine images for multiple platforms from a single source configuration.

Packer Packer is a tool for building identical machine images for multiple platforms from a single source configuration. Packer is lightweight, runs o

Jan 18, 2022

An experimental Go application that allows an SSH session to interact with the clipboard of the host machine and forward calls to open

Remote Development Manager An experimental Go application that allows an SSH session to interact with the clipboard of the host machine and forward ca

Dec 27, 2022

Implementations of Power VS Provider for the OpenShift machine-api

Machine API Provider Power VS This repository contains implementations of Power VS Provider for the OpenShift machine-api. This provider runs as a mac

Jan 31, 2022

Assignment - make a billing machine for the XYZ Cafe

Assignment In this assignment, you have to make a billing machine for the XYZ Cafe. The machine consist of a group of buttons each representing a uniq

Feb 9, 2022

kolm - Kubernetes on your local machine

kolm - Kubernetes on your local machine kolm is a tool for running a Kubernetes 'cluster' consisting of an etcd and a kube-apiserver on your local mac

May 19, 2022
Comments
  • Use Makefile to automate install process

    Use Makefile to automate install process

    Currently, everything needs to be copied manually, but a Makefile would make the installation much easier and more automatable for distribution packages.

Kubernetes Reboot Daemon
Kubernetes Reboot Daemon

kured - Kubernetes Reboot Daemon Introduction Kubernetes & OS Compatibility Installation Configuration Reboot Sentinel File & Period Setting a schedul

Jan 3, 2023
App for VMware Workstartion to auto start VM's on windows reboot

VMware Workstation AutoStart This is an auto start app for VMware Workstation to auto start VM's on windows reboot with VMware Workstation installed.

Dec 15, 2021
Learning about containers and how they work by creating them the hard way
Learning about containers and how they work by creating them the hard way

Containers the hard way: Gocker: A mini Docker written in Go It is a set of Linux's operating system primitives that provide the illusion of a contain

Jan 7, 2023
A collection of commands for work done on GitHub

gh_sugar A collection of commands for work done on GitHub command pr Create pull request. Usage of pr: -from string from branch -owner str

Oct 19, 2021
Go library for easier work with sqlgo

sqlgo go library for easier work with sql Installation go get github.com/Mikhail

Jan 7, 2022
Demo of skaffold's port-forwarding with ko builder (does not work)

skaffold port-forwarding : Ko builder vs docker builder When using ko builder (see folder ko/), port forwarding does not work (skaffold debug or skaff

Jan 6, 2022
Simple tuning work for go programs in high concurrency scenarios.

go-program-tuning Simple tuning work for go programs in high concurrency scenarios. Installation Run the following command under your project: go get

Mar 15, 2022
LTF is a minimal, transparent Terraform wrapper. It makes Terraform projects easier to work with.

LTF Status: alpha LTF is a minimal, transparent Terraform wrapper. It makes Terraform projects easier to work with. In standard Terraform projects, th

Nov 19, 2022
Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.

Packer Website: https://www.packer.io IRC: #packer-tool on Freenode Mailing list: Google Groups Packer is a tool for building identical machine images

Jan 8, 2023
kubetnl tunnels TCP connections from within a Kubernetes cluster to a cluster-external endpoint, e.g. to your local machine. (the perfect complement to kubectl port-forward)

kubetnl kubetnl (kube tunnel) is a command line utility to tunnel TCP connections from within a Kubernetes to a cluster-external endpoint, e.g. to you

Dec 16, 2022