homelab/scripts/monitoring/script.sh

36 lines
949 B
Bash
Raw Normal View History

2022-12-31 22:46:38 +01:00
#!/bin/bash
# Template script not meant to be run
set -euo pipefail
source "$HL_LIB"
_ch_001-install_pip() {
sudo apt-get install -y python3-pip
}
_ch_002-install_monitoring() {
git clone git://git.bain.cz/monitor.git ~/monitoring;
cd ~/monitoring;
python3 -m pip install -r requirements.txt
}
_ch_003-create_ssh_identity() {
pushd ~/monitoring;
ssh-keygen -t ed25519 -N "" -f id_status-repo
popd;
echo "_ch_003-create_ssh_identity" >> run.checkpoints
_err "please upload the new SSH identity at ~/monitoring/id_status-repo.pub to github, then restart"
}
_ch_004-clone_status_repo() {
cd ~/monitoring;
git clone --config "core.sshCommand=ssh -i ~/monitoring/id_status-repo" git@github.com:bain3/status.git status-repo
}
_ch_005-install_crontab() {
echo "*/5 * * * * $USER cd /home/$USER/monitoring && python3 monitor.py >> log.log 2>&1" | sudo tee /etc/cron.d/$USER-monitor
}
_run_checkpoints