First version of README

This commit is contained in:
Robin Meier 2024-03-15 22:35:57 +01:00
parent 3a179d8a00
commit 089078eec5
1 changed files with 76 additions and 0 deletions

76
README.md Normal file
View File

@ -0,0 +1,76 @@
# Admin Scripts
This repo contains some administration scripts for administrering a debian machine.
The covered tasks range from file change tracking via http/ssh monitoring to zfs health checking.
## Installation
The scripts in this repo ***must*** be checked out into `/root/scripts`.
```shell
cd /root
git clone ssh://git@git.mneun.ch:2222/radioelephant/admin-scripts.git scripts
mkdir -p /root/logs
```
For each script there is a `.script_name_env.EXAMPLE` file, which you must copy (remove `.EXAMPLE` part) and edit while providing your own information.
If you want to use the example configuration, you can symbolic link the files. This really only makes sense for `.system_health_check`.
The command for this is:
```shell
cd /root/scripts
ln -s .system_health_check.EXAMPLE .system_health_check
```
### Updating
You can update the admin scripts by pulling from the git remote.
```shell
cd /root/scripts
git pull
```
## Usage
The check and monitoring scripts in this repo can be run periodically be run and if any problems are detected, they produce output.
The output of these scripts can be redirected and used however you like.
Typically I redirect the output to the `telegram_notification.sh` script which notifies me of any noisy scripts.
Regardless of any problems each script also logs its executions in `/root/logs`.
Make sure you created this folder during installation.
### Crontab
You can schedule regular execution of these scripts with "cron".
To configure "cron" use the `crontab -e` command, which opens vim, *our favourite text editor*, containing the cron schedule.
If you are unsure about the cron schedule, use [Crontab Guru](https://crontab.guru).
My current crontab looks like this:
```cron
* * * * * bash -c '/root/scripts/file_monitor.sh | /root/scripts/telegram_notification.sh'
*/2 * * * * bash -c '/root/scripts/monitoring.sh | /root/scripts/telegram_notification.sh'
*/4 * * * * bash -c '/root/scripts/dyndns.sh | /root/scripts/telegram_notification.sh'
*/3 * * * * bash -c '/root/scripts/system_health_check.sh | /root/scripts/telegram_notification.sh'
15 * * * * bash -c '/root/scripts/docker_health_check.sh | /root/scripts/telegram_notification.sh'
*/15 * * * * bash -c '/root/scripts/zfs_health_check.sh | /root/scripts/telegram_notification.sh'
@reboot sleep 10 && /root/scripts/telegram_notification.sh '[STARTUP] System just booted'
@reboot sleep 30 && bash -c '/root/scripts/zfs_health_check.sh | /root/scripts/telegram_notification.sh'
```
### Shutdown
To be notified immediately before sever shutdown the contained `run-before-shutdown.service` can be installed as follows.
This service file will send a telegram notification informing about the pending shutdown.
```shell
ln -s /root/scripts/run-before-shutdown.service /etc/systemd/system/shutdown.target.wants/run-before-shutdown.service
systemctl daemon-reload
```
## Contributors
- Robin Meier (robin@meier.si)