From 6239b0988f66d9471ee915789552e55dc7b3ae9c Mon Sep 17 00:00:00 2001 From: SantosFC <33733406+SantosFC@users.noreply.github.com> Date: Mon, 8 Jun 2026 07:24:06 -0300 Subject: [PATCH] docs: atualizar README para refletir setup.sh e install_systemd.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige nomes de unit files, caminho do arquivo de configuração, documenta setup.sh como ponto de entrada e adiciona guia de instalação completo do zero (git, python3, clone, setup). --- README.md | 88 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 53cb801..5c6afd1 100644 --- a/README.md +++ b/README.md @@ -4,41 +4,79 @@ Simple health check script for Healthchecks.io, designed to run every minute usi ## Installation -1. Copy the systemd unit files to your user systemd directory: +### 1. Install Git - ```bash - mkdir -p ~/.config/systemd/user - cp systemd/chamado-health.service ~/.config/systemd/user/ - cp systemd/chamado-health.timer ~/.config/systemd/user/ - ``` +```bash +# Debian/Ubuntu +sudo apt update && sudo apt install -y git python3 -2. Update the `HEALTHCHECK_URL` in the service unit or set it in `~/.config/chamado-health`. +# RHEL/CentOS/Fedora +sudo dnf install -y git python3 +``` -3. Reload the user daemon and enable the timer: +### 2. Configure Git identity - ```bash - systemctl --user daemon-reload - systemctl --user enable --now chamado-health.timer - systemctl --user status chamado-health.timer - ``` +```bash +git config --global user.name "Your Name" +git config --global user.email "you@example.com" +``` -4. If you change the service or timer unit later, reload the user daemon and restart the timer using the unit name (not the file path): +### 3. Clone the repository - ```bash - systemctl --user daemon-reload - systemctl --user restart --now chamado-health.timer - systemctl --user list-timers --all | grep chamado-health - journalctl --user -u chamado-health.service -n 10 --no-pager - ``` +```bash +mkdir -p ~/src +git clone https://github.com/SantosFC/health-check.git ~/src/health-monitor +cd ~/src/health-monitor +``` + +### 4. Run the setup script + +```bash +bash setup.sh +``` + +The script will: +1. Ask for your `HEALTHCHECK_URL` (Healthchecks.io ping endpoint) and validate it. +2. Ask for a `DEVICE_NAME` to identify this machine. +3. Save the configuration to `~/.config/health-monitor`. +4. Install and enable the systemd timer. +5. Run a test ping to confirm everything works. + +> Both `HEALTHCHECK_URL` and `DEVICE_NAME` can be pre-set as environment variables to skip the interactive prompts: +> ```bash +> HEALTHCHECK_URL=https://hc-ping.com/ DEVICE_NAME=my-machine bash setup.sh +> ``` ## Configuration -- `HEALTHCHECK_URL` must be set to your Healthchecks.io ping endpoint. -- You can also pass the URL as a command-line argument to the script: +The configuration file is `~/.config/health-monitor`: - ```bash - ./healthcheck.py https://hc-ping.com/ - ``` +``` +HEALTHCHECK_URL=https://hc-ping.com/ +DEVICE_NAME=my-machine +``` + +You can also pass the URL as a command-line argument to the script: + +```bash +./healthcheck.py https://hc-ping.com/ +``` + +## Systemd units + +The unit files installed to `~/.config/systemd/user/` are: + +- `health-check.service` +- `health-check.timer` + +To reload and restart after changes: + +```bash +systemctl --user daemon-reload +systemctl --user restart health-check.timer +systemctl --user list-timers --all | grep health-check +journalctl --user -u health-check.service -n 10 --no-pager +``` ## Script behavior