-
Notifications
You must be signed in to change notification settings - Fork 0
/
LibreNMS-Install
97 lines (81 loc) · 3.42 KB
/
LibreNMS-Install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Define variables
K3S_INSTALL_SCRIPT="https://get.k3s.io"
K9S_INSTALL_SCRIPT="https://webi.sh/k9s"
BIN_DIR="${BIN_DIR:-/usr/local/bin}"
LNMS_DIR="${LNMS_DIR:-/data}"
# Start of the script
echo "################## Updating Linux ##################"
echo ""
sudo apt-get update
sudo NEEDRESTART_MODE=a apt-get upgrade --yes
echo ""
echo "################## Installing essential tools ##################"
echo ""
sudo NEEDRESTART_MODE=a apt-get install -y curl git vim snmp snmpd
echo ""
echo "################## Downloading and installing K3S ##################"
echo ""
echo "This step installs K3s, a lightweight Kubernetes distribution."
echo ""
# Set KUBECONFIG for all users by creating a script in /etc/profile.d/
grep -qxF 'KUBECONFIG="/etc/rancher/k3s/k3s.yaml"' /etc/environment || echo 'KUBECONFIG="/etc/rancher/k3s/k3s.yaml"' >> /etc/environment
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
export INSTALL_K3S_BIN_DIR="$BIN_DIR"
curl -fsSL "$K3S_INSTALL_SCRIPT" | sudo sh -
echo ""
echo "################## Downloading and installing K9S ##################"
echo ""
echo "This step installs K9s, a terminal-based Kubernetes dashboard."
echo ""
# make K9S usable by all users
curl -fsSL "$K9S_INSTALL_SCRIPT" | sudo sh -
K9S_PATH=$(readlink -f /usr/local/bin/k9s)
sudo mv "$K9S_PATH" "/usr/local/bin/k9s"
sudo chmod +x /usr/local/bin/k9s
echo "################## Downloading and installing Helm ##################"
echo ""
echo "This step installs Helm, the Kubernetes package manager."
echo ""
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | sudo bash
echo ""
echo "################## Fetching LibreNMS Helm Repo ##################"
echo ""
echo "This step fetches the LibreNMS Helm chart from the repository."
echo ""
sudo mkdir -p "$LNMS_DIR/chart"
sudo git clone https://github.com/LoveSkylark/LibreNMS-Helm.git "$LNMS_DIR/vault/LibreNMS-Helm"
sudo git clone https://github.com/LoveSkylark/LibreNMS-Installer.git "$LNMS_DIR/vault/LibreNMS-Installer"
sudo git clone https://github.com/LoveSkylark/LibreNMS-Weathermap-template.git "$LNMS_DIR/vault/LibreNMS-Weathermap-template"
echo "################## Fetching Config ##################"
echo ""
echo " "
echo ""
if [ ! -f "$LNMS_DIR/lnms-config.yaml" ]; then
sudo cp "$LNMS_DIR/vault/LibreNMS-Installer/config/lnms-config.yaml" "$LNMS_DIR/lnms-config.yaml"
fi
if [ ! -f "$LNMS_DIR/librenms/application/weathermap/templates" ]; then
sudo cp -r $LNMS_DIR/vault/LibreNMS-Weathermap-template/* $LNMS_DIR/librenms/application/weathermap/
fi
echo ""
echo "################## Adding aliases for KUBE & HELM ##################"
echo ""
echo "This step sets up convenient aliases for managing Kubernetes and Helm."
echo ""
sudo cp -r $LNMS_DIR/vault/LibreNMS-Installer/profile.d/* /etc/profile.d/
source /etc/profile
echo ""
echo "################## Setting up SNMP for LibreNMS ##################"
echo ""
echo "This step configures SNMP for LibreNMS monitoring."
echo ""
curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
chmod +x /usr/bin/distro
sudo cp $LNMS_DIR/vault/LibreNMS-Installer/snmpd.conf.d/snmp.conf /etc/snmp/snmpd.conf.d/snmp.conf
sudo systemctl restart snmpd
sudo systemctl enable snmpd
echo ""
echo "################## Installation Complete ##################"
echo ""
echo "LibreNMS cluster is installed and configured successfully."
echo ""
echo "Open a new Terminal and run 'nms start' to start the LibreNMS cluster"