Skip to content

Commit

Permalink
Grammar improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
gersilex committed Oct 14, 2020
1 parent 9fec5ad commit cd8680a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Usage
With default example settings:

```sh
docker run -t -v /tmp/apcupsd-docker:/tmp/apcupsd-docker gersilex/apcupsd
docker run -t -v /tmp/apcupsd-docker:/tmp/apcupsd-docker gersilex/apcupsd:v1
```

With custom settings:
Expand All @@ -33,14 +33,14 @@ docker run -t \
-v /tmp/apcupsd-docker:/tmp/apcupsd-docker \
-v /path/to/your/apcupsd.conf:/etc/apcupsd/apcupsd.conf \
-v /path/to/your/doshutdown:/etc/apcupsd/doshutdown \
gersilex/apcupsd
gersilex/apcupsd:v1
```

You can read the status from the stdout output, as the container starts `apcupsd -b` and shows INFO loglevel information.

The `/etc/apcupsd/doshutdown` script will be executed when a condition (Low Battery, Low Lifetime left, Timeout exceeded) is reached while being in battery operation (See `/etc/apcupsd/apcupsd.conf` for more information and tweaking).

To be able to signal the Docker host on which the container runs, you should either map your local device into the container (if the UPS is connected to this host) or map a folder from your host into the container and use the included `doshutdown` script. The script will write a `1` into a file with the name `trigger` in that folder. Monitor it on the host with cron or inotify and gracefully shut down your server, when the content is `1`.
To be able to notify the Docker host, you should either map your local device into the container (if the UPS is connected to this host) or map a folder from your host into the container and use the included `doshutdown` script. The script will write a `1` into a file with the name `trigger` in that folder. Monitor it on the host with cron or inotify and gracefully shut down your server, when the content is `1`.
Don't forget to remove the file before shutdown to omit shutdown-loops after booting again.

The `host-trigger-check.sh` contains a cron-compatible script that will run an included bash function, if it reads a '1' in the `/tmp/apcupsd-docker/trigger` file on the host. Read the shell script for instructions on how to use it. It's recommended to run this every minute.
Expand All @@ -50,10 +50,10 @@ Configuration Example

An example `apcupsd.conf` file is provided, along with the original comments. Minimal working example:

- UPS connected to a remote apcupsd instance on the host `nas`. Will execute `doshutdown` if 5% battery is left or 10 minutes remaining. Docker host has cron running and checks for shutdown flag every minute.
- UPS connected to a remote apcupsd instance on the host `nas`. Will execute `doshutdown` if 5% battery is left or 10 minutes remaining, whatever happens first. Docker host has cron running and checks for shutdown flag every minute by running `host-trigger-check.sh`.

```apache
# /etc/apcupsd/apcupsd.conf
# /etc/apcupsd/apcupsd.conf (in the apcupsd-docker container)
UPSTYPE net
DEVICE nas:3551
Expand All @@ -62,7 +62,7 @@ MINUTES 10
```

```sh
# /root/apcupsd/host-trigger-check.sh (excerpt)
# /root/apcupsd/host-trigger-check.sh (excerpt) (on the Docker host)
[...]

TRIGGERFILE="/tmp/apcupsd-docker/trigger"
Expand All @@ -85,7 +85,7 @@ action(){
```

```sh
# /var/spool/cron/gersilex (generated by 'crontab -e')
# /var/spool/cron/gersilex (generated by 'crontab -e') (on the Docker host)

* * * * * /root/apcupsd/host-trigger-check.sh
```
Expand All @@ -106,3 +106,8 @@ License
-------

MIT

Buy Me A Beer
-------------

http://paypal.me/leroyfoerster
2 changes: 1 addition & 1 deletion doshutdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh -e
#
# Use docker run -v </path/to/tmp/apcupsd-docker/on/host>:/tmp/apcupsd-docker to mount the trigger file folder to your host
# Use »docker run -v </path/to/tmp/apcupsd-docker/on/host>:/tmp/apcupsd-docker« to mount the trigger file folder to your host
TRIGGERFILE=/tmp/apcupsd-docker/trigger

umask 0000
Expand Down
8 changes: 4 additions & 4 deletions host-trigger-check.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash -e
#
# This script is part of apcupsd-docker by Leroy Foerster.
# This script is part of apcupsd-docker by Leroy Förster.
# It is designed to be run by regularly (e.g. by cron). If it reads a first line '1' in the TRIGGERFILE, it will run the 'action()' function and replace the '1' with a '0'.
# Please change the content of the TRIGGERFILE variable and the action() function according to your needs. This has to be run on the host, not within a container, to be able to shut the machine down.

# Path of the file that get's created in the folder that you mapped into the apcupsd docker container
# Example: docker run -d -v /tmp/apcupsd-docker:/tmp/apcupsd-docker gersilex/apcupsd
# Path of the file that gets created in the folder that you mapped into the apcupsd docker container
# Example: docker run -d -v /tmp/apcupsd-docker:/tmp/apcupsd-docker gersilex/apcupsd:v1
TRIGGERFILE="/tmp/apcupsd-docker/trigger"

# Put everything you want to do on a shutdown condition instide this function.
# Put everything you want to do on a shutdown condition inside this function.
action(){
echo "Detected '1' in '$TRIGGERFILE'."

Expand Down

0 comments on commit cd8680a

Please sign in to comment.