nrpe2to3.sh 1.15 KB
Newer Older
Emmanuel Temam's avatar
Emmanuel Temam committed
1
2
#! /usr/bin/env bash

Emmanuel Temam's avatar
Emmanuel Temam committed
3
4
5
6
7
DESTDIR=/usr/local/etc/nrpe3
NRPEFILE=./nrpe2_mailhub.cfg

echo "Stopping nrpe2"
/usr/local/etc/rc.d/nrpe2 stop
Emmanuel Temam's avatar
Emmanuel Temam committed
8
9
10
11
12
13
echo "Deleting nrpe"
pkg remove -f nrpe-ssl
deluser nagios
echo "Installing nrpe3"
portmaster -bd /usr/ports/net-mgmt/nrpe3
mkdir /usr/local/etc/nrpe3
Emmanuel Temam's avatar
Emmanuel Temam committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
echo "getting files certs"
curl https://gitlab.math.univ-paris-diderot.fr/etemam/nrpe3/raw/master/certs/ca_cert.pem > /usr/local/etc/nrpe3/ca_cert.pem
curl https://gitlab.math.univ-paris-diderot.fr/etemam/nrpe3/raw/master/certs/client_cert.key > /usr/local/etc/nrpe3/client_cert.key
curl https://gitlab.math.univ-paris-diderot.fr/etemam/nrpe3/raw/master/certs/client_cert.pem > /usr/local/etc/nrpe3/client_cert.pem
echo "changing rc.conf"
sed -i.bak 's/nrpe2/nrpe3/g' /etc/rc.conf
echo "backup rc.conf"
mv /etc/rc.conf.bak /usr/local/etc/nrpe3
echo "making new nrpe.cfg"
cat $NRPEFILE | grep "^command\[" > $DESTDIR/local_commands.cfg
curl https://gitlab.math.univ-paris-diderot.fr/etemam/nrpe3/raw/master/tpl_nrpe3.cfg > /tmp/nrpe.cfg
mv $NRPEFILE $DESTDIR/nrpe.cfg.bak
echo "include_dir=$DESDIR" >> /tmp/nrpe.cfg
mv /tmp/nrpe.cfg $NRPEFILE
echo "Starting nrpe3"
/usr/local/etc/rc.d/nrpe3 start