Added a few and some fixes.
This commit is contained in:
@ -1,27 +1,27 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -o errexit
|
set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
|
|
||||||
IFS=$(printf '\n\t')
|
IFS=$(printf '\n\t')
|
||||||
|
|
||||||
# Docker
|
# Docker
|
||||||
sudo apt remove --yes docker docker-engine docker.io containerd runc
|
sudo apt remove --yes docker docker-engine docker.io containerd runc
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt --yes --no-install-recommends install apt-transport-https ca-certificates
|
sudo apt --yes --no-install-recommends install apt-transport-https ca-certificates
|
||||||
wget --quiet --output-document=- https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
wget --quiet --output-document=- https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
||||||
sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu $(lsb_release --codename --short) stable"
|
sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu $(lsb_release --codename --short) stable"
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt --yes --no-install-recommends install docker-ce docker-ce-cli containerd.io
|
sudo apt --yes --no-install-recommends install docker-ce docker-ce-cli containerd.io
|
||||||
sudo usermod --append --groups docker "$USER"
|
sudo usermod --append --groups docker "$USER"
|
||||||
sudo systemctl enable docker
|
sudo systemctl enable docker
|
||||||
printf '\nDocker installed successfully\n\n'
|
printf '\nDocker installed successfully\n\n'
|
||||||
|
|
||||||
printf 'Waiting for Docker to start...\n\n'
|
printf 'Waiting for Docker to start...\n\n'
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
# Docker Compose
|
# Docker Compose
|
||||||
sudo wget --output-document=/usr/local/bin/docker-compose "https://github.com/docker/compose/releases/download/$(wget --quiet --output-document=- https://api.github.com/repos/docker/compose/releases/latest | grep --perl-regexp --only-matching '"tag_name": "\K.*?(?=")')/run.sh"
|
sudo wget --output-document=/usr/local/bin/docker-compose "https://github.com/docker/compose/releases/download/$(wget --quiet --output-document=- https://api.github.com/repos/docker/compose/releases/latest | grep --perl-regexp --only-matching '"tag_name": "\K.*?(?=")')/run.sh"
|
||||||
sudo chmod +x /usr/local/bin/docker-compose
|
sudo chmod +x /usr/local/bin/docker-compose
|
||||||
sudo wget --output-document=/etc/bash_completion.d/docker-compose "https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/bash/docker-compose"
|
sudo wget --output-document=/etc/bash_completion.d/docker-compose "https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/bash/docker-compose"
|
||||||
printf '\nDocker Compose installed successfully\n\n'
|
printf '\nDocker Compose installed successfully\n\n'
|
||||||
|
32
README.md
32
README.md
@ -1,17 +1,17 @@
|
|||||||
# Useful Installation Scripts
|
# Useful Installation Scripts
|
||||||
|
|
||||||
A repo for useful install scripts for various software on Debian based distributions.
|
A repo for useful install scripts for various software on Debian based distributions.
|
||||||
|
|
||||||
# **<u>Current Install Scripts:</u>**
|
# **<u>Current Install Scripts:</u>**
|
||||||
|
|
||||||
- Graylog
|
- Graylog
|
||||||
|
|
||||||
- Netbox
|
- Netbox
|
||||||
|
|
||||||
- Docker with Portainer
|
- Docker with Portainer
|
||||||
|
|
||||||
##### **<u>Credits:</u>**
|
##### **<u>Credits:</u>**
|
||||||
|
|
||||||
#### Ubuntu:
|
#### Ubuntu:
|
||||||
|
|
||||||
- [A simple Docker and Docker Compose install script for Ubuntu · GitHub](https://gist.github.com/EvgenyOrekhov/1ed8a4466efd0a59d73a11d753c0167b)
|
- [A simple Docker and Docker Compose install script for Ubuntu · GitHub](https://gist.github.com/EvgenyOrekhov/1ed8a4466efd0a59d73a11d753c0167b)
|
@ -1,88 +1,88 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Function to print a header with a description
|
# Function to print a header with a description
|
||||||
print_header() {
|
print_header() {
|
||||||
echo "------------------------------------------------------------"
|
echo "------------------------------------------------------------"
|
||||||
echo $1
|
echo $1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if pv is installed, and install it if necessary
|
# Check if pv is installed, and install it if necessary
|
||||||
check_and_install_pv() {
|
check_and_install_pv() {
|
||||||
if ! command -v pv &> /dev/null; then
|
if ! command -v pv &> /dev/null; then
|
||||||
print_header "Installing Pipe Viewer (pv)"
|
print_header "Installing Pipe Viewer (pv)"
|
||||||
sudo apt-get update -y
|
sudo apt-get update -y
|
||||||
sudo apt-get install -y pv
|
sudo apt-get install -y pv
|
||||||
else
|
else
|
||||||
print_header "Pipe Viewer (pv) is already installed"
|
print_header "Pipe Viewer (pv) is already installed"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to run a command with progress bar if `pv` is available
|
# Function to run a command with progress bar if `pv` is available
|
||||||
run_with_progress() {
|
run_with_progress() {
|
||||||
local cmd="$1"
|
local cmd="$1"
|
||||||
if command -v pv &> /dev/null; then
|
if command -v pv &> /dev/null; then
|
||||||
echo "$cmd | pv -l -p -t -e -r"
|
echo "$cmd | pv -l -p -t -e -r"
|
||||||
else
|
else
|
||||||
echo "Running: $cmd"
|
echo "Running: $cmd"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install required packages for Docker
|
# Install required packages for Docker
|
||||||
print_header "Installing required packages..."
|
print_header "Installing required packages..."
|
||||||
sudo apt-get update -y
|
sudo apt-get update -y
|
||||||
sudo apt-get install -y \
|
sudo apt-get install -y \
|
||||||
apt-transport-https \
|
apt-transport-https \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
curl \
|
curl \
|
||||||
gnupg-agent \
|
gnupg-agent \
|
||||||
software-properties-common
|
software-properties-common
|
||||||
|
|
||||||
# Add Docker’s official GPG key with progress bar
|
# Add Docker’s official GPG key with progress bar
|
||||||
check_and_install_pv
|
check_and_install_pv
|
||||||
print_header "Adding Docker's official GPG key..."
|
print_header "Adding Docker's official GPG key..."
|
||||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmour -o /usr/share/keyrings/docker-archive-keyring.gpg
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmour -o /usr/share/keyrings/docker-archive-keyring.gpg
|
||||||
|
|
||||||
# Set up the stable repository for Docker
|
# Set up the stable repository for Docker
|
||||||
print_header "Setting up Docker repository..."
|
print_header "Setting up Docker repository..."
|
||||||
echo \
|
echo \
|
||||||
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
|
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
|
||||||
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||||
|
|
||||||
# Update the package list again with progress bar
|
# Update the package list again with progress bar
|
||||||
run_with_progress "sudo apt-get update"
|
run_with_progress "sudo apt-get update"
|
||||||
|
|
||||||
# Install Docker CE (Community Edition)
|
# Install Docker CE (Community Edition)
|
||||||
print_header "Installing Docker CE..."
|
print_header "Installing Docker CE..."
|
||||||
run_with_progress "sudo apt-get install -y docker-ce docker-ce-cli containerd.io"
|
run_with_progress "sudo apt-get install -y docker-ce docker-ce-cli containerd.io"
|
||||||
|
|
||||||
# Verify that Docker is installed correctly
|
# Verify that Docker is installed correctly
|
||||||
print_header "Starting and enabling Docker service..."
|
print_header "Starting and enabling Docker service..."
|
||||||
sudo systemctl start docker
|
sudo systemctl start docker
|
||||||
sudo systemctl enable docker
|
sudo systemctl enable docker
|
||||||
|
|
||||||
# Download Docker Compose with progress bar
|
# Download Docker Compose with progress bar
|
||||||
check_and_install_pv
|
check_and_install_pv
|
||||||
print_header "Downloading and installing Docker Compose..."
|
print_header "Downloading and installing Docker Compose..."
|
||||||
sudo curl -L --output /tmp/docker-compose.tar.gz https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)
|
sudo curl -L --output /tmp/docker-compose.tar.gz https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)
|
||||||
run_with_progress "pv -p -t -e -r /tmp/docker-compose.tar.gz | tar -xzf - -C /usr/local/bin"
|
run_with_progress "pv -p -t -e -r /tmp/docker-compose.tar.gz | tar -xzf - -C /usr/local/bin"
|
||||||
|
|
||||||
# Verify that Docker Compose is installed correctly
|
# Verify that Docker Compose is installed correctly
|
||||||
print_header "Checking installation of Docker Compose..."
|
print_header "Checking installation of Docker Compose..."
|
||||||
sudo ln -sf /usr/local/bin/docker-compose /usr/bin/docker-compose
|
sudo ln -sf /usr/local/bin/docker-compose /usr/bin/docker-compose
|
||||||
|
|
||||||
# Install Portainer and start it
|
# Install Portainer and start it
|
||||||
print_header "Installing and starting Portainer..."
|
print_header "Installing and starting Portainer..."
|
||||||
run_with_progress "curl -fL https://portainer.io/portainer.tar.gz | sudo tar xz -C /"
|
run_with_progress "curl -fL https://portainer.io/portainer.tar.gz | sudo tar xz -C /"
|
||||||
sudo mv /portainer/portainer /usr/local/bin/portainer
|
sudo mv /portainer/portainer /usr/local/bin/portainer
|
||||||
rm -rf /portainer
|
rm -rf /portainer
|
||||||
sudo chmod +x /usr/local/bin/portainer
|
sudo chmod +x /usr/local/bin/portainer
|
||||||
|
|
||||||
# Run Portainer in detached mode
|
# Run Portainer in detached mode
|
||||||
print_header "Starting Portainer..."
|
print_header "Starting Portainer..."
|
||||||
run_with_progress "sudo /usr/local/bin/portainer --log-level=info --tls"
|
run_with_progress "sudo /usr/local/bin/portainer --log-level=info --tls"
|
||||||
|
|
||||||
# Print a message indicating that Portainer is running and accessible on the default URL
|
# Print a message indicating that Portainer is running and accessible on the default URL
|
||||||
echo ""
|
echo ""
|
||||||
echo "Portainer has been installed and started. You can access it at:"
|
echo "Portainer has been installed and started. You can access it at:"
|
||||||
echo "https://<your-server-ip>:9000"
|
echo "https://<your-server-ip>:9000"
|
@ -1,15 +1,15 @@
|
|||||||
To run this script:
|
To run this script:
|
||||||
|
|
||||||
1. Use wget to grab the latest version:
|
1. Use wget to grab the latest version:
|
||||||
|
|
||||||
`wget https://og.codes/oliver/install-scripts/raw/branch/master/docker-with-portainer/install.sh`
|
`wget https://og.codes/oliver/install-scripts/raw/branch/master/docker-with-portainer/install.sh`
|
||||||
|
|
||||||
2. CHMOD the script to make it executable:
|
2. CHMOD the script to make it executable:
|
||||||
|
|
||||||
`chmod +x install.sh`
|
`chmod +x install.sh`
|
||||||
|
|
||||||
3. Run the script:
|
3. Run the script:
|
||||||
|
|
||||||
`./install.sh`
|
`./install.sh`
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,217 +1,217 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Default versions
|
# Default versions
|
||||||
DEFAULT_PROMETHEUS_VERSION="3.1.0"
|
DEFAULT_PROMETHEUS_VERSION="3.1.0"
|
||||||
DEFAULT_NODE_EXPORTER_VERSION="1.8.2"
|
DEFAULT_NODE_EXPORTER_VERSION="1.8.2"
|
||||||
|
|
||||||
# Function to display menu and get user choices
|
# Function to display menu and get user choices
|
||||||
function show_menu() {
|
function show_menu() {
|
||||||
echo "Please select the software you would like to install (multiple selections allowed):"
|
echo "Please select the software you would like to install (multiple selections allowed):"
|
||||||
echo "1. Prometheus"
|
echo "1. Prometheus"
|
||||||
echo "2. Node Exporter"
|
echo "2. Node Exporter"
|
||||||
echo "3. Grafana"
|
echo "3. Grafana"
|
||||||
echo "4. Exit"
|
echo "4. Exit"
|
||||||
read -p "Enter your choice(s) as a comma-separated list (e.g., 1,2,3) [default: 4]: " choice
|
read -p "Enter your choice(s) as a comma-separated list (e.g., 1,2,3) [default: 4]: " choice
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to display progress bar
|
# Function to display progress bar
|
||||||
function show_progress {
|
function show_progress {
|
||||||
local total=$1
|
local total=$1
|
||||||
local current=$2
|
local current=$2
|
||||||
local percent=$((current * 100 / total))
|
local percent=$((current * 100 / total))
|
||||||
printf "\r[%-70s] %d%%" "$(printf '#%.0s' $(seq 1 $percent))" "$percent"
|
printf "\r[%-70s] %d%%" "$(printf '#%.0s' $(seq 1 $percent))" "$percent"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to download and install Prometheus
|
# Function to download and install Prometheus
|
||||||
function install_prometheus() {
|
function install_prometheus() {
|
||||||
read -p "Enter the desired Prometheus version (e.g., v2.41.0) [default: $DEFAULT_PROMETHEUS_VERSION]: " PROMETHEUS_VERSION
|
read -p "Enter the desired Prometheus version (e.g., v2.41.0) [default: $DEFAULT_PROMETHEUS_VERSION]: " PROMETHEUS_VERSION
|
||||||
PROMETHEUS_VERSION=${PROMETHEUS_VERSION:-$DEFAULT_PROMETHEUS_VERSION}
|
PROMETHEUS_VERSION=${PROMETHEUS_VERSION:-$DEFAULT_PROMETHEUS_VERSION}
|
||||||
|
|
||||||
echo "Chosen Prometheus version: $PROMETHEUS_VERSION"
|
echo "Chosen Prometheus version: $PROMETHEUS_VERSION"
|
||||||
DOWNLOAD_DIR="/tmp/prometheus-install"
|
DOWNLOAD_DIR="/tmp/prometheus-install"
|
||||||
PROMETHEUS_USER="prometheus"
|
PROMETHEUS_USER="prometheus"
|
||||||
PROMETHEUS_GROUP="prometheus"
|
PROMETHEUS_GROUP="prometheus"
|
||||||
PROMETHEUS_DIR="/usr/local/bin/prometheus"
|
PROMETHEUS_DIR="/usr/local/bin/prometheus"
|
||||||
CONFIG_DIR="/etc/prometheus"
|
CONFIG_DIR="/etc/prometheus"
|
||||||
DATA_DIR="/var/lib/prometheus"
|
DATA_DIR="/var/lib/prometheus"
|
||||||
|
|
||||||
echo "Creating download directory..."
|
echo "Creating download directory..."
|
||||||
mkdir -p $DOWNLOAD_DIR
|
mkdir -p $DOWNLOAD_DIR
|
||||||
|
|
||||||
echo "Downloading Prometheus binary..."
|
echo "Downloading Prometheus binary..."
|
||||||
cd $DOWNLOAD_DIR
|
cd $DOWNLOAD_DIR
|
||||||
wget https://github.com/prometheus/prometheus/releases/download/v$PROMETHEUS_VERSION/prometheus-$PROMETHEUS_VERSION.linux-amd64.tar.gz
|
wget https://github.com/prometheus/prometheus/releases/download/v$PROMETHEUS_VERSION/prometheus-$PROMETHEUS_VERSION.linux-amd64.tar.gz
|
||||||
|
|
||||||
echo "Extracting Prometheus binary..."
|
echo "Extracting Prometheus binary..."
|
||||||
tar xvfz prometheus-$PROMETHEUS_VERSION.linux-amd64.tar.gz
|
tar xvfz prometheus-$PROMETHEUS_VERSION.linux-amd64.tar.gz
|
||||||
|
|
||||||
echo "Copying Prometheus binary to $PROMETHEUS_DIR..."
|
echo "Copying Prometheus binary to $PROMETHEUS_DIR..."
|
||||||
cp prometheus-$PROMETHEUS_VERSION.linux-amd64/prometheus $PROMETHEUS_DIR
|
cp prometheus-$PROMETHEUS_VERSION.linux-amd64/prometheus $PROMETHEUS_DIR
|
||||||
echo "Copying promtool binary to /usr/local/bin"
|
echo "Copying promtool binary to /usr/local/bin"
|
||||||
sudo cp prometheus-$PROMETHEUS_VERSION.linux-amd64/promtool /usr/local/bin
|
sudo cp prometheus-$PROMETHEUS_VERSION.linux-amd64/promtool /usr/local/bin
|
||||||
|
|
||||||
echo "Creating Prometheus configuration file in $CONFIG_DIR..."
|
echo "Creating Prometheus configuration file in $CONFIG_DIR..."
|
||||||
cat <<EOF > $CONFIG_DIR/prometheus.yml
|
cat <<EOF > $CONFIG_DIR/prometheus.yml
|
||||||
global:
|
global:
|
||||||
scrape_interval: 15s
|
scrape_interval: 15s
|
||||||
|
|
||||||
scrape_configs:
|
scrape_configs:
|
||||||
- job_name: 'prometheus'
|
- job_name: 'prometheus'
|
||||||
static_configs:
|
static_configs:
|
||||||
- targets: ['localhost:9090']
|
- targets: ['localhost:9090']
|
||||||
|
|
||||||
- job_name: 'node_exporter'
|
- job_name: 'node_exporter'
|
||||||
static_configs:
|
static_configs:
|
||||||
- targets: ['localhost:9100']
|
- targets: ['localhost:9100']
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "Creating $PROMETHEUS_USER user and group..."
|
echo "Creating $PROMETHEUS_USER user and group..."
|
||||||
sudo groupadd --system $PROMETHEUS_GROUP
|
sudo groupadd --system $PROMETHEUS_GROUP
|
||||||
sudo useradd -s /sbin/nologin --system -g $PROMETHEUS_GROUP $PROMETHEUS_USER
|
sudo useradd -s /sbin/nologin --system -g $PROMETHEUS_GROUP $PROMETHEUS_USER
|
||||||
|
|
||||||
echo "Setting ownership of directories and files..."
|
echo "Setting ownership of directories and files..."
|
||||||
sudo chown -R $PROMETHEUS_USER:$PROMETHEUS_GROUP $CONFIG_DIR $DATA_DIR
|
sudo chown -R $PROMETHEUS_USER:$PROMETHEUS_GROUP $CONFIG_DIR $DATA_DIR
|
||||||
sudo chown -R $PROMETHEUS_USER:$PROMETHEUS_GROUP /usr/local/bin/prometheus
|
sudo chown -R $PROMETHEUS_USER:$PROMETHEUS_GROUP /usr/local/bin/prometheus
|
||||||
sudo chown -R $PROMETHEUS_USER:$PROMETHEUS_GROUP /usr/local/bin/node_exporter
|
sudo chown -R $PROMETHEUS_USER:$PROMETHEUS_GROUP /usr/local/bin/node_exporter
|
||||||
|
|
||||||
echo "Creating systemd service for Prometheus..."
|
echo "Creating systemd service for Prometheus..."
|
||||||
cat <<EOF | sudo tee /etc/systemd/system/prometheus.service > /dev/null
|
cat <<EOF | sudo tee /etc/systemd/system/prometheus.service > /dev/null
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Prometheus Time Series Database
|
Description=Prometheus Time Series Database
|
||||||
Wants=network-online.target
|
Wants=network-online.target
|
||||||
After=network-online.target
|
After=network-online.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=$PROMETHEUS_USER
|
User=$PROMETHEUS_USER
|
||||||
Group=$PROMETHEUS_GROUP
|
Group=$PROMETHEUS_GROUP
|
||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=/usr/local/bin/prometheus \
|
ExecStart=/usr/local/bin/prometheus \
|
||||||
--config.file=$CONFIG_DIR/prometheus.yml \
|
--config.file=$CONFIG_DIR/prometheus.yml \
|
||||||
--storage.tsdb.path=$DATA_DIR
|
--storage.tsdb.path=$DATA_DIR
|
||||||
|
|
||||||
Restart=always
|
Restart=always
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=default.target
|
WantedBy=default.target
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "Reloading systemd daemon..."
|
echo "Reloading systemd daemon..."
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
echo "Enabling Prometheus service..."
|
echo "Enabling Prometheus service..."
|
||||||
sudo systemctl enable prometheus.service
|
sudo systemctl enable prometheus.service
|
||||||
echo "Starting Prometheus service..."
|
echo "Starting Prometheus service..."
|
||||||
sudo systemctl start prometheus.service
|
sudo systemctl start prometheus.service
|
||||||
echo "Checking status of Prometheus service..."
|
echo "Checking status of Prometheus service..."
|
||||||
systemctl status prometheus.service
|
systemctl status prometheus.service
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to download and install Node Exporter
|
# Function to download and install Node Exporter
|
||||||
function install_node_exporter() {
|
function install_node_exporter() {
|
||||||
read -p "Enter the desired Node Exporter version (e.g., v1.6.0) [default: $DEFAULT_NODE_EXPORTER_VERSION]: " NODE_EXPORTER_VERSION
|
read -p "Enter the desired Node Exporter version (e.g., v1.6.0) [default: $DEFAULT_NODE_EXPORTER_VERSION]: " NODE_EXPORTER_VERSION
|
||||||
NODE_EXPORTER_VERSION=${NODE_EXPORTER_VERSION:-$DEFAULT_NODE_EXPORTER_VERSION}
|
NODE_EXPORTER_VERSION=${NODE_EXPORTER_VERSION:-$DEFAULT_NODE_EXPORTER_VERSION}
|
||||||
|
|
||||||
echo "Chosen Node Exporter version: $NODE_EXPORTER_VERSION"
|
echo "Chosen Node Exporter version: $NODE_EXPORTER_VERSION"
|
||||||
DOWNLOAD_DIR="/tmp/node-exporter-install"
|
DOWNLOAD_DIR="/tmp/node-exporter-install"
|
||||||
PROMETHEUS_USER="prometheus"
|
PROMETHEUS_USER="prometheus"
|
||||||
PROMETHEUS_GROUP="prometheus"
|
PROMETHEUS_GROUP="prometheus"
|
||||||
BINARY_DIR="/usr/local/bin"
|
BINARY_DIR="/usr/local/bin"
|
||||||
|
|
||||||
echo "Creating download directory..."
|
echo "Creating download directory..."
|
||||||
mkdir -p $DOWNLOAD_DIR
|
mkdir -p $DOWNLOAD_DIR
|
||||||
|
|
||||||
echo "Downloading Node Exporter binary..."
|
echo "Downloading Node Exporter binary..."
|
||||||
cd $DOWNLOAD_DIR
|
cd $DOWNLOAD_DIR
|
||||||
wget https://github.com/prometheus/node_exporter/releases/download/v$NODE_EXPORTER_VERSION/node_exporter-$NODE_EXPORTER_VERSION.linux-amd64.tar.gz
|
wget https://github.com/prometheus/node_exporter/releases/download/v$NODE_EXPORTER_VERSION/node_exporter-$NODE_EXPORTER_VERSION.linux-amd64.tar.gz
|
||||||
|
|
||||||
echo "Extracting Node Exporter binary..."
|
echo "Extracting Node Exporter binary..."
|
||||||
tar xvfz node_exporter-$NODE_EXPORTER_VERSION.linux-amd64.tar.gz
|
tar xvfz node_exporter-$NODE_EXPORTER_VERSION.linux-amd64.tar.gz
|
||||||
|
|
||||||
echo "Copying Node Exporter binary to $BINARY_DIR..."
|
echo "Copying Node Exporter binary to $BINARY_DIR..."
|
||||||
sudo cp node_exporter-$NODE_EXPORTER_VERSION.linux-amd64/node_exporter $BINARY_DIR
|
sudo cp node_exporter-$NODE_EXPORTER_VERSION.linux-amd64/node_exporter $BINARY_DIR
|
||||||
|
|
||||||
echo "Creating systemd service for Node Exporter..."
|
echo "Creating systemd service for Node Exporter..."
|
||||||
cat <<EOF | sudo tee /etc/systemd/system/node_exporter.service > /dev/null
|
cat <<EOF | sudo tee /etc/systemd/system/node_exporter.service > /dev/null
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Node Exporter
|
Description=Node Exporter
|
||||||
Wants=network-online.target
|
Wants=network-online.target
|
||||||
After=network-online.target
|
After=network-online.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=$PROMETHEUS_USER
|
User=$PROMETHEUS_USER
|
||||||
Group=$PROMETHEUS_GROUP
|
Group=$PROMETHEUS_GROUP
|
||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=/usr/local/bin/node_exporter
|
ExecStart=/usr/local/bin/node_exporter
|
||||||
|
|
||||||
Restart=always
|
Restart=always
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=default.target
|
WantedBy=default.target
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "Reloading systemd daemon..."
|
echo "Reloading systemd daemon..."
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
echo "Enabling Node Exporter service..."
|
echo "Enabling Node Exporter service..."
|
||||||
sudo systemctl enable node_exporter.service
|
sudo systemctl enable node_exporter.service
|
||||||
echo "Starting Node Exporter service..."
|
echo "Starting Node Exporter service..."
|
||||||
sudo systemctl start node_exporter.service
|
sudo systemctl start node_exporter.service
|
||||||
echo "Checking status of Node Exporter service..."
|
echo "Checking status of Node Exporter service..."
|
||||||
systemctl status node_exporter.service
|
systemctl status node_exporter.service
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to install Grafana
|
# Function to install Grafana
|
||||||
function install_grafana() {
|
function install_grafana() {
|
||||||
echo "Installing Grafana using the official PPA..."
|
echo "Installing Grafana using the official PPA..."
|
||||||
|
|
||||||
echo "Importing Grafana repository keyring..."
|
echo "Importing Grafana repository keyring..."
|
||||||
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
|
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
|
||||||
|
|
||||||
echo "Adding Grafana repository..."
|
echo "Adding Grafana repository..."
|
||||||
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
|
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
|
||||||
|
|
||||||
echo "Updating package list..."
|
echo "Updating package list..."
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
|
|
||||||
echo "Installing Grafana..."
|
echo "Installing Grafana..."
|
||||||
sudo apt-get install -y grafana
|
sudo apt-get install -y grafana
|
||||||
|
|
||||||
echo "Enabling Grafana service..."
|
echo "Enabling Grafana service..."
|
||||||
sudo systemctl enable grafana-server
|
sudo systemctl enable grafana-server
|
||||||
echo "Starting Grafana service..."
|
echo "Starting Grafana service..."
|
||||||
sudo systemctl start grafana-server
|
sudo systemctl start grafana-server
|
||||||
echo "Checking status of Grafana service..."
|
echo "Checking status of Grafana service..."
|
||||||
systemctl status grafana-server
|
systemctl status grafana-server
|
||||||
}
|
}
|
||||||
|
|
||||||
# Prompt for sudo password and validate it
|
# Prompt for sudo password and validate it
|
||||||
sudo -v
|
sudo -v
|
||||||
|
|
||||||
# Main script execution
|
# Main script execution
|
||||||
show_menu
|
show_menu
|
||||||
|
|
||||||
# Convert the input choice to an array
|
# Convert the input choice to an array
|
||||||
IFS=',' read -r -a choices <<< "$choice"
|
IFS=',' read -r -a choices <<< "$choice"
|
||||||
|
|
||||||
# Execute selected installations with progress bar
|
# Execute selected installations with progress bar
|
||||||
for i in "${!choices[@]}"; do
|
for i in "${!choices[@]}"; do
|
||||||
case ${choices[$i]} in
|
case ${choices[$i]} in
|
||||||
1)
|
1)
|
||||||
echo "Installing Prometheus..."
|
echo "Installing Prometheus..."
|
||||||
install_prometheus
|
install_prometheus
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
echo "Installing Node Exporter..."
|
echo "Installing Node Exporter..."
|
||||||
install_node_exporter
|
install_node_exporter
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
echo "Installing Grafana..."
|
echo "Installing Grafana..."
|
||||||
install_grafana
|
install_grafana
|
||||||
;;
|
;;
|
||||||
4)
|
4)
|
||||||
echo "Exiting..."
|
echo "Exiting..."
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Invalid choice: ${choices[$i]}. Skipping."
|
echo "Invalid choice: ${choices[$i]}. Skipping."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Installation completed successfully!"
|
echo "Installation completed successfully!"
|
||||||
|
@ -1,102 +1,102 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Function to install Loki and Promtail
|
# Function to install Loki and Promtail
|
||||||
install_loki_promtail() {
|
install_loki_promtail() {
|
||||||
echo "Installing Loki and Promtail..."
|
echo "Installing Loki and Promtail..."
|
||||||
|
|
||||||
# Install Loki
|
# Install Loki
|
||||||
echo "Installing Loki..."
|
echo "Installing Loki..."
|
||||||
wget -q -O - https://repo.thanos.io/thanos.key | apt-key add -
|
wget -q -O - https://repo.thanos.io/thanos.key | apt-key add -
|
||||||
echo "deb [arch=amd64] https://repo.thanos.io/deb all main" | tee /etc/apt/sources.list.d/thanos.list
|
echo "deb [arch=amd64] https://repo.thanos.io/deb all main" | tee /etc/apt/sources.list.d/thanos.list
|
||||||
apt-get update -y
|
apt-get update -y
|
||||||
apt-get install -y loki
|
apt-get install -y loki
|
||||||
|
|
||||||
# Install Promtail
|
# Install Promtail
|
||||||
echo "Installing Promtail..."
|
echo "Installing Promtail..."
|
||||||
wget -q -O - https://repo.thanos.io/thanos.key | apt-key add -
|
wget -q -O - https://repo.thanos.io/thanos.key | apt-key add -
|
||||||
echo "deb [arch=amd64] https://repo.thanos.io/deb all main" | tee /etc/apt/sources.list.d/thanos.list
|
echo "deb [arch=amd64] https://repo.thanos.io/deb all main" | tee /etc/apt/sources.list.d/thanos.list
|
||||||
apt-get update -y
|
apt-get update -y
|
||||||
apt-get install -y promtail
|
apt-get install -y promtail
|
||||||
|
|
||||||
# Enable and start Loki and Promtail services
|
# Enable and start Loki and Promtail services
|
||||||
echo "Enabling and starting Loki and Promtail services..."
|
echo "Enabling and starting Loki and Promtail services..."
|
||||||
systemctl enable loki
|
systemctl enable loki
|
||||||
systemctl start loki
|
systemctl start loki
|
||||||
systemctl enable promtail
|
systemctl enable promtail
|
||||||
systemctl start promtail
|
systemctl start promtail
|
||||||
|
|
||||||
echo "Loki and Promtail installed and services started."
|
echo "Loki and Promtail installed and services started."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check for sudo/root privileges
|
# Check for sudo/root privileges
|
||||||
if [ "$(id -u)" != "0" ]; then
|
if [ "$(id -u)" != "0" ]; then
|
||||||
echo "Script must be run as root. Please enter your sudo password."
|
echo "Script must be run as root. Please enter your sudo password."
|
||||||
exec sudo bash "$0" "$@"
|
exec sudo bash "$0" "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Starting script as root."
|
echo "Starting script as root."
|
||||||
|
|
||||||
# Step 2: Install software-properties-common, apt-transport-https, wget
|
# Step 2: Install software-properties-common, apt-transport-https, wget
|
||||||
echo "Step 2: Installing software-properties-common, apt-transport-https, wget..."
|
echo "Step 2: Installing software-properties-common, apt-transport-https, wget..."
|
||||||
apt-get update -y
|
apt-get update -y
|
||||||
apt-get install -y software-properties-common apt-transport-https wget
|
apt-get install -y software-properties-common apt-transport-https wget
|
||||||
|
|
||||||
# Step 3: Add the official Grafana GPG key
|
# Step 3: Add the official Grafana GPG key
|
||||||
echo "Step 3: Adding the official Grafana GPG key..."
|
echo "Step 3: Adding the official Grafana GPG key..."
|
||||||
wget -q -O - https://packages.grafana.com/gpg.key | apt-key add -
|
wget -q -O - https://packages.grafana.com/gpg.key | apt-key add -
|
||||||
|
|
||||||
# Step 4: Add the official Grafana repository for Debian
|
# Step 4: Add the official Grafana repository for Debian
|
||||||
echo "Step 4: Adding the official Grafana repository..."
|
echo "Step 4: Adding the official Grafana repository..."
|
||||||
add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
|
add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
|
||||||
|
|
||||||
# Step 5: Run apt update
|
# Step 5: Run apt update
|
||||||
echo "Step 5: Updating package list..."
|
echo "Step 5: Updating package list..."
|
||||||
apt-get update -y
|
apt-get update -y
|
||||||
|
|
||||||
# Step 6: Install both Grafana & Prometheus
|
# Step 6: Install both Grafana & Prometheus
|
||||||
echo "Step 6: Installing Grafana and Prometheus..."
|
echo "Step 6: Installing Grafana and Prometheus..."
|
||||||
apt-get install -y grafana prometheus
|
apt-get install -y grafana prometheus
|
||||||
|
|
||||||
# Step 7: Edit the Grafana config file to change the default port
|
# Step 7: Edit the Grafana config file to change the default port
|
||||||
echo "Step 7: Changing Grafana port from 3000 to 3100..."
|
echo "Step 7: Changing Grafana port from 3000 to 3100..."
|
||||||
sed -i 's/;http_port = 3000/http_port = 3100/' /etc/grafana/grafana.ini
|
sed -i 's/;http_port = 3000/http_port = 3100/' /etc/grafana/grafana.ini
|
||||||
|
|
||||||
# Step 8: Install and enable both Grafana and Prometheus as systemctl services
|
# Step 8: Install and enable both Grafana and Prometheus as systemctl services
|
||||||
echo "Step 8: Enabling and starting Grafana and Prometheus services..."
|
echo "Step 8: Enabling and starting Grafana and Prometheus services..."
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable grafana-server
|
systemctl enable grafana-server
|
||||||
systemctl start grafana-server
|
systemctl start grafana-server
|
||||||
systemctl enable prometheus
|
systemctl enable prometheus
|
||||||
systemctl start prometheus
|
systemctl start prometheus
|
||||||
|
|
||||||
# Step 9: Wait 2 minutes, then check both services are running successfully
|
# Step 9: Wait 2 minutes, then check both services are running successfully
|
||||||
echo "Step 9: Waiting 2 minutes to check service statuses..."
|
echo "Step 9: Waiting 2 minutes to check service statuses..."
|
||||||
sleep 120
|
sleep 120
|
||||||
|
|
||||||
GRAFANA_STATUS=$(systemctl is-active grafana-server)
|
GRAFANA_STATUS=$(systemctl is-active grafana-server)
|
||||||
PROMETHEUS_STATUS=$(systemctl is-active prometheus)
|
PROMETHEUS_STATUS=$(systemctl is-active prometheus)
|
||||||
|
|
||||||
if [ "$GRAFANA_STATUS" != "active" ] || [ "$PROMETHEUS_STATUS" != "active" ]; then
|
if [ "$GRAFANA_STATUS" != "active" ] || [ "$PROMETHEUS_STATUS" != "active" ]; then
|
||||||
echo "One or both services failed to start. Retrying in 2 minutes..."
|
echo "One or both services failed to start. Retrying in 2 minutes..."
|
||||||
sleep 120
|
sleep 120
|
||||||
systemctl restart grafana-server
|
systemctl restart grafana-server
|
||||||
systemctl restart prometheus
|
systemctl restart prometheus
|
||||||
fi
|
fi
|
||||||
|
|
||||||
GRAFANA_STATUS=$(systemctl is-active grafana-server)
|
GRAFANA_STATUS=$(systemctl is-active grafana-server)
|
||||||
PROMETHEUS_STATUS=$(systemctl is-active prometheus)
|
PROMETHEUS_STATUS=$(systemctl is-active prometheus)
|
||||||
|
|
||||||
if [ "$GRAFANA_STATUS" == "active" ] && [ "$PROMETHEUS_STATUS" == "active" ]; then
|
if [ "$GRAFANA_STATUS" == "active" ] && [ "$PROMETHEUS_STATUS" == "active" ]; then
|
||||||
echo "Both Grafana and Prometheus are running successfully."
|
echo "Both Grafana and Prometheus are running successfully."
|
||||||
echo "Grafana can be accessed on port 3100."
|
echo "Grafana can be accessed on port 3100."
|
||||||
|
|
||||||
# Prompt to install Loki and Promtail
|
# Prompt to install Loki and Promtail
|
||||||
read -p "Would you like to install Loki and Promtail as well? (yes/no): " INSTALL_LOKI_PROMTAIL
|
read -p "Would you like to install Loki and Promtail as well? (yes/no): " INSTALL_LOKI_PROMTAIL
|
||||||
if [ "$INSTALL_LOKI_PROMTAIL" == "yes" ] || [ "$INSTALL_LOKI_PROMTAIL" == "y" ]; then
|
if [ "$INSTALL_LOKI_PROMTAIL" == "yes" ] || [ "$INSTALL_LOKI_PROMTAIL" == "y" ]; then
|
||||||
install_loki_promtail
|
install_loki_promtail
|
||||||
else
|
else
|
||||||
echo "Skipping installation of Loki and Promtail."
|
echo "Skipping installation of Loki and Promtail."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Failed to start one or both services. Please check the logs for more information."
|
echo "Failed to start one or both services. Please check the logs for more information."
|
||||||
fi
|
fi
|
||||||
|
@ -1,139 +1,139 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Check if the script is being run as root
|
# Check if the script is being run as root
|
||||||
if [ "$(id -u)" -ne 0 ]; then
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
echo "This script must be run as root" 1>&2
|
echo "This script must be run as root" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Updating system..."
|
echo "Updating system..."
|
||||||
# Update the system
|
# Update the system
|
||||||
apt update && apt upgrade -y
|
apt update && apt upgrade -y
|
||||||
|
|
||||||
echo "Installing dependencies..."
|
echo "Installing dependencies..."
|
||||||
# Install prerequisites for Graylog, OpenSearch, and MongoDB
|
# Install prerequisites for Graylog, OpenSearch, and MongoDB
|
||||||
apt install -y apt-transport-https openjdk-11-jre-headless uuid-runtime pwgen wget gnupg
|
apt install -y apt-transport-https openjdk-11-jre-headless uuid-runtime pwgen wget gnupg
|
||||||
|
|
||||||
check_system_requirements() {
|
check_system_requirements() {
|
||||||
echo "Checking the minimum system requirements for Graylog..."
|
echo "Checking the minimum system requirements for Graylog..."
|
||||||
|
|
||||||
# Minimum required RAM (in MB)
|
# Minimum required RAM (in MB)
|
||||||
minimum_ram=4096
|
minimum_ram=4096
|
||||||
# Minimum required disk space (in GB)
|
# Minimum required disk space (in GB)
|
||||||
minimum_disk_space=50
|
minimum_disk_space=50
|
||||||
|
|
||||||
# Get total RAM in the system
|
# Get total RAM in the system
|
||||||
total_ram=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
|
total_ram=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
|
||||||
|
|
||||||
# Get total disk space in the system
|
# Get total disk space in the system
|
||||||
total_disk_space=$(df -BG --output=avail / | sed '1d' | awk '{print $1}' | sed 's/G//')
|
total_disk_space=$(df -BG --output=avail / | sed '1d' | awk '{print $1}' | sed 's/G//')
|
||||||
|
|
||||||
# Check if RAM meets the minimum requirements
|
# Check if RAM meets the minimum requirements
|
||||||
if [ "$total_ram" -lt "$minimum_ram" ]; then
|
if [ "$total_ram" -lt "$minimum_ram" ]; then
|
||||||
echo "Error: Insufficient RAM. Graylog requires a minimum of $minimum_ram MB of RAM."
|
echo "Error: Insufficient RAM. Graylog requires a minimum of $minimum_ram MB of RAM."
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "RAM: $total_ram MB - meets minimum requirements."
|
echo "RAM: $total_ram MB - meets minimum requirements."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if disk space meets the minimum requirements
|
# Check if disk space meets the minimum requirements
|
||||||
if [ "$total_disk_space" -lt "$minimum_disk_space" ]; then
|
if [ "$total_disk_space" -lt "$minimum_disk_space" ]; then
|
||||||
echo "Error: Insufficient disk space. Graylog requires a minimum of $minimum_disk_space GB of available disk space."
|
echo "Error: Insufficient disk space. Graylog requires a minimum of $minimum_disk_space GB of available disk space."
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "Disk space: $total_disk_space GB - meets minimum requirements."
|
echo "Disk space: $total_disk_space GB - meets minimum requirements."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "System meets the minimum requirements for Graylog."
|
echo "System meets the minimum requirements for Graylog."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Disable huge pages support
|
# Disable huge pages support
|
||||||
echo "Disabling huge pages support..."
|
echo "Disabling huge pages support..."
|
||||||
echo never > /sys/kernel/mm/transparent_hugepage/enabled
|
echo never > /sys/kernel/mm/transparent_hugepage/enabled
|
||||||
echo never > /sys/kernel/mm/transparent_hugepage/defrag
|
echo never > /sys/kernel/mm/transparent_hugepage/defrag
|
||||||
|
|
||||||
# Set maximum file count for OpenSearch
|
# Set maximum file count for OpenSearch
|
||||||
echo "Setting maximum file count for OpenSearch..."
|
echo "Setting maximum file count for OpenSearch..."
|
||||||
sysctl -w vm.max_map_count=262144
|
sysctl -w vm.max_map_count=262144
|
||||||
echo "vm.max_map_count=262144" >> /etc/sysctl.conf
|
echo "vm.max_map_count=262144" >> /etc/sysctl.conf
|
||||||
|
|
||||||
# Add the OpenSearch repository and its GPG key
|
# Add the OpenSearch repository and its GPG key
|
||||||
echo "Adding OpenSearch repository..."
|
echo "Adding OpenSearch repository..."
|
||||||
curl -o- https://artifacts.opensearch.org/publickeys/opensearch.pgp | gpg --dearmor --batch --yes -o /usr/share/keyrings/opensearch-keyring
|
curl -o- https://artifacts.opensearch.org/publickeys/opensearch.pgp | gpg --dearmor --batch --yes -o /usr/share/keyrings/opensearch-keyring
|
||||||
echo "deb [signed-by=/usr/share/keyrings/opensearch-keyring] https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/apt stable main" | tee /etc/apt/sources.list.d/opensearch-2.x.list
|
echo "deb [signed-by=/usr/share/keyrings/opensearch-keyring] https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/apt stable main" | tee /etc/apt/sources.list.d/opensearch-2.x.list
|
||||||
|
|
||||||
# Add the MongoDB repository
|
# Add the MongoDB repository
|
||||||
echo "Adding MongoDB repository..."
|
echo "Adding MongoDB repository..."
|
||||||
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | apt-key add -
|
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | apt-key add -
|
||||||
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/debian buster/mongodb-org/6.0 main" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list
|
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/debian buster/mongodb-org/6.0 main" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list
|
||||||
|
|
||||||
# Add the Graylog repository and its GPG key
|
# Add the Graylog repository and its GPG key
|
||||||
echo "Adding Graylog repository..."
|
echo "Adding Graylog repository..."
|
||||||
wget -qO - https://packages.graylog2.org/repo/packages/graylog-5.3-repository_latest.deb | dpkg -i -
|
wget -qO - https://packages.graylog2.org/repo/packages/graylog-5.3-repository_latest.deb | dpkg -i -
|
||||||
|
|
||||||
# Update the package index again
|
# Update the package index again
|
||||||
echo "Updating package index..."
|
echo "Updating package index..."
|
||||||
apt update
|
apt update
|
||||||
|
|
||||||
#Add OpenSearch User
|
#Add OpenSearch User
|
||||||
echo "Adding Opensearch User"
|
echo "Adding Opensearch User"
|
||||||
adduser --system --disabled-password --disabled-login --home /var/empty --no-create-home --quiet --force-badname --group opensearch
|
adduser --system --disabled-password --disabled-login --home /var/empty --no-create-home --quiet --force-badname --group opensearch
|
||||||
|
|
||||||
# Install OpenSearch and MongoDB
|
# Install OpenSearch and MongoDB
|
||||||
echo "Installing OpenSearch"
|
echo "Installing OpenSearch"
|
||||||
apt install -y opensearch
|
apt install -y opensearch
|
||||||
|
|
||||||
#Create OpenSearch Directories
|
#Create OpenSearch Directories
|
||||||
mkdir -p /graylog/opensearch/data
|
mkdir -p /graylog/opensearch/data
|
||||||
mkdir /var/log/opensearch
|
mkdir /var/log/opensearch
|
||||||
|
|
||||||
#Extract Contents from tar
|
#Extract Contents from tar
|
||||||
tar -zxf opensearch-2.0.1-linux-x64.tar.gz
|
tar -zxf opensearch-2.0.1-linux-x64.tar.gz
|
||||||
mv opensearch-2.0.1/* /graylog/opensearch/
|
mv opensearch-2.0.1/* /graylog/opensearch/
|
||||||
|
|
||||||
#Create empty log file
|
#Create empty log file
|
||||||
sudo -u opensearch touch /var/log/opensearch/graylog.log
|
sudo -u opensearch touch /var/log/opensearch/graylog.log
|
||||||
|
|
||||||
#Set Permissions
|
#Set Permissions
|
||||||
chown -R opensearch:opensearch /graylog/opensearch/
|
chown -R opensearch:opensearch /graylog/opensearch/
|
||||||
chown -R opensearch:opensearch /var/log/opensearch
|
chown -R opensearch:opensearch /var/log/opensearch
|
||||||
chmod -R 2750 /graylog/opensearch/
|
chmod -R 2750 /graylog/opensearch/
|
||||||
chmod -R 2750 /var/log/opensearch/
|
chmod -R 2750 /var/log/opensearch/
|
||||||
|
|
||||||
# Add OpenSearch service and set it to start automatically
|
# Add OpenSearch service and set it to start automatically
|
||||||
echo "Adding OpenSearch service and enabling autostart..."
|
echo "Adding OpenSearch service and enabling autostart..."
|
||||||
systemctl enable opensearch
|
systemctl enable opensearch
|
||||||
systemctl start opensearch
|
systemctl start opensearch
|
||||||
|
|
||||||
#Install MongoDB
|
#Install MongoDB
|
||||||
echo "Installing MongoDB"
|
echo "Installing MongoDB"
|
||||||
sudo apt install -y MongoDB
|
sudo apt install -y MongoDB
|
||||||
|
|
||||||
# Install Graylog
|
# Install Graylog
|
||||||
echo "Installing Graylog..."
|
echo "Installing Graylog..."
|
||||||
apt install -y graylog-server
|
apt install -y graylog-server
|
||||||
|
|
||||||
# Prompt user to enter admin user password
|
# Prompt user to enter admin user password
|
||||||
read -sp "Enter your desired admin password for Graylog: " GRAYLOG_ADMIN_PASSWORD
|
read -sp "Enter your desired admin password for Graylog: " GRAYLOG_ADMIN_PASSWORD
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# Generate a secret key for Graylog
|
# Generate a secret key for Graylog
|
||||||
echo "Generating secret key for Graylog..."
|
echo "Generating secret key for Graylog..."
|
||||||
GRAYLOG_SECRET=$(pwgen -N 1 -s 96)
|
GRAYLOG_SECRET=$(pwgen -N 1 -s 96)
|
||||||
sed -i "s/password_secret =.*/password_secret = $GRAYLOG_SECRET/" /etc/graylog/server/server.conf
|
sed -i "s/password_secret =.*/password_secret = $GRAYLOG_SECRET/" /etc/graylog/server/server.conf
|
||||||
|
|
||||||
# Generate a hash password for the admin user
|
# Generate a hash password for the admin user
|
||||||
echo "Generating hash password for the admin user..."
|
echo "Generating hash password for the admin user..."
|
||||||
GRAYLOG_PASSWORD=$(echo -n "$GRAYLOG_ADMIN_PASSWORD" | sha256sum | awk '{print $1}')
|
GRAYLOG_PASSWORD=$(echo -n "$GRAYLOG_ADMIN_PASSWORD" | sha256sum | awk '{print $1}')
|
||||||
sed -i "s/root_password_sha2 =.*/root_password_sha2 = $GRAYLOG_PASSWORD/" /etc/graylog/server/server.conf
|
sed -i "s/root_password_sha2 =.*/root_password_sha2 = $GRAYLOG_PASSWORD/" /etc/graylog/server/server.conf
|
||||||
|
|
||||||
# Reload systemd
|
# Reload systemd
|
||||||
echo "Reloading systemd..."
|
echo "Reloading systemd..."
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
|
||||||
# Enable and start Graylog service
|
# Enable and start Graylog service
|
||||||
echo "Enabling and starting Graylog service..."
|
echo "Enabling and starting Graylog service..."
|
||||||
systemctl enable graylog-server
|
systemctl enable graylog-server
|
||||||
systemctl start graylog-server
|
systemctl start graylog-server
|
||||||
|
|
||||||
echo "Graylog installation complete. You can access it at http://your-server-ip:9000"
|
echo "Graylog installation complete. You can access it at http://your-server-ip:9000"
|
@ -1,51 +1,51 @@
|
|||||||
# Requirements:
|
# Requirements:
|
||||||
|
|
||||||
This script makes no additional requirments other than the following. The script will automatically install all dependencies and make the additional required system modifications.
|
This script makes no additional requirments other than the following. The script will automatically install all dependencies and make the additional required system modifications.
|
||||||
|
|
||||||
# Installation:
|
# Installation:
|
||||||
|
|
||||||
To run this script:
|
To run this script:
|
||||||
|
|
||||||
1. Use wget to grab the latest version:
|
1. Use wget to grab the latest version:
|
||||||
|
|
||||||
`wget https://og.codes/oliver/install-scripts/raw/branch/master/graylog/install.sh`
|
`wget https://og.codes/oliver/install-scripts/raw/branch/master/graylog/install.sh`
|
||||||
|
|
||||||
2. CHMOD the script to make it executable:
|
2. CHMOD the script to make it executable:
|
||||||
|
|
||||||
`sudo chmod +x install.sh`
|
`sudo chmod +x install.sh`
|
||||||
|
|
||||||
3. Run the script:
|
3. Run the script:
|
||||||
|
|
||||||
`sudo ./install.sh`
|
`sudo ./install.sh`
|
||||||
|
|
||||||
# Script Process:
|
# Script Process:
|
||||||
|
|
||||||
This script makes the following checks (in order):
|
This script makes the following checks (in order):
|
||||||
|
|
||||||
Checks the script is being run as root.
|
Checks the script is being run as root.
|
||||||
|
|
||||||
Installs required dependencies.
|
Installs required dependencies.
|
||||||
|
|
||||||
Checks the system meets the minimum system requirements.
|
Checks the system meets the minimum system requirements.
|
||||||
|
|
||||||
Disables Huge Pages Support if Enabled (OpenSearch).
|
Disables Huge Pages Support if Enabled (OpenSearch).
|
||||||
|
|
||||||
Sets Maximum File Count (OpenSearch).
|
Sets Maximum File Count (OpenSearch).
|
||||||
|
|
||||||
Adds all required respitory keys & Updates the package index.
|
Adds all required respitory keys & Updates the package index.
|
||||||
|
|
||||||
Adds the OpenSearch user.
|
Adds the OpenSearch user.
|
||||||
|
|
||||||
Installs OpenSearch.
|
Installs OpenSearch.
|
||||||
|
|
||||||
Creates required OpenSearch directories & log file. Ensures their permissions.
|
Creates required OpenSearch directories & log file. Ensures their permissions.
|
||||||
|
|
||||||
Installs MongoDB.
|
Installs MongoDB.
|
||||||
|
|
||||||
Installs Graylog
|
Installs Graylog
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,201 +1,201 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Check if running as root
|
# Check if running as root
|
||||||
if [[ $EUID -ne 0 ]]; then
|
if [[ $EUID -ne 0 ]]; then
|
||||||
echo "This script must be run as root"
|
echo "This script must be run as root"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update and upgrade the system
|
# Update and upgrade the system
|
||||||
echo "Updating and upgrading the system..."
|
echo "Updating and upgrading the system..."
|
||||||
apt update && apt upgrade -y
|
apt update && apt upgrade -y
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
echo "Installing dependencies..."
|
echo "Installing dependencies..."
|
||||||
apt install -y python3 python3-pip python3-dev build-essential libxml2 libxml2-dev libxslt1-dev libffi-dev graphviz git libpq-dev libssl-dev redis-server postgresql postgresql-contrib nginx
|
apt install -y python3 python3-pip python3-dev build-essential libxml2 libxml2-dev libxslt1-dev libffi-dev graphviz git libpq-dev libssl-dev redis-server postgresql postgresql-contrib nginx
|
||||||
|
|
||||||
# Check Python version
|
# Check Python version
|
||||||
echo "Checking Python version. Please ensure this meets the minimum requirements of Python 3.8, 3.9, 3.10 or 3.11.:"
|
echo "Checking Python version. Please ensure this meets the minimum requirements of Python 3.8, 3.9, 3.10 or 3.11.:"
|
||||||
python3 --version
|
python3 --version
|
||||||
|
|
||||||
# Prompt user to confirm if the currently installed Python version meets the minimum requirements
|
# Prompt user to confirm if the currently installed Python version meets the minimum requirements
|
||||||
read -p "Does the installed Python version meet the minimum requirements of Python 3.8, 3.9, 3.10 or 3.11.? (y/n): " PYTHON_CONFIRM
|
read -p "Does the installed Python version meet the minimum requirements of Python 3.8, 3.9, 3.10 or 3.11.? (y/n): " PYTHON_CONFIRM
|
||||||
if [[ $PYTHON_CONFIRM != "y" ]]; then
|
if [[ $PYTHON_CONFIRM != "y" ]]; then
|
||||||
echo "Minimum Python version requirement confirmed!"
|
echo "Minimum Python version requirement confirmed!"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check other system requirements
|
# Check other system requirements
|
||||||
echo "Checking the system meets the minimum requirements..."
|
echo "Checking the system meets the minimum requirements..."
|
||||||
RAM=$(free -m | awk '/Mem/ {print $2}')
|
RAM=$(free -m | awk '/Mem/ {print $2}')
|
||||||
CPU=$(grep -c ^processor /proc/cpuinfo)
|
CPU=$(grep -c ^processor /proc/cpuinfo)
|
||||||
DISK=$(df -h / | awk 'NR==2 {print $4}')
|
DISK=$(df -h / | awk 'NR==2 {print $4}')
|
||||||
MIN_RAM=2048 # Minimum RAM in MB
|
MIN_RAM=2048 # Minimum RAM in MB
|
||||||
MIN_CPU=2 # Minimum CPU cores
|
MIN_CPU=2 # Minimum CPU cores
|
||||||
MIN_DISK=10 # Minimum free disk space in GB
|
MIN_DISK=10 # Minimum free disk space in GB
|
||||||
|
|
||||||
# Check RAM
|
# Check RAM
|
||||||
if [ "$RAM" -lt "$MIN_RAM" ]; then
|
if [ "$RAM" -lt "$MIN_RAM" ]; then
|
||||||
echo "Error: Insufficient RAM. At least $MIN_RAM MB of RAM is required."
|
echo "Error: Insufficient RAM. At least $MIN_RAM MB of RAM is required."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check CPU cores
|
# Check CPU cores
|
||||||
if [ "$CPU" -lt "$MIN_CPU" ]; then
|
if [ "$CPU" -lt "$MIN_CPU" ]; then
|
||||||
echo "Error: Insufficient CPU cores. At least $MIN_CPU CPU cores are required."
|
echo "Error: Insufficient CPU cores. At least $MIN_CPU CPU cores are required."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check disk space
|
# Check disk space
|
||||||
DISK_NUM=$(echo "$DISK" | grep -o -E '[0-9]+')
|
DISK_NUM=$(echo "$DISK" | grep -o -E '[0-9]+')
|
||||||
DISK_UNIT=$(echo "$DISK" | grep -o -E '[A-Za-z]+')
|
DISK_UNIT=$(echo "$DISK" | grep -o -E '[A-Za-z]+')
|
||||||
if [ "$DISK_UNIT" == "G" ]; then
|
if [ "$DISK_UNIT" == "G" ]; then
|
||||||
if [ "$DISK_NUM" -lt "$MIN_DISK" ]; then
|
if [ "$DISK_NUM" -lt "$MIN_DISK" ]; then
|
||||||
echo "Error: Insufficient disk space. At least $MIN_DISK GB of free disk space is required."
|
echo "Error: Insufficient disk space. At least $MIN_DISK GB of free disk space is required."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Error: Unsupported disk space unit. Please ensure disk space is at least 10GB."
|
echo "Error: Unsupported disk space unit. Please ensure disk space is at least 10GB."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "System meets minimum requirements. Proceeding with installation..."
|
echo "System meets minimum requirements. Proceeding with installation..."
|
||||||
|
|
||||||
# Download the latest version of netbox and unzip it
|
# Download the latest version of netbox and unzip it
|
||||||
echo "Downloading latest version of Netbox and moving files..."
|
echo "Downloading latest version of Netbox and moving files..."
|
||||||
sudo wget https://github.com/netbox-community/netbox/archive/refs/tags/vX.Y.Z.tar.gz
|
sudo wget https://github.com/netbox-community/netbox/archive/refs/tags/vX.Y.Z.tar.gz
|
||||||
sudo tar -xzf vX.Y.Z.tar.gz -C /opt
|
sudo tar -xzf vX.Y.Z.tar.gz -C /opt
|
||||||
sudo ln -s /opt/netbox-X.Y.Z/ /opt/netbox
|
sudo ln -s /opt/netbox-X.Y.Z/ /opt/netbox
|
||||||
|
|
||||||
# Prompt user for PostgreSQL and Netbox password
|
# Prompt user for PostgreSQL and Netbox password
|
||||||
read -p "Enter PostgreSQL password for 'netbox' user: " PG_PASSWORD
|
read -p "Enter PostgreSQL password for 'netbox' user: " PG_PASSWORD
|
||||||
read -p "Enter password for Netbox application: " NETBOX_PASSWORD
|
read -p "Enter password for Netbox application: " NETBOX_PASSWORD
|
||||||
|
|
||||||
# Create PostgreSQL user and database
|
# Create PostgreSQL user and database
|
||||||
echo "Creating PostgreSQL user and database..."
|
echo "Creating PostgreSQL user and database..."
|
||||||
sudo -u postgres psql -c "CREATE DATABASE netbox;"
|
sudo -u postgres psql -c "CREATE DATABASE netbox;"
|
||||||
sudo -u postgres psql -c "CREATE USER netbox WITH PASSWORD '$PG_PASSWORD';"
|
sudo -u postgres psql -c "CREATE USER netbox WITH PASSWORD '$PG_PASSWORD';"
|
||||||
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;"
|
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;"
|
||||||
|
|
||||||
# Create new user for Netbox
|
# Create new user for Netbox
|
||||||
echo "Creating new user for Netbox..."
|
echo "Creating new user for Netbox..."
|
||||||
useradd -m -s /bin/bash netbox
|
useradd -m -s /bin/bash netbox
|
||||||
|
|
||||||
# Install Netbox
|
# Install Netbox
|
||||||
echo "Installing Netbox..."
|
echo "Installing Netbox..."
|
||||||
apt update
|
apt update
|
||||||
apt install -y netbox
|
apt install -y netbox
|
||||||
|
|
||||||
# Move into NetBox configuration directory and make a copy of configuration_example.py
|
# Move into NetBox configuration directory and make a copy of configuration_example.py
|
||||||
echo "Copying Netbox configuration file..."
|
echo "Copying Netbox configuration file..."
|
||||||
cd /opt/netbox/netbox/netbox/
|
cd /opt/netbox/netbox/netbox/
|
||||||
cp configuration.example.py configuration.py
|
cp configuration.example.py configuration.py
|
||||||
|
|
||||||
# Populate database fields in configuration.py with PostgreSQL information
|
# Populate database fields in configuration.py with PostgreSQL information
|
||||||
echo "Populating the Netbox configuration file with prior PostgreSQL information..."
|
echo "Populating the Netbox configuration file with prior PostgreSQL information..."
|
||||||
sed -i "s/'USER': '',/'USER': 'netbox',/g" configuration.py
|
sed -i "s/'USER': '',/'USER': 'netbox',/g" configuration.py
|
||||||
sed -i "s/'NAME': '',/'NAME': 'netbox',/g" configuration.py
|
sed -i "s/'NAME': '',/'NAME': 'netbox',/g" configuration.py
|
||||||
sed -i "s/'PASSWORD': '',/'PASSWORD': '$PG_PASSWORD',/g" configuration.py
|
sed -i "s/'PASSWORD': '',/'PASSWORD': '$PG_PASSWORD',/g" configuration.py
|
||||||
sed -i "s/'HOST': '',/'HOST': 'localhost',/g" configuration.py
|
sed -i "s/'HOST': '',/'HOST': 'localhost',/g" configuration.py
|
||||||
|
|
||||||
# Generate secret key and parse it into configuration.py
|
# Generate secret key and parse it into configuration.py
|
||||||
echo "Generating secret key..."
|
echo "Generating secret key..."
|
||||||
SECRET_KEY=$(python3 /opt/netbox/generate_secret_key.py)
|
SECRET_KEY=$(python3 /opt/netbox/generate_secret_key.py)
|
||||||
sed -i "s/SECRET_KEY = ''/SECRET_KEY = '$SECRET_KEY'/g" configuration.py
|
sed -i "s/SECRET_KEY = ''/SECRET_KEY = '$SECRET_KEY'/g" configuration.py
|
||||||
|
|
||||||
# Prompt user to enter ALLOWED_HOSTS
|
# Prompt user to enter ALLOWED_HOSTS
|
||||||
echo "Please enter manually input the following inforation..."
|
echo "Please enter manually input the following inforation..."
|
||||||
read -p "Enter ALLOWED_HOSTS (separated by commas): " ALLOWED_HOSTS
|
read -p "Enter ALLOWED_HOSTS (separated by commas): " ALLOWED_HOSTS
|
||||||
|
|
||||||
# Parse user input into configuration.py
|
# Parse user input into configuration.py
|
||||||
echo "Parsing the entered information to configuration.py..."
|
echo "Parsing the entered information to configuration.py..."
|
||||||
sed -i "s/ALLOWED_HOSTS = \[\]/ALLOWED_HOSTS = \[$ALLOWED_HOSTS\]/g" configuration.py
|
sed -i "s/ALLOWED_HOSTS = \[\]/ALLOWED_HOSTS = \[$ALLOWED_HOSTS\]/g" configuration.py
|
||||||
sed -i "s/SECRET_KEY = ''/SECRET_KEY = '$SECRET_KEY'/g" configuration.py
|
sed -i "s/SECRET_KEY = ''/SECRET_KEY = '$SECRET_KEY'/g" configuration.py
|
||||||
|
|
||||||
# Perform initial Netbox database migration
|
# Perform initial Netbox database migration
|
||||||
echo "Performing initial Netbox database migration..."
|
echo "Performing initial Netbox database migration..."
|
||||||
sudo -u netbox /opt/netbox/upgrade.sh
|
sudo -u netbox /opt/netbox/upgrade.sh
|
||||||
|
|
||||||
# Create directory for Netbox reports
|
# Create directory for Netbox reports
|
||||||
echo "Creating directory for Netbox reports..."
|
echo "Creating directory for Netbox reports..."
|
||||||
mkdir -p /opt/netbox/netbox/media/reports
|
mkdir -p /opt/netbox/netbox/media/reports
|
||||||
|
|
||||||
# Check if directories exist
|
# Check if directories exist
|
||||||
echo "Checking if directories exist..."
|
echo "Checking if directories exist..."
|
||||||
if [ ! -d "/opt/netbox/netbox/media/reports" ] || [ ! -d "/opt/netbox/netbox/media/" ] || [ ! -d "/opt/netbox/netbox/static/" ]; then
|
if [ ! -d "/opt/netbox/netbox/media/reports" ] || [ ! -d "/opt/netbox/netbox/media/" ] || [ ! -d "/opt/netbox/netbox/static/" ]; then
|
||||||
read -p "Required directories are missing. Do you want to create them? (y/n): " CREATE_DIRS
|
read -p "Required directories are missing. Do you want to create them? (y/n): " CREATE_DIRS
|
||||||
if [[ $CREATE_DIRS == "y" ]]; then
|
if [[ $CREATE_DIRS == "y" ]]; then
|
||||||
mkdir -p /opt/netbox/netbox/media/reports
|
mkdir -p /opt/netbox/netbox/media/reports
|
||||||
mkdir -p /opt/netbox/netbox/media/
|
mkdir -p /opt/netbox/netbox/media/
|
||||||
mkdir -p /opt/netbox/netbox/static/
|
mkdir -p /opt/netbox/netbox/static/
|
||||||
else
|
else
|
||||||
echo "Please create the required directories manually and rerun the script."
|
echo "Please create the required directories manually and rerun the script."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect static files
|
# Collect static files
|
||||||
echo "Collecting static files..."
|
echo "Collecting static files..."
|
||||||
sudo -u netbox /opt/netbox/manage.py collectstatic --no-input
|
sudo -u netbox /opt/netbox/manage.py collectstatic --no-input
|
||||||
|
|
||||||
# Enable plugin support
|
# Enable plugin support
|
||||||
echo "Enabling plugin support..."
|
echo "Enabling plugin support..."
|
||||||
echo "PLUGINS = []" >> /opt/netbox/netbox/configuration.py
|
echo "PLUGINS = []" >> /opt/netbox/netbox/configuration.py
|
||||||
|
|
||||||
# Prompt user to enter plugin names
|
# Prompt user to enter plugin names
|
||||||
read -p "Enter names of plugins to add (separated by commas, leave empty to skip): " PLUGIN_NAMES
|
read -p "Enter names of plugins to add (separated by commas, leave empty to skip): " PLUGIN_NAMES
|
||||||
|
|
||||||
# Add plugins to configuration file
|
# Add plugins to configuration file
|
||||||
if [ -n "$PLUGIN_NAMES" ]; then
|
if [ -n "$PLUGIN_NAMES" ]; then
|
||||||
IFS=',' read -ra PLUGINS <<< "$PLUGIN_NAMES"
|
IFS=',' read -ra PLUGINS <<< "$PLUGIN_NAMES"
|
||||||
for PLUGIN in "${PLUGINS[@]}"; do
|
for PLUGIN in "${PLUGINS[@]}"; do
|
||||||
echo "Adding plugin: $PLUGIN"
|
echo "Adding plugin: $PLUGIN"
|
||||||
echo " '$PLUGIN'," >> /opt/netbox/netbox/configuration.py
|
echo " '$PLUGIN'," >> /opt/netbox/netbox/configuration.py
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Prompt user to create a new superuser
|
# Prompt user to create a new superuser
|
||||||
echo "Please create a new superuser for Netbox:"
|
echo "Please create a new superuser for Netbox:"
|
||||||
sudo -u netbox /opt/netbox/manage.py createsuperuser
|
sudo -u netbox /opt/netbox/manage.py createsuperuser
|
||||||
|
|
||||||
# Set file and directory permissions
|
# Set file and directory permissions
|
||||||
echo "Setting file permissions..."
|
echo "Setting file permissions..."
|
||||||
chown -R netbox:netbox /opt/netbox/netbox/media
|
chown -R netbox:netbox /opt/netbox/netbox/media
|
||||||
chown -R netbox:netbox /opt/netbox/netbox/static
|
chown -R netbox:netbox /opt/netbox/netbox/static
|
||||||
chown -R netbox:netbox /opt/netbox/netbox/media/reports
|
chown -R netbox:netbox /opt/netbox/netbox/media/reports
|
||||||
|
|
||||||
# Enable and start services
|
# Enable and start services
|
||||||
echo "Enabling and starting services..."
|
echo "Enabling and starting services..."
|
||||||
systemctl enable netbox
|
systemctl enable netbox
|
||||||
systemctl enable redis-server
|
systemctl enable redis-server
|
||||||
systemctl enable postgresql
|
systemctl enable postgresql
|
||||||
systemctl start netbox
|
systemctl start netbox
|
||||||
systemctl start redis-server
|
systemctl start redis-server
|
||||||
systemctl start postgresql
|
systemctl start postgresql
|
||||||
|
|
||||||
# NGINX reverse proxy config
|
# NGINX reverse proxy config
|
||||||
echo "Example NGINX reverse proxy configuration for Netbox:"
|
echo "Example NGINX reverse proxy configuration for Netbox:"
|
||||||
echo "
|
echo "
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name netbox.example.com;
|
server_name netbox.example.com;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://localhost:8001;
|
proxy_pass http://localhost:8001;
|
||||||
proxy_set_header X-Forwarded-Host \$server_name;
|
proxy_set_header X-Forwarded-Host \$server_name;
|
||||||
proxy_set_header X-Real-IP \$remote_addr;
|
proxy_set_header X-Real-IP \$remote_addr;
|
||||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto \$scheme;
|
proxy_set_header X-Forwarded-Proto \$scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /static/ {
|
location /static/ {
|
||||||
alias /opt/netbox/netbox/static/;
|
alias /opt/netbox/netbox/static/;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /media/ {
|
location /media/ {
|
||||||
alias /opt/netbox/netbox/media/;
|
alias /opt/netbox/netbox/media/;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
|
||||||
echo "Netbox installation completed successfully!"
|
echo "Netbox installation completed successfully!"
|
@ -1,15 +1,15 @@
|
|||||||
To run this script:
|
To run this script:
|
||||||
|
|
||||||
1. Use wget to grab the latest version:
|
1. Use wget to grab the latest version:
|
||||||
|
|
||||||
`wget https://og.codes/oliver/install-scripts/raw/branch/master/netbox/install.sh`
|
`wget https://og.codes/oliver/install-scripts/raw/branch/master/netbox/install.sh`
|
||||||
|
|
||||||
2. CHMOD the script to make it executable:
|
2. CHMOD the script to make it executable:
|
||||||
|
|
||||||
`chmod +x install.sh`
|
`chmod +x install.sh`
|
||||||
|
|
||||||
3. Run the script:
|
3. Run the script:
|
||||||
|
|
||||||
`./install.sh`
|
`./install.sh`
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,77 +1,77 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Function to check if a command exists
|
# Function to check if a command exists
|
||||||
command_exists() {
|
command_exists() {
|
||||||
type "$1" &> /dev/null ;
|
type "$1" &> /dev/null ;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if the script is run as root
|
# Check if the script is run as root
|
||||||
if [ "$(id -u)" != "0" ]; then
|
if [ "$(id -u)" != "0" ]; then
|
||||||
echo "This script must be run as root. Please use sudo." 1>&2
|
echo "This script must be run as root. Please use sudo." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update and install necessary packages
|
# Update and install necessary packages
|
||||||
echo "Updating package list and installing necessary tools..."
|
echo "Updating package list and installing necessary tools..."
|
||||||
apt-get update && apt-get upgrade -y
|
apt-get update && apt-get upgrade -y
|
||||||
if command_exists lspci; then
|
if command_exists lspci; then
|
||||||
echo "lspci is already installed."
|
echo "lspci is already installed."
|
||||||
else
|
else
|
||||||
echo "Installing lspci..."
|
echo "Installing lspci..."
|
||||||
apt-get install pciutils -y
|
apt-get install pciutils -y
|
||||||
fi
|
fi
|
||||||
if command_exists grep; then
|
if command_exists grep; then
|
||||||
echo "grep is already installed."
|
echo "grep is already installed."
|
||||||
else
|
else
|
||||||
echo "Installing grep..."
|
echo "Installing grep..."
|
||||||
apt-get install grep -y
|
apt-get install grep -y
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Identify the GPU device you want to passthrough
|
# Identify the GPU device you want to passthrough
|
||||||
echo "Listing all PCI devices to identify your GPU:"
|
echo "Listing all PCI devices to identify your GPU:"
|
||||||
lspci
|
lspci
|
||||||
read -p "Enter the PCI ID of your GPU (e.g., 00:01.0): " gpu_id
|
read -p "Enter the PCI ID of your GPU (e.g., 00:01.0): " gpu_id
|
||||||
|
|
||||||
# Verify GPU identification
|
# Verify GPU identification
|
||||||
echo "Verifying GPU with lspci -k..."
|
echo "Verifying GPU with lspci -k..."
|
||||||
lspci -k | grep -i "$gpu_id"
|
lspci -k | grep -i "$gpu_id"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "GPU not found or incorrect ID entered." >&2
|
echo "GPU not found or incorrect ID entered." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Configure Proxmox for GPU passthrough
|
# Configure Proxmox for GPU passthrough
|
||||||
echo "Configuring Proxmox to enable GPU passthrough..."
|
echo "Configuring Proxmox to enable GPU passthrough..."
|
||||||
# Edit the VM configuration file, e.g., /etc/pve/qemu-server/YOUR_VM_ID.conf
|
# Edit the VM configuration file, e.g., /etc/pve/qemu-server/YOUR_VM_ID.conf
|
||||||
read -p "Enter the ID of the VM you want to configure (e.g., 100 for vm100): " vm_id
|
read -p "Enter the ID of the VM you want to configure (e.g., 100 for vm100): " vm_id
|
||||||
echo "Editing VM configuration file for GPU passthrough..."
|
echo "Editing VM configuration file for GPU passthrough..."
|
||||||
sed -i "/^[^#]*args=/ s/$/ --device $gpu_id/" /etc/pve/qemu-server/$vm_id.conf
|
sed -i "/^[^#]*args=/ s/$/ --device $gpu_id/" /etc/pve/qemu-server/$vm_id.conf
|
||||||
|
|
||||||
# Optionally, add the GPU to a specific PCI slot (useful if you have multiple GPUs)
|
# Optionally, add the GPU to a specific PCI slot (useful if you have multiple GPUs)
|
||||||
echo "Do you want to bind this GPU to a specific PCI slot in Proxmox? This might require creating a new VMDX file."
|
echo "Do you want to bind this GPU to a specific PCI slot in Proxmox? This might require creating a new VMDX file."
|
||||||
read -p "Type 'yes' or 'no': " response
|
read -p "Type 'yes' or 'no': " response
|
||||||
if [[ "$response" == "yes" ]]; then
|
if [[ "$response" == "yes" ]]; then
|
||||||
read -p "Enter the desired PCI slot (e.g., 00:02.0): " pci_slot
|
read -p "Enter the desired PCI slot (e.g., 00:02.0): " pci_slot
|
||||||
echo "Adding GPU to specified PCI slot..."
|
echo "Adding GPU to specified PCI slot..."
|
||||||
# You might need to create a new VMDX file or modify an existing one, this step depends on your Proxmox setup and version.
|
# You might need to create a new VMDX file or modify an existing one, this step depends on your Proxmox setup and version.
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Blacklist the GPU driver modules
|
# Blacklist the GPU driver modules
|
||||||
echo "Do you want to blacklist the GPU driver modules? This will prevent them from loading at boot."
|
echo "Do you want to blacklist the GPU driver modules? This will prevent them from loading at boot."
|
||||||
read -p "Type 'yes' or 'no': " response
|
read -p "Type 'yes' or 'no': " response
|
||||||
if [[ "$response" == "yes" ]]; then
|
if [[ "$response" == "yes" ]]; then
|
||||||
echo "Blacklisting GPU driver modules..."
|
echo "Blacklisting GPU driver modules..."
|
||||||
# Create a blacklist file for the relevant drivers
|
# Create a blacklist file for the relevant drivers
|
||||||
echo "${gpu_id}*" > /etc/modprobe.d/blacklist-gpu.conf
|
echo "${gpu_id}*" > /etc/modprobe.d/blacklist-gpu.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restart the VM for changes to take effect
|
# Restart the VM for changes to take effect
|
||||||
echo "Changes require restarting the VM. Please power off your VM:"
|
echo "Changes require restarting the VM. Please power off your VM:"
|
||||||
read -p "Enter the ID of the VM you want to restart (e.g., 100): " vm_id
|
read -p "Enter the ID of the VM you want to restart (e.g., 100): " vm_id
|
||||||
virsh shutdown $vm_id
|
virsh shutdown $vm_id
|
||||||
read -p "Power on the VM now? Type 'yes': " response
|
read -p "Power on the VM now? Type 'yes': " response
|
||||||
if [[ "$response" == "yes" ]]; then
|
if [[ "$response" == "yes" ]]; then
|
||||||
virsh start $vm_id
|
virsh start $vm_id
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "GPU passthrough setup is complete. Please check your VM for GPU functionality."
|
echo "GPU passthrough setup is complete. Please check your VM for GPU functionality."
|
@ -1,114 +1,114 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Color codes for echo statements
|
# Color codes for echo statements
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
GREEN='\033[0;32m'
|
GREEN='\033[0;32m'
|
||||||
YELLOW='\033[0;33m'
|
YELLOW='\033[0;33m'
|
||||||
NC='\033[0m' # No Color
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
# Function to display colored messages
|
# Function to display colored messages
|
||||||
echo_colored() {
|
echo_colored() {
|
||||||
local color=$1
|
local color=$1
|
||||||
shift
|
shift
|
||||||
echo -e "${color}$@$NC"
|
echo -e "${color}$@$NC"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Step 1: Ask for the number of nodes
|
# Step 1: Ask for the number of nodes
|
||||||
read -p "Enter the number of nodes in your K8S cluster: " num_nodes
|
read -p "Enter the number of nodes in your K8S cluster: " num_nodes
|
||||||
|
|
||||||
# Step 2: Gather node details and store them
|
# Step 2: Gather node details and store them
|
||||||
node_details=()
|
node_details=()
|
||||||
for ((i=1; i<=num_nodes; i++)); do
|
for ((i=1; i<=num_nodes; i++)); do
|
||||||
read -p "Enter IP address for node $i: " ip
|
read -p "Enter IP address for node $i: " ip
|
||||||
read -p "Enter SSH username for node $i: " user
|
read -p "Enter SSH username for node $i: " user
|
||||||
read -s -p "Enter SSH password for node $i: " password
|
read -s -p "Enter SSH password for node $i: " password
|
||||||
echo ""
|
echo ""
|
||||||
node_details+=("$ip:$user:$password")
|
node_details+=("$ip:$user:$password")
|
||||||
done
|
done
|
||||||
|
|
||||||
# Step 3: Display stored IP addresses and ask for confirmation
|
# Step 3: Display stored IP addresses and ask for confirmation
|
||||||
echo_colored "$GREEN" "Stored Node Details:"
|
echo_colored "$GREEN" "Stored Node Details:"
|
||||||
for detail in "${node_details[@]}"; do
|
for detail in "${node_details[@]}"; do
|
||||||
IFS=':' read -r -a split <<< "$detail"
|
IFS=':' read -r -a split <<< "$detail"
|
||||||
echo_colored "$YELLOW" "IP: ${split[0]}, User: ${split[1]}"
|
echo_colored "$YELLOW" "IP: ${split[0]}, User: ${split[1]}"
|
||||||
done
|
done
|
||||||
|
|
||||||
read -p "Are the above details correct? (yes/no): " confirm
|
read -p "Are the above details correct? (yes/no): " confirm
|
||||||
if [ "$confirm" != "yes" ]; then
|
if [ "$confirm" != "yes" ]; then
|
||||||
echo_colored "$RED" "Please edit your node details and run this script again."
|
echo_colored "$RED" "Please edit your node details and run this script again."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Step 4: Ask for the master node
|
# Step 4: Ask for the master node
|
||||||
read -p "Enter the IP address of the master node (control plane): " master_ip
|
read -p "Enter the IP address of the master node (control plane): " master_ip
|
||||||
|
|
||||||
# Function to execute commands on a remote node using SSH
|
# Function to execute commands on a remote node using SSH
|
||||||
ssh_cmd() {
|
ssh_cmd() {
|
||||||
local ip=$1
|
local ip=$1
|
||||||
local user=$2
|
local user=$2
|
||||||
local password=$3
|
local password=$3
|
||||||
shift 3
|
shift 3
|
||||||
sshpass -p "$password" ssh -o StrictHostKeyChecking=no "$user@$ip" "$@"
|
sshpass -p "$password" ssh -o StrictHostKeyChecking=no "$user@$ip" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Step 5: Update and upgrade all nodes, then reboot them
|
# Step 5: Update and upgrade all nodes, then reboot them
|
||||||
echo_colored "$GREEN" "Updating and upgrading all nodes..."
|
echo_colored "$GREEN" "Updating and upgrading all nodes..."
|
||||||
for detail in "${node_details[@]}"; do
|
for detail in "${node_details[@]}"; do
|
||||||
IFS=':' read -r -a split <<< "$detail"
|
IFS=':' read -r -a split <<< "$detail"
|
||||||
ssh_cmd "${split[0]}" "${split[1]}" "${split[2]}" "sudo apt update && sudo apt upgrade -y"
|
ssh_cmd "${split[0]}" "${split[1]}" "${split[2]}" "sudo apt update && sudo apt upgrade -y"
|
||||||
ssh_cmd "${split[0]}" "${split[1]}" "${split[2]}" "sudo reboot"
|
ssh_cmd "${split[0]}" "${split[1]}" "${split[2]}" "sudo reboot"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Step 6: Install K8S on the master node
|
# Step 6: Install K8S on the master node
|
||||||
echo_colored "$GREEN" "Installing Kubernetes on the master node..."
|
echo_colored "$GREEN" "Installing Kubernetes on the master node..."
|
||||||
master_ip_split=(${master_ip//:/ })
|
master_ip_split=(${master_ip//:/ })
|
||||||
sshpass -p "${master_ip_split[2]}" ssh -o StrictHostKeyChecking=no "${master_ip_split[1]}@${master_ip_split[0]}" << 'EOF'
|
sshpass -p "${master_ip_split[2]}" ssh -o StrictHostKeyChecking=no "${master_ip_split[1]}@${master_ip_split[0]}" << 'EOF'
|
||||||
sudo apt update
|
sudo apt update
|
||||||
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
|
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
|
||||||
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
|
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
|
||||||
deb https://apt.kubernetes.io/ kubernetes-xenial main
|
deb https://apt.kubernetes.io/ kubernetes-xenial main
|
||||||
EOF
|
EOF
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install -y kubelet=1.24.0-00 kubeadm=1.24.0-00 kubectl=1.24.0-00
|
sudo apt install -y kubelet=1.24.0-00 kubeadm=1.24.0-00 kubectl=1.24.0-00
|
||||||
sudo systemctl enable --now kubelet
|
sudo systemctl enable --now kubelet
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Step 7: Configure and restart Kubernetes services on the master node
|
# Step 7: Configure and restart Kubernetes services on the master node
|
||||||
echo_colored "$GREEN" "Configuring Kubernetes services on the master node..."
|
echo_colored "$GREEN" "Configuring Kubernetes services on the master node..."
|
||||||
read -p "Do you want to customize the port number? (yes/no): " custom_port
|
read -p "Do you want to customize the port number? (yes/no): " custom_port
|
||||||
if [ "$custom_port" == "yes" ]; then
|
if [ "$custom_port" == "yes" ]; then
|
||||||
read -p "Enter a custom port number: " k8s_port
|
read -p "Enter a custom port number: " k8s_port
|
||||||
else
|
else
|
||||||
k8s_port=6443
|
k8s_port=6443
|
||||||
fi
|
fi
|
||||||
|
|
||||||
read -p "Do you want to specify a listening IP or domain? (yes/no): " listen_ip
|
read -p "Do you want to specify a listening IP or domain? (yes/no): " listen_ip
|
||||||
if [ "$listen_ip" == "yes" ]; then
|
if [ "$listen_ip" == "yes" ]; then
|
||||||
read -p "Enter the listening IP address or FQDN: " k8s_address
|
read -p "Enter the listening IP address or FQDN: " k8s_address
|
||||||
else
|
else
|
||||||
k8s_address=0.0.0.0
|
k8s_address=0.0.0.0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sshpass -p "${master_ip_split[2]}" ssh -o StrictHostKeyChecking=no "${master_ip_split[1]}@${master_ip_split[0]}" <<EOF
|
sshpass -p "${master_ip_split[2]}" ssh -o StrictHostKeyChecking=no "${master_ip_split[1]}@${master_ip_split[0]}" <<EOF
|
||||||
sudo sed -i "s/advertiseAddress: .*/advertiseAddress: $k8s_address/" /etc/kubernetes/manifests/kube-apiserver.yaml
|
sudo sed -i "s/advertiseAddress: .*/advertiseAddress: $k8s_address/" /etc/kubernetes/manifests/kube-apiserver.yaml
|
||||||
sudo sed -i "s/nodePort: 6443/nodePort: $k8s_port/" /etc/kubernetes/manifests/kube-apiserver.yaml
|
sudo sed -i "s/nodePort: 6443/nodePort: $k8s_port/" /etc/kubernetes/manifests/kube-apiserver.yaml
|
||||||
sudo systemctl restart kubelet
|
sudo systemctl restart kubelet
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Step 8: Install K8S on all nodes
|
# Step 8: Install K8S on all nodes
|
||||||
echo_colored "$GREEN" "Installing Kubernetes on all nodes..."
|
echo_colored "$GREEN" "Installing Kubernetes on all nodes..."
|
||||||
for detail in "${node_details[@]}"; do
|
for detail in "${node_details[@]}"; do
|
||||||
IFS=':' read -r -a split <<< "$detail"
|
IFS=':' read -r -a split <<< "$detail"
|
||||||
sshpass -p "${split[2]}" ssh -o StrictHostKeyChecking=no "${split[1]}@${split[0]}" << 'EOF'
|
sshpass -p "${split[2]}" ssh -o StrictHostKeyChecking=no "${split[1]}@${split[0]}" << 'EOF'
|
||||||
sudo apt update
|
sudo apt update
|
||||||
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
|
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
|
||||||
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
|
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
|
||||||
deb https://apt.kubernetes.io/ kubernetes-xenial main
|
deb https://apt.kubernetes.io/ kubernetes-xenial main
|
||||||
EOF
|
EOF
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install -y kubelet=1.24.0-00 kubeadm=1.24.0-00 kubectl=1.24.0-00
|
sudo apt install -y kubelet=1.24.0-00 kubeadm=1.24.0-00 kubectl=1.24.0-00
|
||||||
sudo systemctl enable --now kubelet
|
sudo systemctl enable --now kubelet
|
||||||
EOF
|
EOF
|
||||||
done
|
done
|
||||||
|
|
||||||
echo_colored "$GREEN" "Kubernetes cluster deployment completed successfully!"
|
echo_colored "$GREEN" "Kubernetes cluster deployment completed successfully!"
|
||||||
|
@ -1,136 +1,136 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# 1st Step - Ask user for no. of cluster nodes
|
# 1st Step - Ask user for no. of cluster nodes
|
||||||
echo "How many nodes would you like your cluster to have?"
|
echo "How many nodes would you like your cluster to have?"
|
||||||
read NODECOUNT
|
read NODECOUNT
|
||||||
|
|
||||||
# 2nd Step - Ask user for node details & store in tmp files
|
# 2nd Step - Ask user for node details & store in tmp files
|
||||||
for ((i=0; i < $NODECOUNT; i++))
|
for ((i=0; i < $NODECOUNT; i++))
|
||||||
do
|
do
|
||||||
echo "Please enter the IP address of the ${i}th node: "
|
echo "Please enter the IP address of the ${i}th node: "
|
||||||
read IPADDR_$i
|
read IPADDR_$i
|
||||||
echo "${IPADDR_$i}" > /tmp/node${i}_ip.txt
|
echo "${IPADDR_$i}" > /tmp/node${i}_ip.txt
|
||||||
|
|
||||||
echo "Please enter the username for SSH access to the ${i}th node (defaults to 'root'):"
|
echo "Please enter the username for SSH access to the ${i}th node (defaults to 'root'):"
|
||||||
read USERNAME_$i
|
read USERNAME_$i
|
||||||
if [ -z $USERNAME ]
|
if [ -z $USERNAME ]
|
||||||
then USERNAME="root";
|
then USERNAME="root";
|
||||||
fi
|
fi
|
||||||
echo "${USERNAME}" > /tmp/node${i}_user.txt
|
echo "${USERNAME}" > /tmp/node${i}_user.txt
|
||||||
|
|
||||||
echo "Please enter the password for SSH access to the ${i}th node (defaults to 'root'):"
|
echo "Please enter the password for SSH access to the ${i}th node (defaults to 'root'):"
|
||||||
read PASSWORD_$i
|
read PASSWORD_$i
|
||||||
if [ -z $PASSWORD ]
|
if [ -z $PASSWORD ]
|
||||||
then PASSWORD="root";
|
then PASSWORD="root";
|
||||||
fi
|
fi
|
||||||
echo "${PASSWORD}" > /tmp/node${i}_pass.txt
|
echo "${PASSWORD}" > /tmp/node${i}_pass.txt
|
||||||
done
|
done
|
||||||
|
|
||||||
# 3rd Step - Confirm node details with user & allow them to edit if necessary
|
# 3rd Step - Confirm node details with user & allow them to edit if necessary
|
||||||
echo "The following IP addresses were entered by the user:"
|
echo "The following IP addresses were entered by the user:"
|
||||||
for ((i=0; i < $NODECOUNT; i++))
|
for ((i=0; i < $NODECOUNT; i++))
|
||||||
do
|
do
|
||||||
echo "${IPADDR_$i}"
|
echo "${IPADDR_$i}"
|
||||||
done
|
done
|
||||||
read -p "Please confirm these are correct, or type 'edit' to make changes: " USERCONFIRMATION
|
read -p "Please confirm these are correct, or type 'edit' to make changes: " USERCONFIRMATION
|
||||||
if [ "$USERCONFIRMATION" == "edit" ]
|
if [ "$USERCONFIRMATION" == "edit" ]
|
||||||
then
|
then
|
||||||
for ((i=0; i < $NODECOUNT; i++))
|
for ((i=0; i < $NODECOUNT; i++))
|
||||||
do
|
do
|
||||||
echo "Please enter the IP address of the ${i}th node: "
|
echo "Please enter the IP address of the ${i}th node: "
|
||||||
read IPADDR_$i
|
read IPADDR_$i
|
||||||
echo "${IPADDR_$i}" > /tmp/node${i}_ip.txt
|
echo "${IPADDR_$i}" > /tmp/node${i}_ip.txt
|
||||||
|
|
||||||
echo "Please enter the username for SSH access to the ${i}th node (defaults to 'root'):"
|
echo "Please enter the username for SSH access to the ${i}th node (defaults to 'root'):"
|
||||||
read USERNAME_$i
|
read USERNAME_$i
|
||||||
if [ -z $USERNAME ]
|
if [ -z $USERNAME ]
|
||||||
then USERNAME="root";
|
then USERNAME="root";
|
||||||
fi
|
fi
|
||||||
echo "${USERNAME}" > /tmp/node${i}_user.txt
|
echo "${USERNAME}" > /tmp/node${i}_user.txt
|
||||||
|
|
||||||
echo "Please enter the password for SSH access to the ${i}th node (defaults to 'root'):"
|
echo "Please enter the password for SSH access to the ${i}th node (defaults to 'root'):"
|
||||||
read PASSWORD_$<s> i
|
read PASSWORD_$<s> i
|
||||||
if [ -z $PASSWORD ]
|
if [ -z $PASSWORD ]
|
||||||
then PASSWORD="root";
|
then PASSWORD="root";
|
||||||
fi
|
fi
|
||||||
echo "${PASSWORD}" > /tmp/node${i}_pass.txt
|
echo "${PASSWORD}" > /tmp/node${i}_pass.txt
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 4th Step - Ask user to define master node & store selection in tmp files
|
# 4th Step - Ask user to define master node & store selection in tmp files
|
||||||
echo "Please enter the number of the node you would like to define as your control plane (master):"
|
echo "Please enter the number of the node you would like to define as your control plane (master):"
|
||||||
read MASTERNODE_SELECTION
|
read MASTERNODE_SELECTION
|
||||||
echo "${MASTERNODE_SELECTION}" > /tmp/master.txt
|
echo "${MASTERNODE_SELECTION}" > /tmp/master.txt
|
||||||
|
|
||||||
# 5th Step - Add K8S repo & relevant keys to each node, install K8S & restart services
|
# 5th Step - Add K8S repo & relevant keys to each node, install K8S & restart services
|
||||||
for ((i=0; i < $NODECOUNT; i++))
|
for ((i=0; i < $NODECOUNT; i++))
|
||||||
do
|
do
|
||||||
echo "Adding Kubernetes repo to the system sources list on ${IPADDR_$i}..."
|
echo "Adding Kubernetes repo to the system sources list on ${IPADDR_$i}..."
|
||||||
ssh -n $USERNAME_$i@${IPADDR_$i} 'sudo sh -c "echo deb http://apt.kubernetes.io/ kubernetes-xenial main > /etc/apt/sources.list.d/kubernetes.list"'
|
ssh -n $USERNAME_$i@${IPADDR_$i} 'sudo sh -c "echo deb http://apt.kubernetes.io/ kubernetes-xenial main > /etc/apt/sources.list.d/kubernetes.list"'
|
||||||
|
|
||||||
echo "Adding GPG key to the system on ${IPADDR_$i}..."
|
echo "Adding GPG key to the system on ${IPADDR_$i}..."
|
||||||
ssh -n $USERNAME_$i@${IPADDR_$i} 'sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -'
|
ssh -n $USERNAME_$i@${IPADDR_$i} 'sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -'
|
||||||
|
|
||||||
echo "Updating package list on ${IPADDR_$i}..."
|
echo "Updating package list on ${IPADDR_$i}..."
|
||||||
ssh -n $USERNAME_$i@${IPADDR_$i} 'sudo sh -c "apt update"'
|
ssh -n $USERNAME_$i@${IPADDR_$i} 'sudo sh -c "apt update"'
|
||||||
|
|
||||||
echo "Upgrading packages on ${IPADDR_$i}..."
|
echo "Upgrading packages on ${IPADDR_$i}..."
|
||||||
ssh -n $USERNAME_$i@${IPADDR_$i} 'sudo sh -c "apt upgrade"'
|
ssh -n $USERNAME_$i@${IPADDR_$i} 'sudo sh -c "apt upgrade"'
|
||||||
done
|
done
|
||||||
|
|
||||||
# 6th Step - Install K8S on master node and ask for configuration options from user
|
# 6th Step - Install K8S on master node and ask for configuration options from user
|
||||||
echo "Installing Kubernetes on the master node..."
|
echo "Installing Kubernetes on the master node..."
|
||||||
ssh -n $USERNAME_$MASTERNODE_SELECTION@${IPADDR_$MASTERNODE_SELECTION} 'sudo sh -c "apt install kubeadm; apt-get install kubelet; apt-get install kubernetes-cni"'
|
ssh -n $USERNAME_$MASTERNODE_SELECTION@${IPADDR_$MASTERNODE_SELECTION} 'sudo sh -c "apt install kubeadm; apt-get install kubelet; apt-get install kubernetes-cni"'
|
||||||
|
|
||||||
echo "Please enter your preferred port number for the control plane (master node) (defaults to 6443): "
|
echo "Please enter your preferred port number for the control plane (master node) (defaults to 6443): "
|
||||||
read PORT_SELECTION
|
read PORT_SELECTION
|
||||||
if [ -z $PORT_SELECTION ]
|
if [ -z $PORT_SELECTION ]
|
||||||
then PORT_SELECTION="6443";
|
then PORT_SELECTION="6443";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Please enter your preferred IP address or FQDN for the control plane (master node) (defaults to '0.0.0.0'): "
|
echo "Please enter your preferred IP address or FQDN for the control plane (master node) (defaults to '0.0.0.0'): "
|
||||||
read IPADDRESS_SELECTION
|
read IPADDRESS_SELECTION
|
||||||
if [ -z $IPADDRESS_SELECTION ]
|
if [ -z $IPADDRESS_SELECTION ]
|
||||||
then IPADDRESS_SELECTION="0.0.0.0";
|
then IPADDRESS_SELECTION="0.0.0.0";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Configuring Kubernetes on the master node, using port ${PORT_SELECTION} and listening IP/domain ${IPADDRESS_SELECTION}..."
|
echo "Configuring Kubernetes on the master node, using port ${PORT_SELECTION} and listening IP/domain ${IPADDRESS_SELECTION}..."
|
||||||
ssh -n $USERNAME_$MASTERNODE_SELECTION@${IPADDR_$MASTERNODE_SELECTION} 'sudo sh -c "kubeadm init --apiserver-advertise-address=$IPADDRESS_SELECTION --apiserver-bind-port=$PORT_SELECTION"'
|
ssh -n $USERNAME_$MASTERNODE_SELECTION@${IPADDR_$MASTERNODE_SELECTION} 'sudo sh -c "kubeadm init --apiserver-advertise-address=$IPADDRESS_SELECTION --apiserver-bind-port=$PORT_SELECTION"'
|
||||||
|
|
||||||
echo "Please enter the following options to configure the Kubernetes control plane (master node)..."
|
echo "Please enter the following options to configure the Kubernetes control plane (master node)..."
|
||||||
echo "1. Pod Network CIDR: "
|
echo "1. Pod Network CIDR: "
|
||||||
read NETWORKCIDR_SELECTION
|
read NETWORKCIDR_SELECTION
|
||||||
echo "${NETWORKCIDR_SELECTION}" > /tmp/network.txt
|
echo "${NETWORKCIDR_SELECTION}" > /tmp/network.txt
|
||||||
|
|
||||||
echo "2. Service Subnet: "
|
echo "2. Service Subnet: "
|
||||||
read SERVICESUBNET_SELECTION
|
read SERVICESUBNET_SELECTION
|
||||||
echo "${SERVICESUBNET_SELECTION}" > /tmp/servicesubnet.txt
|
echo "${SERVICESUBNET_SELECTION}" > /tmp/servicesubnet.txt
|
||||||
|
|
||||||
echo "3. Kubernetes DNS Domain: "
|
echo "3. Kubernetes DNS Domain: "
|
||||||
read K8SDNS_SELECTION
|
read K8SDNS_SELECTION
|
||||||
echo "${K8SDNS_SELECTION}" > /tmp/kube-dns.txt
|
echo "${K8SDNS_SELECTION}" > /tmp/kube-dns.txt
|
||||||
|
|
||||||
echo "Please enter your preferred Kubernetes version (defaults to '1.20.1'): "
|
echo "Please enter your preferred Kubernetes version (defaults to '1.20.1'): "
|
||||||
read K8SVERSION_SELECTION
|
read K8SVERSION_SELECTION
|
||||||
if [ -z $K8SVERSION_SELECTION ]
|
if [ -z $K8SVERSION_SELECTION ]
|
||||||
then K8SVERSION_SELECTION="1.20.1";
|
then K8SVERSION_SELECTION="1.20.1";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Please enter your preferred pod Network provider (defaults to 'calico'): "
|
echo "Please enter your preferred pod Network provider (defaults to 'calico'): "
|
||||||
read NETWORKPROVIDER_SELECTION
|
read NETWORKPROVIDER_SELECTION
|
||||||
if [ -z $NETWORKPROVIDER_SELECT<s> ION_SELECTION ]
|
if [ -z $NETWORKPROVIDER_SELECT<s> ION_SELECTION ]
|
||||||
then NETWORKPROVIDER_SELECTION="calico";
|
then NETWORKPROVIDER_SELECTION="calico";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Configuring Kubernetes on the master node with pod Network CIDR: ${NETWORKCIDR_SELECTION}, service subnet: ${SERVICESUBNET_SELECTION}, K8S DNS domain: ${K8SDNS_SELECTION}, K8S version: ${K8SVERSION_SELECTION}, and pod network provider: ${NETWORKPROVIDER_SELECTION}..."
|
echo "Configuring Kubernetes on the master node with pod Network CIDR: ${NETWORKCIDR_SELECTION}, service subnet: ${SERVICESUBNET_SELECTION}, K8S DNS domain: ${K8SDNS_SELECTION}, K8S version: ${K8SVERSION_SELECTION}, and pod network provider: ${NETWORKPROVIDER_SELECTION}..."
|
||||||
ssh -n $USERNAME_$MASTERNODE_SELECTION@${IPADDR_$MASTERNODE_SELECTION} 'sudo sh -c "kubectl apply --kubelet-extra-args '--node-ip=$IPADDRESS_SELECTION' -f https://docs.projectcalico.org/manifests/kube-flannel.yaml; kubeadm init phase addon all; kubectl apply --kubelet-extra-args '--node-ip=$IPADDRESS_SELECTION' -f https://docs.projectcalico.org/manifests/kube-flannel.yaml; kubectl create deployment nginx-deployment --image=nginx; kubectl expose deployments nginx-deployment --port 80 --type LoadBalancer"'
|
ssh -n $USERNAME_$MASTERNODE_SELECTION@${IPADDR_$MASTERNODE_SELECTION} 'sudo sh -c "kubectl apply --kubelet-extra-args '--node-ip=$IPADDRESS_SELECTION' -f https://docs.projectcalico.org/manifests/kube-flannel.yaml; kubeadm init phase addon all; kubectl apply --kubelet-extra-args '--node-ip=$IPADDRESS_SELECTION' -f https://docs.projectcalico.org/manifests/kube-flannel.yaml; kubectl create deployment nginx-deployment --image=nginx; kubectl expose deployments nginx-deployment --port 80 --type LoadBalancer"'
|
||||||
|
|
||||||
echo "Restarting Kubernetes services on the master node..."
|
echo "Restarting Kubernetes services on the master node..."
|
||||||
ssh -n $USERNAME_$MASTERNODE_SELECTION@${IPADDR_$MASTERNODE_SELECTION} 'sudo sh -c "systemctl restart kubelet.service"'
|
ssh -n $USERNAME_$MASTERNODE_SELECTION@${IPADDR_$MASTERNODE_SELECTION} 'sudo sh -c "systemctl restart kubelet.service"'
|
||||||
|
|
||||||
echo "Restarting Kubernetes services on all nodes..."
|
echo "Restarting Kubernetes services on all nodes..."
|
||||||
for ((i=0; i < $NODECOUNT; i++))
|
for ((i=0; i < $NODECOUNT; i++))
|
||||||
do
|
do
|
||||||
echo "Restarting Kubernetes services on the ${IPADDR_$i} node..."
|
echo "Restarting Kubernetes services on the ${IPADDR_$i} node..."
|
||||||
ssh -n $USERNAME_$i@${IPADDR_$i} 'sudo sh -c "systemctl restart kubelet.service"'
|
ssh -n $USERNAME_$i@${IPADDR_$i} 'sudo sh -c "systemctl restart kubelet.service"'
|
||||||
done
|
done
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
Please generate me a bash script to deploy a Kubernetes cluster across multiple VM's. The script should complete every step for the user. Include colour coded echo statements to make it easy to use. It needs to include the following steps:
|
Please generate me a bash script to deploy a Kubernetes cluster across multiple VM's. The script should complete every step for the user. Include colour coded echo statements to make it easy to use. It needs to include the following steps:
|
||||||
|
|
||||||
1) Ask the user to input the number of nodes that are going to be part of the K8S cluster.
|
1) Ask the user to input the number of nodes that are going to be part of the K8S cluster.
|
||||||
|
|
||||||
2) Ask the user to input the IP's and SSH credentials for each node. The script needs to temporarily store these credentials in the linux tmp directory to use for the rest of this process. Following the users input, the script should then list all the previously inputed IP addresses and ask the user to confirm they are correct. If the user declares they are not, the script should offer them the option to go back and edit them before proceeding with the next step.
|
2) Ask the user to input the IP's and SSH credentials for each node. The script needs to temporarily store these credentials in the linux tmp directory to use for the rest of this process. Following the users input, the script should then list all the previously inputed IP addresses and ask the user to confirm they are correct. If the user declares they are not, the script should offer them the option to go back and edit them before proceeding with the next step.
|
||||||
|
|
||||||
3) It should then ask the user which node (by number or IP) they would like to define as the master node/control plane. All other nodes should be assumed to be worker nodes.
|
3) It should then ask the user which node (by number or IP) they would like to define as the master node/control plane. All other nodes should be assumed to be worker nodes.
|
||||||
|
|
||||||
4) It should then proceed to use the previously defined SSH credentials to log in to each node sequentially and add the K8S repository and relevant keys.
|
4) It should then proceed to use the previously defined SSH credentials to log in to each node sequentially and add the K8S repository and relevant keys.
|
||||||
|
|
||||||
5) Following this, it should log in to each node sequentially and prompt the user to escalate their session to sudo. It should then run the 'apt update' and 'apt upgrade', followed by the rebooting of each node. Following the successful execution of this task (and while the nodes are rebooting), the script should include a time delay of 5 minutes while displaying a countdown in seconds to allow each node to reboot.
|
5) Following this, it should log in to each node sequentially and prompt the user to escalate their session to sudo. It should then run the 'apt update' and 'apt upgrade', followed by the rebooting of each node. Following the successful execution of this task (and while the nodes are rebooting), the script should include a time delay of 5 minutes while displaying a countdown in seconds to allow each node to reboot.
|
||||||
|
|
||||||
6) It should then proceed to use the credentials of the corresponding node to install K8S on the master node initially. The install must add the official K8S repository to the system sources list and then run apt update before proceeding with the installation.
|
6) It should then proceed to use the credentials of the corresponding node to install K8S on the master node initially. The install must add the official K8S repository to the system sources list and then run apt update before proceeding with the installation.
|
||||||
|
|
||||||
7) Following the successful completion of the K8S installation, the script must then offer the user the following options in order to complete the K8S configuration. The script must parse the users choices to the relveant configuration files and then restart all K8S services.
|
7) Following the successful completion of the K8S installation, the script must then offer the user the following options in order to complete the K8S configuration. The script must parse the users choices to the relveant configuration files and then restart all K8S services.
|
||||||
|
|
||||||
1) Port number: The script must offer the user the option to define a custom port. If no choice is made the script should resort to the default.
|
1) Port number: The script must offer the user the option to define a custom port. If no choice is made the script should resort to the default.
|
||||||
|
|
||||||
2) Listening IP or domain: The script must offer the user the option to input the IP address or FQDN that K8S will listen on.
|
2) Listening IP or domain: The script must offer the user the option to input the IP address or FQDN that K8S will listen on.
|
||||||
|
|
||||||
8) After completing the installation of Kubernetes on the master node, the script must then proceed to add the official K8S repo to all the master nodes and then install K8S on each machine.
|
8) After completing the installation of Kubernetes on the master node, the script must then proceed to add the official K8S repo to all the master nodes and then install K8S on each machine.
|
||||||
|
@ -1,77 +1,77 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Function to display the main menu
|
# Function to display the main menu
|
||||||
function show_menu() {
|
function show_menu() {
|
||||||
clear
|
clear
|
||||||
echo "======================================"
|
echo "======================================"
|
||||||
echo " Proxmox Helper Script Installer"
|
echo " Proxmox Helper Script Installer"
|
||||||
echo "======================================"
|
echo "======================================"
|
||||||
echo "1. Install PVE-No-Subscription-Warning"
|
echo "1. Install PVE-No-Subscription-Warning"
|
||||||
echo "2. Install PVE Kernel Module Patcher"
|
echo "2. Install PVE Kernel Module Patcher"
|
||||||
echo "3. Install PVE VM Backup Script"
|
echo "3. Install PVE VM Backup Script"
|
||||||
echo "4. Exit"
|
echo "4. Exit"
|
||||||
echo "======================================"
|
echo "======================================"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to install the PVE No Subscription Warning script
|
# Function to install the PVE No Subscription Warning script
|
||||||
function install_pve_no_subscription_warning() {
|
function install_pve_no_subscription_warning() {
|
||||||
clear
|
clear
|
||||||
echo "Installing PVE-No-Subscription-Warning..."
|
echo "Installing PVE-No-Subscription-Warning..."
|
||||||
# Backup important configuration files
|
# Backup important configuration files
|
||||||
backup_file "/etc/apt/sources.list"
|
backup_file "/etc/apt/sources.list"
|
||||||
# Add your installation command here, for example:
|
# Add your installation command here, for example:
|
||||||
wget https://raw.githubusercontent.com/proxmox/pve-no-subscription-warning/master/pve-no-subscription-warning -O /usr/local/bin/pve-no-subscription-warning
|
wget https://raw.githubusercontent.com/proxmox/pve-no-subscription-warning/master/pve-no-subscription-warning -O /usr/local/bin/pve-no-subscription-warning
|
||||||
chmod +x /usr/local/bin/pve-no-subscription-warning
|
chmod +x /usr/local/bin/pve-no-subscription-warning
|
||||||
echo "PVE-No-Subscription-Warning installed successfully!"
|
echo "PVE-No-Subscription-Warning installed successfully!"
|
||||||
read -n 1 -s -r -p "Press any key to continue..."
|
read -n 1 -s -r -p "Press any key to continue..."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to install the PVE Kernel Module Patcher script
|
# Function to install the PVE Kernel Module Patcher script
|
||||||
function install_pve_kernel_module_patcher() {
|
function install_pve_kernel_module_patcher() {
|
||||||
clear
|
clear
|
||||||
echo "Installing PVE Kernel Module Patcher..."
|
echo "Installing PVE Kernel Module Patcher..."
|
||||||
# Backup important configuration files
|
# Backup important configuration files
|
||||||
backup_file "/etc/modprobe.d/proxmox-no-subscription.conf"
|
backup_file "/etc/modprobe.d/proxmox-no-subscription.conf"
|
||||||
# Add your installation command here, for example:
|
# Add your installation command here, for example:
|
||||||
wget https://raw.githubusercontent.com/olafm/proxmox-no-subscription-patch/master/pve-no-subscription-patch -O /usr/local/bin/pve-kernel-module-patcher
|
wget https://raw.githubusercontent.com/olafm/proxmox-no-subscription-patch/master/pve-no-subscription-patch -O /usr/local/bin/pve-kernel-module-patcher
|
||||||
chmod +x /usr/local/bin/pve-kernel-module-patcher
|
chmod +x /usr/local/bin/pve-kernel-module-patcher
|
||||||
echo "PVE Kernel Module Patcher installed successfully!"
|
echo "PVE Kernel Module Patcher installed successfully!"
|
||||||
read -n 1 -s -r -p "Press any key to continue..."
|
read -n 1 -s -r -p "Press any key to continue..."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to install the PVE VM Backup Script
|
# Function to install the PVE VM Backup Script
|
||||||
function install_pve_vm_backup_script() {
|
function install_pve_vm_backup_script() {
|
||||||
clear
|
clear
|
||||||
echo "Installing PVE VM Backup Script..."
|
echo "Installing PVE VM Backup Script..."
|
||||||
# Add your installation command here, for example:
|
# Add your installation command here, for example:
|
||||||
wget https://raw.githubusercontent.com/erikng/proxmox-scripts/master/backup-vm.sh -O /usr/local/bin/pve-vm-backup
|
wget https://raw.githubusercontent.com/erikng/proxmox-scripts/master/backup-vm.sh -O /usr/local/bin/pve-vm-backup
|
||||||
chmod +x /usr/local/bin/pve-vm-backup
|
chmod +x /usr/local/bin/pve-vm-backup
|
||||||
echo "PVE VM Backup Script installed successfully!"
|
echo "PVE VM Backup Script installed successfully!"
|
||||||
read -n 1 -s -r -p "Press any key to continue..."
|
read -n 1 -s -r -p "Press any key to continue..."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to backup files
|
# Function to backup files
|
||||||
function backup_file() {
|
function backup_file() {
|
||||||
local file=$1
|
local file=$1
|
||||||
if [ -f $file ]; then
|
if [ -f $file ]; then
|
||||||
local timestamp=$(date +%Y%m%d_%H%M%S)
|
local timestamp=$(date +%Y%m%d_%H%M%S)
|
||||||
local backup_file="/root/backup_$timestamp_$(basename $file)"
|
local backup_file="/root/backup_$timestamp_$(basename $file)"
|
||||||
echo "Backing up $file to $backup_file"
|
echo "Backing up $file to $backup_file"
|
||||||
rsync -a --delete $file $backup_file
|
rsync -a --delete $file $backup_file
|
||||||
else
|
else
|
||||||
echo "$file does not exist. Skipping backup."
|
echo "$file does not exist. Skipping backup."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main loop
|
# Main loop
|
||||||
while true; do
|
while true; do
|
||||||
show_menu
|
show_menu
|
||||||
read -p "Please enter your choice: " choice
|
read -p "Please enter your choice: " choice
|
||||||
case $choice in
|
case $choice in
|
||||||
1) install_pve_no_subscription_warning ;;
|
1) install_pve_no_subscription_warning ;;
|
||||||
2) install_pve_kernel_module_patcher ;;
|
2) install_pve_kernel_module_patcher ;;
|
||||||
3) install_pve_vm_backup_script ;;
|
3) install_pve_vm_backup_script ;;
|
||||||
4) exit 0 ;;
|
4) exit 0 ;;
|
||||||
*) echo "Invalid option. Please enter a number between 1 and 4." ;;
|
*) echo "Invalid option. Please enter a number between 1 and 4." ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
@ -1,82 +1,82 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# ASCII Art
|
# ASCII Art
|
||||||
echo "================================="
|
echo "================================="
|
||||||
echo " █████╗ ██╗ ██╗ ██╗ ██╗ ██╗███╗ ██╗███████╗████████╗ █████╗ ██╗ ██╗ ███████╗██████╗
|
echo " █████╗ ██╗ ██╗ ██╗ ██╗ ██╗███╗ ██╗███████╗████████╗ █████╗ ██╗ ██╗ ███████╗██████╗
|
||||||
██╔══██╗███║███║███║███║ ██║████╗ ██║██╔════╝╚══██╔══╝██╔══██╗██║ ██║ ██╔════╝██╔══██╗
|
██╔══██╗███║███║███║███║ ██║████╗ ██║██╔════╝╚══██╔══╝██╔══██╗██║ ██║ ██╔════╝██╔══██╗
|
||||||
███████║╚██║╚██║╚██║╚██║ ██║██╔██╗ ██║███████╗ ██║ ███████║██║ ██║ █████╗ ██████╔╝
|
███████║╚██║╚██║╚██║╚██║ ██║██╔██╗ ██║███████╗ ██║ ███████║██║ ██║ █████╗ ██████╔╝
|
||||||
██╔══██║ ██║ ██║ ██║ ██║ ██║██║╚██╗██║╚════██║ ██║ ██╔══██║██║ ██║ ██╔══╝ ██╔══██╗
|
██╔══██║ ██║ ██║ ██║ ██║ ██║██║╚██╗██║╚════██║ ██║ ██╔══██║██║ ██║ ██╔══╝ ██╔══██╗
|
||||||
██║ ██║ ██║ ██║ ██║ ██║ ██║██║ ╚████║███████║ ██║ ██║ ██║███████╗███████╗███████╗██║ ██║
|
██║ ██║ ██║ ██║ ██║ ██║ ██║██║ ╚████║███████║ ██║ ██║ ██║███████╗███████╗███████╗██║ ██║
|
||||||
╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝╚═╝ ╚═╝"
|
╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝╚═╝ ╚═╝"
|
||||||
echo "================================="
|
echo "================================="
|
||||||
|
|
||||||
# Function to install Nvidia CUDA toolkit
|
# Function to install Nvidia CUDA toolkit
|
||||||
install_cuda() {
|
install_cuda() {
|
||||||
echo "Step 1: Installing Nvidia CUDA Toolkit..."
|
echo "Step 1: Installing Nvidia CUDA Toolkit..."
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install -y nvidia-driver-550 cuda-toolkit
|
sudo apt install -y nvidia-driver-550 cuda-toolkit
|
||||||
echo "NVIDIA CUDA Toolkit installation completed."
|
echo "NVIDIA CUDA Toolkit installation completed."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to install dependencies for AUTOMATIC1111 Stable Diffusion
|
# Function to install dependencies for AUTOMATIC1111 Stable Diffusion
|
||||||
install_dependencies() {
|
install_dependencies() {
|
||||||
echo "Step 2: Installing required dependencies for AUTOMATIC1111 Stable Diffusion..."
|
echo "Step 2: Installing required dependencies for AUTOMATIC1111 Stable Diffusion..."
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install -y git libgl1-mesa-dev libfreetype6-dev pkg-config build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev curl wget
|
sudo apt install -y git libgl1-mesa-dev libfreetype6-dev pkg-config build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev curl wget
|
||||||
# Install Python 3.11 from source
|
# Install Python 3.11 from source
|
||||||
echo "Downloading and installing Python 3.11..."
|
echo "Downloading and installing Python 3.11..."
|
||||||
wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz
|
wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz
|
||||||
tar -xf Python-3.11.0.tgz
|
tar -xf Python-3.11.0.tgz
|
||||||
cd Python-3.11.0
|
cd Python-3.11.0
|
||||||
./configure --enable-optimizations
|
./configure --enable-optimizations
|
||||||
make -j $(nproc)
|
make -j $(nproc)
|
||||||
sudo make altinstall
|
sudo make altinstall
|
||||||
echo "Python 3.11 installation completed."
|
echo "Python 3.11 installation completed."
|
||||||
|
|
||||||
# Install pip and dependencies for stable-diffusion-webui
|
# Install pip and dependencies for stable-diffusion-webui
|
||||||
python3.11 -m pip install --upgrade pip
|
python3.11 -m pip install --upgrade pip
|
||||||
echo "Installing Python packages..."
|
echo "Installing Python packages..."
|
||||||
pip3.11 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu118
|
pip3.11 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu118
|
||||||
pip3.11 install gradio transformers diffusers
|
pip3.11 install gradio transformers diffusers
|
||||||
echo "Dependencies installation completed."
|
echo "Dependencies installation completed."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to clone and setup AUTOMATIC1111 Stable Diffusion web ui
|
# Function to clone and setup AUTOMATIC1111 Stable Diffusion web ui
|
||||||
install_stable_diffusion() {
|
install_stable_diffusion() {
|
||||||
echo "Step 3: Cloning AUTOMATIC1111 Stable Diffusion web UI..."
|
echo "Step 3: Cloning AUTOMATIC1111 Stable Diffusion web UI..."
|
||||||
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
|
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
|
||||||
cd stable-diffusion-webui
|
cd stable-diffusion-webui
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main menu
|
# Main menu
|
||||||
while true; do
|
while true; do
|
||||||
echo "=========================="
|
echo "=========================="
|
||||||
echo "AUTOMATIC1111 Stable Diffusion Installer"
|
echo "AUTOMATIC1111 Stable Diffusion Installer"
|
||||||
echo "=========================="
|
echo "=========================="
|
||||||
echo "Please select an option:"
|
echo "Please select an option:"
|
||||||
echo "1. Install Nvidia CUDA Toolkit (NVIDIA Driver 550)"
|
echo "1. Install Nvidia CUDA Toolkit (NVIDIA Driver 550)"
|
||||||
echo "2. Install required dependencies for AUTOMATIC1111 Stable Diffusion (Python 3.11)"
|
echo "2. Install required dependencies for AUTOMATIC1111 Stable Diffusion (Python 3.11)"
|
||||||
echo "3. Install AUTOMATIC1111 stable diffusion web ui itself"
|
echo "3. Install AUTOMATIC1111 stable diffusion web ui itself"
|
||||||
echo "4. Exit"
|
echo "4. Exit"
|
||||||
|
|
||||||
read -p "Enter your choice [1-4]: " choice
|
read -p "Enter your choice [1-4]: " choice
|
||||||
|
|
||||||
case $choice in
|
case $choice in
|
||||||
1)
|
1)
|
||||||
install_cuda
|
install_cuda
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
install_dependencies
|
install_dependencies
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
install_stable_diffusion
|
install_stable_diffusion
|
||||||
;;
|
;;
|
||||||
4)
|
4)
|
||||||
echo "Exiting..."
|
echo "Exiting..."
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Invalid option. Please try again."
|
echo "Invalid option. Please try again."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
@ -1,19 +1,19 @@
|
|||||||
# /etc/systemd/system/sd-webui.service
|
# /etc/systemd/system/sd-webui.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
|
|
||||||
ExecStart=/bin/bash /home/oliver/stable-diffusion-webui/webui.sh
|
ExecStart=/bin/bash /home/oliver/stable-diffusion-webui/webui.sh
|
||||||
Restart=always
|
Restart=always
|
||||||
WorkingDirectory=/home/oliver/stable-diffusion-webui
|
WorkingDirectory=/home/oliver/stable-diffusion-webui
|
||||||
StandardOutput=syslog
|
StandardOutput=syslog
|
||||||
StandardError=syslog
|
StandardError=syslog
|
||||||
SyslogIdentifier=sd-webui
|
SyslogIdentifier=sd-webui
|
||||||
User=oliver
|
User=oliver
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
||||||
# usage
|
# usage
|
||||||
#
|
#
|
||||||
# sudo mv sd-webui.service /etc/systemd/system/sd-webui.service
|
# sudo mv sd-webui.service /etc/systemd/system/sd-webui.service
|
||||||
# sudo systemctl start sd-webui
|
# sudo systemctl start sd-webui
|
@ -1,49 +1,49 @@
|
|||||||
Please write me a Windows 11 Powershell script that presents the user with a menu of the following options and executes the associated tasks. It should include echo statements to keep the user informed. Please also style the terminal interface to make it easy to use.
|
Please write me a Windows 11 Powershell script that presents the user with a menu of the following options and executes the associated tasks. It should include echo statements to keep the user informed. Please also style the terminal interface to make it easy to use.
|
||||||
|
|
||||||
The script should include the following options:
|
The script should include the following options:
|
||||||
|
|
||||||
1) Make the following modifications to Windows:
|
1) Make the following modifications to Windows:
|
||||||
|
|
||||||
1) Revert to the old explorer context menu.
|
1) Revert to the old explorer context menu.
|
||||||
|
|
||||||
2) Enable hidden files by default.
|
2) Enable hidden files by default.
|
||||||
|
|
||||||
3) Enable showing file extensions by default.
|
3) Enable showing file extensions by default.
|
||||||
|
|
||||||
2) The option to download and install the following system utilities. Users should be able to select/deselect which apps they would like installed before executing the task:
|
2) The option to download and install the following system utilities. Users should be able to select/deselect which apps they would like installed before executing the task:
|
||||||
|
|
||||||
1) OpenRGB
|
1) OpenRGB
|
||||||
|
|
||||||
2) FanControl
|
2) FanControl
|
||||||
|
|
||||||
3) System Informer
|
3) System Informer
|
||||||
|
|
||||||
4) WizTree
|
4) WizTree
|
||||||
|
|
||||||
5) Rustdesk (remote desktop software)
|
5) Rustdesk (remote desktop software)
|
||||||
|
|
||||||
6) XnViewMP (image viewer)
|
6) XnViewMP (image viewer)
|
||||||
|
|
||||||
7) Browsers:
|
7) Browsers:
|
||||||
|
|
||||||
1) Mozilla Firefox
|
1) Mozilla Firefox
|
||||||
|
|
||||||
2) Waterfox
|
2) Waterfox
|
||||||
|
|
||||||
3) Zen Browser
|
3) Zen Browser
|
||||||
|
|
||||||
4) Thorium
|
4) Thorium
|
||||||
|
|
||||||
5) Chromium
|
5) Chromium
|
||||||
|
|
||||||
6) Vivaldi
|
6) Vivaldi
|
||||||
|
|
||||||
8) UniGetUI (package manager)
|
8) UniGetUI (package manager)
|
||||||
|
|
||||||
9) ShareX
|
9) ShareX
|
||||||
|
|
||||||
10) Windhawk
|
10) Windhawk
|
||||||
|
|
||||||
3) Download an execute the MassGravel Windows Activation Script.
|
3) Download an execute the MassGravel Windows Activation Script.
|
||||||
|
|
||||||
4) Download and install Grafana, Prometheus, Windows Exporter and OHMGraphite. Make sure Prometheus is then configured to collect data from Windows Exporter and OHMGraphite.
|
4) Download and install Grafana, Prometheus, Windows Exporter and OHMGraphite. Make sure Prometheus is then configured to collect data from Windows Exporter and OHMGraphite.
|
||||||
|
Reference in New Issue
Block a user