Added a few and some fixes.

This commit is contained in:
2025-08-14 22:10:42 +01:00
parent cf94b48a42
commit 58ccdb5209
18 changed files with 1439 additions and 1439 deletions

View File

@ -1,27 +1,27 @@
#!/bin/sh
set -o errexit
set -o nounset
IFS=$(printf '\n\t')
# Docker
sudo apt remove --yes docker docker-engine docker.io containerd runc
sudo apt update
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 -
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 --yes --no-install-recommends install docker-ce docker-ce-cli containerd.io
sudo usermod --append --groups docker "$USER"
sudo systemctl enable docker
printf '\nDocker installed successfully\n\n'
printf 'Waiting for Docker to start...\n\n'
sleep 5
# 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 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"
printf '\nDocker Compose installed successfully\n\n'
#!/bin/sh
set -o errexit
set -o nounset
IFS=$(printf '\n\t')
# Docker
sudo apt remove --yes docker docker-engine docker.io containerd runc
sudo apt update
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 -
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 --yes --no-install-recommends install docker-ce docker-ce-cli containerd.io
sudo usermod --append --groups docker "$USER"
sudo systemctl enable docker
printf '\nDocker installed successfully\n\n'
printf 'Waiting for Docker to start...\n\n'
sleep 5
# 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 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"
printf '\nDocker Compose installed successfully\n\n'

View File

@ -1,17 +1,17 @@
# Useful Installation Scripts
A repo for useful install scripts for various software on Debian based distributions.
# **<u>Current Install Scripts:</u>**
- Graylog
- Netbox
- Docker with Portainer
##### **<u>Credits:</u>**
#### Ubuntu:
# Useful Installation Scripts
A repo for useful install scripts for various software on Debian based distributions.
# **<u>Current Install Scripts:</u>**
- Graylog
- Netbox
- Docker with Portainer
##### **<u>Credits:</u>**
#### Ubuntu:
- [A simple Docker and Docker Compose install script for Ubuntu · GitHub](https://gist.github.com/EvgenyOrekhov/1ed8a4466efd0a59d73a11d753c0167b)

View File

@ -1,88 +1,88 @@
#!/bin/bash
# Function to print a header with a description
print_header() {
echo "------------------------------------------------------------"
echo $1
}
# Check if pv is installed, and install it if necessary
check_and_install_pv() {
if ! command -v pv &> /dev/null; then
print_header "Installing Pipe Viewer (pv)"
sudo apt-get update -y
sudo apt-get install -y pv
else
print_header "Pipe Viewer (pv) is already installed"
fi
}
# Function to run a command with progress bar if `pv` is available
run_with_progress() {
local cmd="$1"
if command -v pv &> /dev/null; then
echo "$cmd | pv -l -p -t -e -r"
else
echo "Running: $cmd"
eval "$cmd"
fi
}
# Install required packages for Docker
print_header "Installing required packages..."
sudo apt-get update -y
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
# Add Dockers official GPG key with progress bar
check_and_install_pv
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
# Set up the stable repository for Docker
print_header "Setting up Docker repository..."
echo \
"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
# Update the package list again with progress bar
run_with_progress "sudo apt-get update"
# Install Docker CE (Community Edition)
print_header "Installing Docker CE..."
run_with_progress "sudo apt-get install -y docker-ce docker-ce-cli containerd.io"
# Verify that Docker is installed correctly
print_header "Starting and enabling Docker service..."
sudo systemctl start docker
sudo systemctl enable docker
# Download Docker Compose with progress bar
check_and_install_pv
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)
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
print_header "Checking installation of Docker Compose..."
sudo ln -sf /usr/local/bin/docker-compose /usr/bin/docker-compose
# Install Portainer and start it
print_header "Installing and starting Portainer..."
run_with_progress "curl -fL https://portainer.io/portainer.tar.gz | sudo tar xz -C /"
sudo mv /portainer/portainer /usr/local/bin/portainer
rm -rf /portainer
sudo chmod +x /usr/local/bin/portainer
# Run Portainer in detached mode
print_header "Starting Portainer..."
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
echo ""
echo "Portainer has been installed and started. You can access it at:"
#!/bin/bash
# Function to print a header with a description
print_header() {
echo "------------------------------------------------------------"
echo $1
}
# Check if pv is installed, and install it if necessary
check_and_install_pv() {
if ! command -v pv &> /dev/null; then
print_header "Installing Pipe Viewer (pv)"
sudo apt-get update -y
sudo apt-get install -y pv
else
print_header "Pipe Viewer (pv) is already installed"
fi
}
# Function to run a command with progress bar if `pv` is available
run_with_progress() {
local cmd="$1"
if command -v pv &> /dev/null; then
echo "$cmd | pv -l -p -t -e -r"
else
echo "Running: $cmd"
eval "$cmd"
fi
}
# Install required packages for Docker
print_header "Installing required packages..."
sudo apt-get update -y
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
# Add Dockers official GPG key with progress bar
check_and_install_pv
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
# Set up the stable repository for Docker
print_header "Setting up Docker repository..."
echo \
"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
# Update the package list again with progress bar
run_with_progress "sudo apt-get update"
# Install Docker CE (Community Edition)
print_header "Installing Docker CE..."
run_with_progress "sudo apt-get install -y docker-ce docker-ce-cli containerd.io"
# Verify that Docker is installed correctly
print_header "Starting and enabling Docker service..."
sudo systemctl start docker
sudo systemctl enable docker
# Download Docker Compose with progress bar
check_and_install_pv
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)
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
print_header "Checking installation of Docker Compose..."
sudo ln -sf /usr/local/bin/docker-compose /usr/bin/docker-compose
# Install Portainer and start it
print_header "Installing and starting Portainer..."
run_with_progress "curl -fL https://portainer.io/portainer.tar.gz | sudo tar xz -C /"
sudo mv /portainer/portainer /usr/local/bin/portainer
rm -rf /portainer
sudo chmod +x /usr/local/bin/portainer
# Run Portainer in detached mode
print_header "Starting Portainer..."
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
echo ""
echo "Portainer has been installed and started. You can access it at:"
echo "https://<your-server-ip>:9000"

View File

@ -1,15 +1,15 @@
To run this script:
1. Use wget to grab the latest version:
`wget https://og.codes/oliver/install-scripts/raw/branch/master/docker-with-portainer/install.sh`
2. CHMOD the script to make it executable:
`chmod +x install.sh`
3. Run the script:
`./install.sh`
To run this script:
1. Use wget to grab the latest version:
`wget https://og.codes/oliver/install-scripts/raw/branch/master/docker-with-portainer/install.sh`
2. CHMOD the script to make it executable:
`chmod +x install.sh`
3. Run the script:
`./install.sh`

View File

@ -1,217 +1,217 @@
#!/bin/bash
# Default versions
DEFAULT_PROMETHEUS_VERSION="3.1.0"
DEFAULT_NODE_EXPORTER_VERSION="1.8.2"
# Function to display menu and get user choices
function show_menu() {
echo "Please select the software you would like to install (multiple selections allowed):"
echo "1. Prometheus"
echo "2. Node Exporter"
echo "3. Grafana"
echo "4. Exit"
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 show_progress {
local total=$1
local current=$2
local percent=$((current * 100 / total))
printf "\r[%-70s] %d%%" "$(printf '#%.0s' $(seq 1 $percent))" "$percent"
}
# Function to download and install Prometheus
function install_prometheus() {
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}
echo "Chosen Prometheus version: $PROMETHEUS_VERSION"
DOWNLOAD_DIR="/tmp/prometheus-install"
PROMETHEUS_USER="prometheus"
PROMETHEUS_GROUP="prometheus"
PROMETHEUS_DIR="/usr/local/bin/prometheus"
CONFIG_DIR="/etc/prometheus"
DATA_DIR="/var/lib/prometheus"
echo "Creating download directory..."
mkdir -p $DOWNLOAD_DIR
echo "Downloading Prometheus binary..."
cd $DOWNLOAD_DIR
wget https://github.com/prometheus/prometheus/releases/download/v$PROMETHEUS_VERSION/prometheus-$PROMETHEUS_VERSION.linux-amd64.tar.gz
echo "Extracting Prometheus binary..."
tar xvfz prometheus-$PROMETHEUS_VERSION.linux-amd64.tar.gz
echo "Copying Prometheus binary to $PROMETHEUS_DIR..."
cp prometheus-$PROMETHEUS_VERSION.linux-amd64/prometheus $PROMETHEUS_DIR
echo "Copying promtool binary to /usr/local/bin"
sudo cp prometheus-$PROMETHEUS_VERSION.linux-amd64/promtool /usr/local/bin
echo "Creating Prometheus configuration file in $CONFIG_DIR..."
cat <<EOF > $CONFIG_DIR/prometheus.yml
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node_exporter'
static_configs:
- targets: ['localhost:9100']
EOF
echo "Creating $PROMETHEUS_USER user and group..."
sudo groupadd --system $PROMETHEUS_GROUP
sudo useradd -s /sbin/nologin --system -g $PROMETHEUS_GROUP $PROMETHEUS_USER
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 /usr/local/bin/prometheus
sudo chown -R $PROMETHEUS_USER:$PROMETHEUS_GROUP /usr/local/bin/node_exporter
echo "Creating systemd service for Prometheus..."
cat <<EOF | sudo tee /etc/systemd/system/prometheus.service > /dev/null
[Unit]
Description=Prometheus Time Series Database
Wants=network-online.target
After=network-online.target
[Service]
User=$PROMETHEUS_USER
Group=$PROMETHEUS_GROUP
Type=simple
ExecStart=/usr/local/bin/prometheus \
--config.file=$CONFIG_DIR/prometheus.yml \
--storage.tsdb.path=$DATA_DIR
Restart=always
[Install]
WantedBy=default.target
EOF
echo "Reloading systemd daemon..."
sudo systemctl daemon-reload
echo "Enabling Prometheus service..."
sudo systemctl enable prometheus.service
echo "Starting Prometheus service..."
sudo systemctl start prometheus.service
echo "Checking status of Prometheus service..."
systemctl status prometheus.service
}
# Function to download and 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
NODE_EXPORTER_VERSION=${NODE_EXPORTER_VERSION:-$DEFAULT_NODE_EXPORTER_VERSION}
echo "Chosen Node Exporter version: $NODE_EXPORTER_VERSION"
DOWNLOAD_DIR="/tmp/node-exporter-install"
PROMETHEUS_USER="prometheus"
PROMETHEUS_GROUP="prometheus"
BINARY_DIR="/usr/local/bin"
echo "Creating download directory..."
mkdir -p $DOWNLOAD_DIR
echo "Downloading Node Exporter binary..."
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
echo "Extracting Node Exporter binary..."
tar xvfz node_exporter-$NODE_EXPORTER_VERSION.linux-amd64.tar.gz
echo "Copying Node Exporter binary to $BINARY_DIR..."
sudo cp node_exporter-$NODE_EXPORTER_VERSION.linux-amd64/node_exporter $BINARY_DIR
echo "Creating systemd service for Node Exporter..."
cat <<EOF | sudo tee /etc/systemd/system/node_exporter.service > /dev/null
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=$PROMETHEUS_USER
Group=$PROMETHEUS_GROUP
Type=simple
ExecStart=/usr/local/bin/node_exporter
Restart=always
[Install]
WantedBy=default.target
EOF
echo "Reloading systemd daemon..."
sudo systemctl daemon-reload
echo "Enabling Node Exporter service..."
sudo systemctl enable node_exporter.service
echo "Starting Node Exporter service..."
sudo systemctl start node_exporter.service
echo "Checking status of Node Exporter service..."
systemctl status node_exporter.service
}
# Function to install Grafana
function install_grafana() {
echo "Installing Grafana using the official PPA..."
echo "Importing Grafana repository keyring..."
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "Adding Grafana repository..."
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
echo "Updating package list..."
sudo apt-get update
echo "Installing Grafana..."
sudo apt-get install -y grafana
echo "Enabling Grafana service..."
sudo systemctl enable grafana-server
echo "Starting Grafana service..."
sudo systemctl start grafana-server
echo "Checking status of Grafana service..."
systemctl status grafana-server
}
# Prompt for sudo password and validate it
sudo -v
# Main script execution
show_menu
# Convert the input choice to an array
IFS=',' read -r -a choices <<< "$choice"
# Execute selected installations with progress bar
for i in "${!choices[@]}"; do
case ${choices[$i]} in
1)
echo "Installing Prometheus..."
install_prometheus
;;
2)
echo "Installing Node Exporter..."
install_node_exporter
;;
3)
echo "Installing Grafana..."
install_grafana
;;
4)
echo "Exiting..."
exit 0
;;
*)
echo "Invalid choice: ${choices[$i]}. Skipping."
;;
esac
done
echo "Installation completed successfully!"
#!/bin/bash
# Default versions
DEFAULT_PROMETHEUS_VERSION="3.1.0"
DEFAULT_NODE_EXPORTER_VERSION="1.8.2"
# Function to display menu and get user choices
function show_menu() {
echo "Please select the software you would like to install (multiple selections allowed):"
echo "1. Prometheus"
echo "2. Node Exporter"
echo "3. Grafana"
echo "4. Exit"
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 show_progress {
local total=$1
local current=$2
local percent=$((current * 100 / total))
printf "\r[%-70s] %d%%" "$(printf '#%.0s' $(seq 1 $percent))" "$percent"
}
# Function to download and install Prometheus
function install_prometheus() {
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}
echo "Chosen Prometheus version: $PROMETHEUS_VERSION"
DOWNLOAD_DIR="/tmp/prometheus-install"
PROMETHEUS_USER="prometheus"
PROMETHEUS_GROUP="prometheus"
PROMETHEUS_DIR="/usr/local/bin/prometheus"
CONFIG_DIR="/etc/prometheus"
DATA_DIR="/var/lib/prometheus"
echo "Creating download directory..."
mkdir -p $DOWNLOAD_DIR
echo "Downloading Prometheus binary..."
cd $DOWNLOAD_DIR
wget https://github.com/prometheus/prometheus/releases/download/v$PROMETHEUS_VERSION/prometheus-$PROMETHEUS_VERSION.linux-amd64.tar.gz
echo "Extracting Prometheus binary..."
tar xvfz prometheus-$PROMETHEUS_VERSION.linux-amd64.tar.gz
echo "Copying Prometheus binary to $PROMETHEUS_DIR..."
cp prometheus-$PROMETHEUS_VERSION.linux-amd64/prometheus $PROMETHEUS_DIR
echo "Copying promtool binary to /usr/local/bin"
sudo cp prometheus-$PROMETHEUS_VERSION.linux-amd64/promtool /usr/local/bin
echo "Creating Prometheus configuration file in $CONFIG_DIR..."
cat <<EOF > $CONFIG_DIR/prometheus.yml
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node_exporter'
static_configs:
- targets: ['localhost:9100']
EOF
echo "Creating $PROMETHEUS_USER user and group..."
sudo groupadd --system $PROMETHEUS_GROUP
sudo useradd -s /sbin/nologin --system -g $PROMETHEUS_GROUP $PROMETHEUS_USER
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 /usr/local/bin/prometheus
sudo chown -R $PROMETHEUS_USER:$PROMETHEUS_GROUP /usr/local/bin/node_exporter
echo "Creating systemd service for Prometheus..."
cat <<EOF | sudo tee /etc/systemd/system/prometheus.service > /dev/null
[Unit]
Description=Prometheus Time Series Database
Wants=network-online.target
After=network-online.target
[Service]
User=$PROMETHEUS_USER
Group=$PROMETHEUS_GROUP
Type=simple
ExecStart=/usr/local/bin/prometheus \
--config.file=$CONFIG_DIR/prometheus.yml \
--storage.tsdb.path=$DATA_DIR
Restart=always
[Install]
WantedBy=default.target
EOF
echo "Reloading systemd daemon..."
sudo systemctl daemon-reload
echo "Enabling Prometheus service..."
sudo systemctl enable prometheus.service
echo "Starting Prometheus service..."
sudo systemctl start prometheus.service
echo "Checking status of Prometheus service..."
systemctl status prometheus.service
}
# Function to download and 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
NODE_EXPORTER_VERSION=${NODE_EXPORTER_VERSION:-$DEFAULT_NODE_EXPORTER_VERSION}
echo "Chosen Node Exporter version: $NODE_EXPORTER_VERSION"
DOWNLOAD_DIR="/tmp/node-exporter-install"
PROMETHEUS_USER="prometheus"
PROMETHEUS_GROUP="prometheus"
BINARY_DIR="/usr/local/bin"
echo "Creating download directory..."
mkdir -p $DOWNLOAD_DIR
echo "Downloading Node Exporter binary..."
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
echo "Extracting Node Exporter binary..."
tar xvfz node_exporter-$NODE_EXPORTER_VERSION.linux-amd64.tar.gz
echo "Copying Node Exporter binary to $BINARY_DIR..."
sudo cp node_exporter-$NODE_EXPORTER_VERSION.linux-amd64/node_exporter $BINARY_DIR
echo "Creating systemd service for Node Exporter..."
cat <<EOF | sudo tee /etc/systemd/system/node_exporter.service > /dev/null
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=$PROMETHEUS_USER
Group=$PROMETHEUS_GROUP
Type=simple
ExecStart=/usr/local/bin/node_exporter
Restart=always
[Install]
WantedBy=default.target
EOF
echo "Reloading systemd daemon..."
sudo systemctl daemon-reload
echo "Enabling Node Exporter service..."
sudo systemctl enable node_exporter.service
echo "Starting Node Exporter service..."
sudo systemctl start node_exporter.service
echo "Checking status of Node Exporter service..."
systemctl status node_exporter.service
}
# Function to install Grafana
function install_grafana() {
echo "Installing Grafana using the official PPA..."
echo "Importing Grafana repository keyring..."
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "Adding Grafana repository..."
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
echo "Updating package list..."
sudo apt-get update
echo "Installing Grafana..."
sudo apt-get install -y grafana
echo "Enabling Grafana service..."
sudo systemctl enable grafana-server
echo "Starting Grafana service..."
sudo systemctl start grafana-server
echo "Checking status of Grafana service..."
systemctl status grafana-server
}
# Prompt for sudo password and validate it
sudo -v
# Main script execution
show_menu
# Convert the input choice to an array
IFS=',' read -r -a choices <<< "$choice"
# Execute selected installations with progress bar
for i in "${!choices[@]}"; do
case ${choices[$i]} in
1)
echo "Installing Prometheus..."
install_prometheus
;;
2)
echo "Installing Node Exporter..."
install_node_exporter
;;
3)
echo "Installing Grafana..."
install_grafana
;;
4)
echo "Exiting..."
exit 0
;;
*)
echo "Invalid choice: ${choices[$i]}. Skipping."
;;
esac
done
echo "Installation completed successfully!"

View File

@ -1,102 +1,102 @@
#!/bin/bash
# Function to install Loki and Promtail
install_loki_promtail() {
echo "Installing Loki and Promtail..."
# Install Loki
echo "Installing Loki..."
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
apt-get update -y
apt-get install -y loki
# Install Promtail
echo "Installing Promtail..."
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
apt-get update -y
apt-get install -y promtail
# Enable and start Loki and Promtail services
echo "Enabling and starting Loki and Promtail services..."
systemctl enable loki
systemctl start loki
systemctl enable promtail
systemctl start promtail
echo "Loki and Promtail installed and services started."
}
# Check for sudo/root privileges
if [ "$(id -u)" != "0" ]; then
echo "Script must be run as root. Please enter your sudo password."
exec sudo bash "$0" "$@"
fi
echo "Starting script as root."
# Step 2: Install software-properties-common, apt-transport-https, wget
echo "Step 2: Installing software-properties-common, apt-transport-https, wget..."
apt-get update -y
apt-get install -y software-properties-common apt-transport-https wget
# Step 3: Add 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 -
# Step 4: Add the official Grafana repository for Debian
echo "Step 4: Adding the official Grafana repository..."
add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
# Step 5: Run apt update
echo "Step 5: Updating package list..."
apt-get update -y
# Step 6: Install both Grafana & Prometheus
echo "Step 6: Installing Grafana and Prometheus..."
apt-get install -y grafana prometheus
# Step 7: Edit the Grafana config file to change the default port
echo "Step 7: Changing Grafana port from 3000 to 3100..."
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
echo "Step 8: Enabling and starting Grafana and Prometheus services..."
systemctl daemon-reload
systemctl enable grafana-server
systemctl start grafana-server
systemctl enable prometheus
systemctl start prometheus
# Step 9: Wait 2 minutes, then check both services are running successfully
echo "Step 9: Waiting 2 minutes to check service statuses..."
sleep 120
GRAFANA_STATUS=$(systemctl is-active grafana-server)
PROMETHEUS_STATUS=$(systemctl is-active prometheus)
if [ "$GRAFANA_STATUS" != "active" ] || [ "$PROMETHEUS_STATUS" != "active" ]; then
echo "One or both services failed to start. Retrying in 2 minutes..."
sleep 120
systemctl restart grafana-server
systemctl restart prometheus
fi
GRAFANA_STATUS=$(systemctl is-active grafana-server)
PROMETHEUS_STATUS=$(systemctl is-active prometheus)
if [ "$GRAFANA_STATUS" == "active" ] && [ "$PROMETHEUS_STATUS" == "active" ]; then
echo "Both Grafana and Prometheus are running successfully."
echo "Grafana can be accessed on port 3100."
# Prompt to install Loki and 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
install_loki_promtail
else
echo "Skipping installation of Loki and Promtail."
fi
else
echo "Failed to start one or both services. Please check the logs for more information."
fi
#!/bin/bash
# Function to install Loki and Promtail
install_loki_promtail() {
echo "Installing Loki and Promtail..."
# Install Loki
echo "Installing Loki..."
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
apt-get update -y
apt-get install -y loki
# Install Promtail
echo "Installing Promtail..."
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
apt-get update -y
apt-get install -y promtail
# Enable and start Loki and Promtail services
echo "Enabling and starting Loki and Promtail services..."
systemctl enable loki
systemctl start loki
systemctl enable promtail
systemctl start promtail
echo "Loki and Promtail installed and services started."
}
# Check for sudo/root privileges
if [ "$(id -u)" != "0" ]; then
echo "Script must be run as root. Please enter your sudo password."
exec sudo bash "$0" "$@"
fi
echo "Starting script as root."
# Step 2: Install software-properties-common, apt-transport-https, wget
echo "Step 2: Installing software-properties-common, apt-transport-https, wget..."
apt-get update -y
apt-get install -y software-properties-common apt-transport-https wget
# Step 3: Add 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 -
# Step 4: Add the official Grafana repository for Debian
echo "Step 4: Adding the official Grafana repository..."
add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
# Step 5: Run apt update
echo "Step 5: Updating package list..."
apt-get update -y
# Step 6: Install both Grafana & Prometheus
echo "Step 6: Installing Grafana and Prometheus..."
apt-get install -y grafana prometheus
# Step 7: Edit the Grafana config file to change the default port
echo "Step 7: Changing Grafana port from 3000 to 3100..."
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
echo "Step 8: Enabling and starting Grafana and Prometheus services..."
systemctl daemon-reload
systemctl enable grafana-server
systemctl start grafana-server
systemctl enable prometheus
systemctl start prometheus
# Step 9: Wait 2 minutes, then check both services are running successfully
echo "Step 9: Waiting 2 minutes to check service statuses..."
sleep 120
GRAFANA_STATUS=$(systemctl is-active grafana-server)
PROMETHEUS_STATUS=$(systemctl is-active prometheus)
if [ "$GRAFANA_STATUS" != "active" ] || [ "$PROMETHEUS_STATUS" != "active" ]; then
echo "One or both services failed to start. Retrying in 2 minutes..."
sleep 120
systemctl restart grafana-server
systemctl restart prometheus
fi
GRAFANA_STATUS=$(systemctl is-active grafana-server)
PROMETHEUS_STATUS=$(systemctl is-active prometheus)
if [ "$GRAFANA_STATUS" == "active" ] && [ "$PROMETHEUS_STATUS" == "active" ]; then
echo "Both Grafana and Prometheus are running successfully."
echo "Grafana can be accessed on port 3100."
# Prompt to install Loki and 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
install_loki_promtail
else
echo "Skipping installation of Loki and Promtail."
fi
else
echo "Failed to start one or both services. Please check the logs for more information."
fi

View File

@ -1,139 +1,139 @@
#!/bin/bash
# Check if the script is being run as root
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
echo "Updating system..."
# Update the system
apt update && apt upgrade -y
echo "Installing dependencies..."
# Install prerequisites for Graylog, OpenSearch, and MongoDB
apt install -y apt-transport-https openjdk-11-jre-headless uuid-runtime pwgen wget gnupg
check_system_requirements() {
echo "Checking the minimum system requirements for Graylog..."
# Minimum required RAM (in MB)
minimum_ram=4096
# Minimum required disk space (in GB)
minimum_disk_space=50
# Get total RAM in the system
total_ram=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
# Get total disk space in the system
total_disk_space=$(df -BG --output=avail / | sed '1d' | awk '{print $1}' | sed 's/G//')
# Check if RAM meets the minimum requirements
if [ "$total_ram" -lt "$minimum_ram" ]; then
echo "Error: Insufficient RAM. Graylog requires a minimum of $minimum_ram MB of RAM."
exit 1
else
echo "RAM: $total_ram MB - meets minimum requirements."
fi
# Check if disk space meets the minimum requirements
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."
exit 1
else
echo "Disk space: $total_disk_space GB - meets minimum requirements."
fi
echo "System meets the minimum requirements for Graylog."
}
# Disable huge pages support
echo "Disabling huge pages support..."
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
# Set maximum file count for OpenSearch
echo "Setting maximum file count for OpenSearch..."
sysctl -w vm.max_map_count=262144
echo "vm.max_map_count=262144" >> /etc/sysctl.conf
# Add the OpenSearch repository and its GPG key
echo "Adding OpenSearch repository..."
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
# Add the MongoDB repository
echo "Adding MongoDB repository..."
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
# Add the Graylog repository and its GPG key
echo "Adding Graylog repository..."
wget -qO - https://packages.graylog2.org/repo/packages/graylog-5.3-repository_latest.deb | dpkg -i -
# Update the package index again
echo "Updating package index..."
apt update
#Add OpenSearch User
echo "Adding Opensearch User"
adduser --system --disabled-password --disabled-login --home /var/empty --no-create-home --quiet --force-badname --group opensearch
# Install OpenSearch and MongoDB
echo "Installing OpenSearch"
apt install -y opensearch
#Create OpenSearch Directories
mkdir -p /graylog/opensearch/data
mkdir /var/log/opensearch
#Extract Contents from tar
tar -zxf opensearch-2.0.1-linux-x64.tar.gz
mv opensearch-2.0.1/* /graylog/opensearch/
#Create empty log file
sudo -u opensearch touch /var/log/opensearch/graylog.log
#Set Permissions
chown -R opensearch:opensearch /graylog/opensearch/
chown -R opensearch:opensearch /var/log/opensearch
chmod -R 2750 /graylog/opensearch/
chmod -R 2750 /var/log/opensearch/
# Add OpenSearch service and set it to start automatically
echo "Adding OpenSearch service and enabling autostart..."
systemctl enable opensearch
systemctl start opensearch
#Install MongoDB
echo "Installing MongoDB"
sudo apt install -y MongoDB
# Install Graylog
echo "Installing Graylog..."
apt install -y graylog-server
# Prompt user to enter admin user password
read -sp "Enter your desired admin password for Graylog: " GRAYLOG_ADMIN_PASSWORD
echo
# Generate a secret key for Graylog
echo "Generating secret key for Graylog..."
GRAYLOG_SECRET=$(pwgen -N 1 -s 96)
sed -i "s/password_secret =.*/password_secret = $GRAYLOG_SECRET/" /etc/graylog/server/server.conf
# Generate a 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}')
sed -i "s/root_password_sha2 =.*/root_password_sha2 = $GRAYLOG_PASSWORD/" /etc/graylog/server/server.conf
# Reload systemd
echo "Reloading systemd..."
systemctl daemon-reload
# Enable and start Graylog service
echo "Enabling and starting Graylog service..."
systemctl enable graylog-server
systemctl start graylog-server
#!/bin/bash
# Check if the script is being run as root
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
echo "Updating system..."
# Update the system
apt update && apt upgrade -y
echo "Installing dependencies..."
# Install prerequisites for Graylog, OpenSearch, and MongoDB
apt install -y apt-transport-https openjdk-11-jre-headless uuid-runtime pwgen wget gnupg
check_system_requirements() {
echo "Checking the minimum system requirements for Graylog..."
# Minimum required RAM (in MB)
minimum_ram=4096
# Minimum required disk space (in GB)
minimum_disk_space=50
# Get total RAM in the system
total_ram=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
# Get total disk space in the system
total_disk_space=$(df -BG --output=avail / | sed '1d' | awk '{print $1}' | sed 's/G//')
# Check if RAM meets the minimum requirements
if [ "$total_ram" -lt "$minimum_ram" ]; then
echo "Error: Insufficient RAM. Graylog requires a minimum of $minimum_ram MB of RAM."
exit 1
else
echo "RAM: $total_ram MB - meets minimum requirements."
fi
# Check if disk space meets the minimum requirements
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."
exit 1
else
echo "Disk space: $total_disk_space GB - meets minimum requirements."
fi
echo "System meets the minimum requirements for Graylog."
}
# Disable huge pages support
echo "Disabling huge pages support..."
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
# Set maximum file count for OpenSearch
echo "Setting maximum file count for OpenSearch..."
sysctl -w vm.max_map_count=262144
echo "vm.max_map_count=262144" >> /etc/sysctl.conf
# Add the OpenSearch repository and its GPG key
echo "Adding OpenSearch repository..."
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
# Add the MongoDB repository
echo "Adding MongoDB repository..."
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
# Add the Graylog repository and its GPG key
echo "Adding Graylog repository..."
wget -qO - https://packages.graylog2.org/repo/packages/graylog-5.3-repository_latest.deb | dpkg -i -
# Update the package index again
echo "Updating package index..."
apt update
#Add OpenSearch User
echo "Adding Opensearch User"
adduser --system --disabled-password --disabled-login --home /var/empty --no-create-home --quiet --force-badname --group opensearch
# Install OpenSearch and MongoDB
echo "Installing OpenSearch"
apt install -y opensearch
#Create OpenSearch Directories
mkdir -p /graylog/opensearch/data
mkdir /var/log/opensearch
#Extract Contents from tar
tar -zxf opensearch-2.0.1-linux-x64.tar.gz
mv opensearch-2.0.1/* /graylog/opensearch/
#Create empty log file
sudo -u opensearch touch /var/log/opensearch/graylog.log
#Set Permissions
chown -R opensearch:opensearch /graylog/opensearch/
chown -R opensearch:opensearch /var/log/opensearch
chmod -R 2750 /graylog/opensearch/
chmod -R 2750 /var/log/opensearch/
# Add OpenSearch service and set it to start automatically
echo "Adding OpenSearch service and enabling autostart..."
systemctl enable opensearch
systemctl start opensearch
#Install MongoDB
echo "Installing MongoDB"
sudo apt install -y MongoDB
# Install Graylog
echo "Installing Graylog..."
apt install -y graylog-server
# Prompt user to enter admin user password
read -sp "Enter your desired admin password for Graylog: " GRAYLOG_ADMIN_PASSWORD
echo
# Generate a secret key for Graylog
echo "Generating secret key for Graylog..."
GRAYLOG_SECRET=$(pwgen -N 1 -s 96)
sed -i "s/password_secret =.*/password_secret = $GRAYLOG_SECRET/" /etc/graylog/server/server.conf
# Generate a 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}')
sed -i "s/root_password_sha2 =.*/root_password_sha2 = $GRAYLOG_PASSWORD/" /etc/graylog/server/server.conf
# Reload systemd
echo "Reloading systemd..."
systemctl daemon-reload
# Enable and start Graylog service
echo "Enabling and starting Graylog service..."
systemctl enable graylog-server
systemctl start graylog-server
echo "Graylog installation complete. You can access it at http://your-server-ip:9000"

View File

@ -1,51 +1,51 @@
# 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.
# Installation:
To run this script:
1. Use wget to grab the latest version:
`wget https://og.codes/oliver/install-scripts/raw/branch/master/graylog/install.sh`
2. CHMOD the script to make it executable:
`sudo chmod +x install.sh`
3. Run the script:
`sudo ./install.sh`
# Script Process:
This script makes the following checks (in order):
Checks the script is being run as root.
Installs required dependencies.
Checks the system meets the minimum system requirements.
Disables Huge Pages Support if Enabled (OpenSearch).
Sets Maximum File Count (OpenSearch).
Adds all required respitory keys & Updates the package index.
Adds the OpenSearch user.
Installs OpenSearch.
Creates required OpenSearch directories & log file. Ensures their permissions.
Installs MongoDB.
Installs Graylog
# 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.
# Installation:
To run this script:
1. Use wget to grab the latest version:
`wget https://og.codes/oliver/install-scripts/raw/branch/master/graylog/install.sh`
2. CHMOD the script to make it executable:
`sudo chmod +x install.sh`
3. Run the script:
`sudo ./install.sh`
# Script Process:
This script makes the following checks (in order):
Checks the script is being run as root.
Installs required dependencies.
Checks the system meets the minimum system requirements.
Disables Huge Pages Support if Enabled (OpenSearch).
Sets Maximum File Count (OpenSearch).
Adds all required respitory keys & Updates the package index.
Adds the OpenSearch user.
Installs OpenSearch.
Creates required OpenSearch directories & log file. Ensures their permissions.
Installs MongoDB.
Installs Graylog

View File

@ -1,201 +1,201 @@
#!/bin/bash
# Check if running as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# Update and upgrade the system
echo "Updating and upgrading the system..."
apt update && apt upgrade -y
# Install 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
# 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.:"
python3 --version
# 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
if [[ $PYTHON_CONFIRM != "y" ]]; then
echo "Minimum Python version requirement confirmed!"
exit 0
fi
# Check other system requirements
echo "Checking the system meets the minimum requirements..."
RAM=$(free -m | awk '/Mem/ {print $2}')
CPU=$(grep -c ^processor /proc/cpuinfo)
DISK=$(df -h / | awk 'NR==2 {print $4}')
MIN_RAM=2048 # Minimum RAM in MB
MIN_CPU=2 # Minimum CPU cores
MIN_DISK=10 # Minimum free disk space in GB
# Check RAM
if [ "$RAM" -lt "$MIN_RAM" ]; then
echo "Error: Insufficient RAM. At least $MIN_RAM MB of RAM is required."
exit 1
fi
# Check CPU cores
if [ "$CPU" -lt "$MIN_CPU" ]; then
echo "Error: Insufficient CPU cores. At least $MIN_CPU CPU cores are required."
exit 1
fi
# Check disk space
DISK_NUM=$(echo "$DISK" | grep -o -E '[0-9]+')
DISK_UNIT=$(echo "$DISK" | grep -o -E '[A-Za-z]+')
if [ "$DISK_UNIT" == "G" ]; then
if [ "$DISK_NUM" -lt "$MIN_DISK" ]; then
echo "Error: Insufficient disk space. At least $MIN_DISK GB of free disk space is required."
exit 1
fi
else
echo "Error: Unsupported disk space unit. Please ensure disk space is at least 10GB."
exit 1
fi
echo "System meets minimum requirements. Proceeding with installation..."
# Download the latest version of netbox and unzip it
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 tar -xzf vX.Y.Z.tar.gz -C /opt
sudo ln -s /opt/netbox-X.Y.Z/ /opt/netbox
# Prompt user for PostgreSQL and Netbox password
read -p "Enter PostgreSQL password for 'netbox' user: " PG_PASSWORD
read -p "Enter password for Netbox application: " NETBOX_PASSWORD
# Create PostgreSQL user and database
echo "Creating PostgreSQL user and database..."
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 "GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;"
# Create new user for Netbox
echo "Creating new user for Netbox..."
useradd -m -s /bin/bash netbox
# Install Netbox
echo "Installing Netbox..."
apt update
apt install -y netbox
# Move into NetBox configuration directory and make a copy of configuration_example.py
echo "Copying Netbox configuration file..."
cd /opt/netbox/netbox/netbox/
cp configuration.example.py configuration.py
# Populate database fields in configuration.py with PostgreSQL information
echo "Populating the Netbox configuration file with prior PostgreSQL information..."
sed -i "s/'USER': '',/'USER': '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/'HOST': '',/'HOST': 'localhost',/g" configuration.py
# Generate secret key and parse it into configuration.py
echo "Generating secret key..."
SECRET_KEY=$(python3 /opt/netbox/generate_secret_key.py)
sed -i "s/SECRET_KEY = ''/SECRET_KEY = '$SECRET_KEY'/g" configuration.py
# Prompt user to enter ALLOWED_HOSTS
echo "Please enter manually input the following inforation..."
read -p "Enter ALLOWED_HOSTS (separated by commas): " ALLOWED_HOSTS
# Parse user input into 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/SECRET_KEY = ''/SECRET_KEY = '$SECRET_KEY'/g" configuration.py
# Perform initial Netbox database migration
echo "Performing initial Netbox database migration..."
sudo -u netbox /opt/netbox/upgrade.sh
# Create directory for Netbox reports
echo "Creating directory for Netbox reports..."
mkdir -p /opt/netbox/netbox/media/reports
# Check 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
read -p "Required directories are missing. Do you want to create them? (y/n): " CREATE_DIRS
if [[ $CREATE_DIRS == "y" ]]; then
mkdir -p /opt/netbox/netbox/media/reports
mkdir -p /opt/netbox/netbox/media/
mkdir -p /opt/netbox/netbox/static/
else
echo "Please create the required directories manually and rerun the script."
exit 1
fi
fi
# Collect static files
echo "Collecting static files..."
sudo -u netbox /opt/netbox/manage.py collectstatic --no-input
# Enable plugin support
echo "Enabling plugin support..."
echo "PLUGINS = []" >> /opt/netbox/netbox/configuration.py
# Prompt user to enter plugin names
read -p "Enter names of plugins to add (separated by commas, leave empty to skip): " PLUGIN_NAMES
# Add plugins to configuration file
if [ -n "$PLUGIN_NAMES" ]; then
IFS=',' read -ra PLUGINS <<< "$PLUGIN_NAMES"
for PLUGIN in "${PLUGINS[@]}"; do
echo "Adding plugin: $PLUGIN"
echo " '$PLUGIN'," >> /opt/netbox/netbox/configuration.py
done
fi
# Prompt user to create a new superuser
echo "Please create a new superuser for Netbox:"
sudo -u netbox /opt/netbox/manage.py createsuperuser
# Set file and directory permissions
echo "Setting file permissions..."
chown -R netbox:netbox /opt/netbox/netbox/media
chown -R netbox:netbox /opt/netbox/netbox/static
chown -R netbox:netbox /opt/netbox/netbox/media/reports
# Enable and start services
echo "Enabling and starting services..."
systemctl enable netbox
systemctl enable redis-server
systemctl enable postgresql
systemctl start netbox
systemctl start redis-server
systemctl start postgresql
# NGINX reverse proxy config
echo "Example NGINX reverse proxy configuration for Netbox:"
echo "
server {
listen 80;
server_name netbox.example.com;
location / {
proxy_pass http://localhost:8001;
proxy_set_header X-Forwarded-Host \$server_name;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
}
location /static/ {
alias /opt/netbox/netbox/static/;
}
location /media/ {
alias /opt/netbox/netbox/media/;
}
}
"
#!/bin/bash
# Check if running as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# Update and upgrade the system
echo "Updating and upgrading the system..."
apt update && apt upgrade -y
# Install 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
# 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.:"
python3 --version
# 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
if [[ $PYTHON_CONFIRM != "y" ]]; then
echo "Minimum Python version requirement confirmed!"
exit 0
fi
# Check other system requirements
echo "Checking the system meets the minimum requirements..."
RAM=$(free -m | awk '/Mem/ {print $2}')
CPU=$(grep -c ^processor /proc/cpuinfo)
DISK=$(df -h / | awk 'NR==2 {print $4}')
MIN_RAM=2048 # Minimum RAM in MB
MIN_CPU=2 # Minimum CPU cores
MIN_DISK=10 # Minimum free disk space in GB
# Check RAM
if [ "$RAM" -lt "$MIN_RAM" ]; then
echo "Error: Insufficient RAM. At least $MIN_RAM MB of RAM is required."
exit 1
fi
# Check CPU cores
if [ "$CPU" -lt "$MIN_CPU" ]; then
echo "Error: Insufficient CPU cores. At least $MIN_CPU CPU cores are required."
exit 1
fi
# Check disk space
DISK_NUM=$(echo "$DISK" | grep -o -E '[0-9]+')
DISK_UNIT=$(echo "$DISK" | grep -o -E '[A-Za-z]+')
if [ "$DISK_UNIT" == "G" ]; then
if [ "$DISK_NUM" -lt "$MIN_DISK" ]; then
echo "Error: Insufficient disk space. At least $MIN_DISK GB of free disk space is required."
exit 1
fi
else
echo "Error: Unsupported disk space unit. Please ensure disk space is at least 10GB."
exit 1
fi
echo "System meets minimum requirements. Proceeding with installation..."
# Download the latest version of netbox and unzip it
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 tar -xzf vX.Y.Z.tar.gz -C /opt
sudo ln -s /opt/netbox-X.Y.Z/ /opt/netbox
# Prompt user for PostgreSQL and Netbox password
read -p "Enter PostgreSQL password for 'netbox' user: " PG_PASSWORD
read -p "Enter password for Netbox application: " NETBOX_PASSWORD
# Create PostgreSQL user and database
echo "Creating PostgreSQL user and database..."
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 "GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;"
# Create new user for Netbox
echo "Creating new user for Netbox..."
useradd -m -s /bin/bash netbox
# Install Netbox
echo "Installing Netbox..."
apt update
apt install -y netbox
# Move into NetBox configuration directory and make a copy of configuration_example.py
echo "Copying Netbox configuration file..."
cd /opt/netbox/netbox/netbox/
cp configuration.example.py configuration.py
# Populate database fields in configuration.py with PostgreSQL information
echo "Populating the Netbox configuration file with prior PostgreSQL information..."
sed -i "s/'USER': '',/'USER': '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/'HOST': '',/'HOST': 'localhost',/g" configuration.py
# Generate secret key and parse it into configuration.py
echo "Generating secret key..."
SECRET_KEY=$(python3 /opt/netbox/generate_secret_key.py)
sed -i "s/SECRET_KEY = ''/SECRET_KEY = '$SECRET_KEY'/g" configuration.py
# Prompt user to enter ALLOWED_HOSTS
echo "Please enter manually input the following inforation..."
read -p "Enter ALLOWED_HOSTS (separated by commas): " ALLOWED_HOSTS
# Parse user input into 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/SECRET_KEY = ''/SECRET_KEY = '$SECRET_KEY'/g" configuration.py
# Perform initial Netbox database migration
echo "Performing initial Netbox database migration..."
sudo -u netbox /opt/netbox/upgrade.sh
# Create directory for Netbox reports
echo "Creating directory for Netbox reports..."
mkdir -p /opt/netbox/netbox/media/reports
# Check 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
read -p "Required directories are missing. Do you want to create them? (y/n): " CREATE_DIRS
if [[ $CREATE_DIRS == "y" ]]; then
mkdir -p /opt/netbox/netbox/media/reports
mkdir -p /opt/netbox/netbox/media/
mkdir -p /opt/netbox/netbox/static/
else
echo "Please create the required directories manually and rerun the script."
exit 1
fi
fi
# Collect static files
echo "Collecting static files..."
sudo -u netbox /opt/netbox/manage.py collectstatic --no-input
# Enable plugin support
echo "Enabling plugin support..."
echo "PLUGINS = []" >> /opt/netbox/netbox/configuration.py
# Prompt user to enter plugin names
read -p "Enter names of plugins to add (separated by commas, leave empty to skip): " PLUGIN_NAMES
# Add plugins to configuration file
if [ -n "$PLUGIN_NAMES" ]; then
IFS=',' read -ra PLUGINS <<< "$PLUGIN_NAMES"
for PLUGIN in "${PLUGINS[@]}"; do
echo "Adding plugin: $PLUGIN"
echo " '$PLUGIN'," >> /opt/netbox/netbox/configuration.py
done
fi
# Prompt user to create a new superuser
echo "Please create a new superuser for Netbox:"
sudo -u netbox /opt/netbox/manage.py createsuperuser
# Set file and directory permissions
echo "Setting file permissions..."
chown -R netbox:netbox /opt/netbox/netbox/media
chown -R netbox:netbox /opt/netbox/netbox/static
chown -R netbox:netbox /opt/netbox/netbox/media/reports
# Enable and start services
echo "Enabling and starting services..."
systemctl enable netbox
systemctl enable redis-server
systemctl enable postgresql
systemctl start netbox
systemctl start redis-server
systemctl start postgresql
# NGINX reverse proxy config
echo "Example NGINX reverse proxy configuration for Netbox:"
echo "
server {
listen 80;
server_name netbox.example.com;
location / {
proxy_pass http://localhost:8001;
proxy_set_header X-Forwarded-Host \$server_name;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
}
location /static/ {
alias /opt/netbox/netbox/static/;
}
location /media/ {
alias /opt/netbox/netbox/media/;
}
}
"
echo "Netbox installation completed successfully!"

View File

@ -1,15 +1,15 @@
To run this script:
1. Use wget to grab the latest version:
`wget https://og.codes/oliver/install-scripts/raw/branch/master/netbox/install.sh`
2. CHMOD the script to make it executable:
`chmod +x install.sh`
3. Run the script:
`./install.sh`
To run this script:
1. Use wget to grab the latest version:
`wget https://og.codes/oliver/install-scripts/raw/branch/master/netbox/install.sh`
2. CHMOD the script to make it executable:
`chmod +x install.sh`
3. Run the script:
`./install.sh`

View File

@ -1,77 +1,77 @@
#!/bin/bash
# Function to check if a command exists
command_exists() {
type "$1" &> /dev/null ;
}
# Check if the script is run as root
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root. Please use sudo." 1>&2
exit 1
fi
# Update and install necessary packages
echo "Updating package list and installing necessary tools..."
apt-get update && apt-get upgrade -y
if command_exists lspci; then
echo "lspci is already installed."
else
echo "Installing lspci..."
apt-get install pciutils -y
fi
if command_exists grep; then
echo "grep is already installed."
else
echo "Installing grep..."
apt-get install grep -y
fi
# Identify the GPU device you want to passthrough
echo "Listing all PCI devices to identify your GPU:"
lspci
read -p "Enter the PCI ID of your GPU (e.g., 00:01.0): " gpu_id
# Verify GPU identification
echo "Verifying GPU with lspci -k..."
lspci -k | grep -i "$gpu_id"
if [ $? -ne 0 ]; then
echo "GPU not found or incorrect ID entered." >&2
exit 1
fi
# Configure Proxmox for GPU passthrough
echo "Configuring Proxmox to enable GPU passthrough..."
# 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
echo "Editing VM configuration file for GPU passthrough..."
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)
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
if [[ "$response" == "yes" ]]; then
read -p "Enter the desired PCI slot (e.g., 00:02.0): " 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.
fi
# Blacklist the GPU driver modules
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
if [[ "$response" == "yes" ]]; then
echo "Blacklisting GPU driver modules..."
# Create a blacklist file for the relevant drivers
echo "${gpu_id}*" > /etc/modprobe.d/blacklist-gpu.conf
fi
# Restart the VM for changes to take effect
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
virsh shutdown $vm_id
read -p "Power on the VM now? Type 'yes': " response
if [[ "$response" == "yes" ]]; then
virsh start $vm_id
fi
#!/bin/bash
# Function to check if a command exists
command_exists() {
type "$1" &> /dev/null ;
}
# Check if the script is run as root
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root. Please use sudo." 1>&2
exit 1
fi
# Update and install necessary packages
echo "Updating package list and installing necessary tools..."
apt-get update && apt-get upgrade -y
if command_exists lspci; then
echo "lspci is already installed."
else
echo "Installing lspci..."
apt-get install pciutils -y
fi
if command_exists grep; then
echo "grep is already installed."
else
echo "Installing grep..."
apt-get install grep -y
fi
# Identify the GPU device you want to passthrough
echo "Listing all PCI devices to identify your GPU:"
lspci
read -p "Enter the PCI ID of your GPU (e.g., 00:01.0): " gpu_id
# Verify GPU identification
echo "Verifying GPU with lspci -k..."
lspci -k | grep -i "$gpu_id"
if [ $? -ne 0 ]; then
echo "GPU not found or incorrect ID entered." >&2
exit 1
fi
# Configure Proxmox for GPU passthrough
echo "Configuring Proxmox to enable GPU passthrough..."
# 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
echo "Editing VM configuration file for GPU passthrough..."
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)
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
if [[ "$response" == "yes" ]]; then
read -p "Enter the desired PCI slot (e.g., 00:02.0): " 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.
fi
# Blacklist the GPU driver modules
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
if [[ "$response" == "yes" ]]; then
echo "Blacklisting GPU driver modules..."
# Create a blacklist file for the relevant drivers
echo "${gpu_id}*" > /etc/modprobe.d/blacklist-gpu.conf
fi
# Restart the VM for changes to take effect
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
virsh shutdown $vm_id
read -p "Power on the VM now? Type 'yes': " response
if [[ "$response" == "yes" ]]; then
virsh start $vm_id
fi
echo "GPU passthrough setup is complete. Please check your VM for GPU functionality."

View File

@ -1,114 +1,114 @@
#!/bin/bash
# Color codes for echo statements
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
# Function to display colored messages
echo_colored() {
local color=$1
shift
echo -e "${color}$@$NC"
}
# Step 1: Ask for the number of nodes
read -p "Enter the number of nodes in your K8S cluster: " num_nodes
# Step 2: Gather node details and store them
node_details=()
for ((i=1; i<=num_nodes; i++)); do
read -p "Enter IP address for node $i: " ip
read -p "Enter SSH username for node $i: " user
read -s -p "Enter SSH password for node $i: " password
echo ""
node_details+=("$ip:$user:$password")
done
# Step 3: Display stored IP addresses and ask for confirmation
echo_colored "$GREEN" "Stored Node Details:"
for detail in "${node_details[@]}"; do
IFS=':' read -r -a split <<< "$detail"
echo_colored "$YELLOW" "IP: ${split[0]}, User: ${split[1]}"
done
read -p "Are the above details correct? (yes/no): " confirm
if [ "$confirm" != "yes" ]; then
echo_colored "$RED" "Please edit your node details and run this script again."
exit 1
fi
# Step 4: Ask for the master node
read -p "Enter the IP address of the master node (control plane): " master_ip
# Function to execute commands on a remote node using SSH
ssh_cmd() {
local ip=$1
local user=$2
local password=$3
shift 3
sshpass -p "$password" ssh -o StrictHostKeyChecking=no "$user@$ip" "$@"
}
# Step 5: Update and upgrade all nodes, then reboot them
echo_colored "$GREEN" "Updating and upgrading all nodes..."
for detail in "${node_details[@]}"; do
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 reboot"
done
# Step 6: Install K8S on the master node
echo_colored "$GREEN" "Installing Kubernetes on the master node..."
master_ip_split=(${master_ip//:/ })
sshpass -p "${master_ip_split[2]}" ssh -o StrictHostKeyChecking=no "${master_ip_split[1]}@${master_ip_split[0]}" << 'EOF'
sudo apt update
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
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt update
sudo apt install -y kubelet=1.24.0-00 kubeadm=1.24.0-00 kubectl=1.24.0-00
sudo systemctl enable --now kubelet
EOF
# Step 7: Configure and restart 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
if [ "$custom_port" == "yes" ]; then
read -p "Enter a custom port number: " k8s_port
else
k8s_port=6443
fi
read -p "Do you want to specify a listening IP or domain? (yes/no): " listen_ip
if [ "$listen_ip" == "yes" ]; then
read -p "Enter the listening IP address or FQDN: " k8s_address
else
k8s_address=0.0.0.0
fi
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/nodePort: 6443/nodePort: $k8s_port/" /etc/kubernetes/manifests/kube-apiserver.yaml
sudo systemctl restart kubelet
EOF
# Step 8: Install K8S on all nodes
echo_colored "$GREEN" "Installing Kubernetes on all nodes..."
for detail in "${node_details[@]}"; do
IFS=':' read -r -a split <<< "$detail"
sshpass -p "${split[2]}" ssh -o StrictHostKeyChecking=no "${split[1]}@${split[0]}" << 'EOF'
sudo apt update
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
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt update
sudo apt install -y kubelet=1.24.0-00 kubeadm=1.24.0-00 kubectl=1.24.0-00
sudo systemctl enable --now kubelet
EOF
done
echo_colored "$GREEN" "Kubernetes cluster deployment completed successfully!"
#!/bin/bash
# Color codes for echo statements
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
# Function to display colored messages
echo_colored() {
local color=$1
shift
echo -e "${color}$@$NC"
}
# Step 1: Ask for the number of nodes
read -p "Enter the number of nodes in your K8S cluster: " num_nodes
# Step 2: Gather node details and store them
node_details=()
for ((i=1; i<=num_nodes; i++)); do
read -p "Enter IP address for node $i: " ip
read -p "Enter SSH username for node $i: " user
read -s -p "Enter SSH password for node $i: " password
echo ""
node_details+=("$ip:$user:$password")
done
# Step 3: Display stored IP addresses and ask for confirmation
echo_colored "$GREEN" "Stored Node Details:"
for detail in "${node_details[@]}"; do
IFS=':' read -r -a split <<< "$detail"
echo_colored "$YELLOW" "IP: ${split[0]}, User: ${split[1]}"
done
read -p "Are the above details correct? (yes/no): " confirm
if [ "$confirm" != "yes" ]; then
echo_colored "$RED" "Please edit your node details and run this script again."
exit 1
fi
# Step 4: Ask for the master node
read -p "Enter the IP address of the master node (control plane): " master_ip
# Function to execute commands on a remote node using SSH
ssh_cmd() {
local ip=$1
local user=$2
local password=$3
shift 3
sshpass -p "$password" ssh -o StrictHostKeyChecking=no "$user@$ip" "$@"
}
# Step 5: Update and upgrade all nodes, then reboot them
echo_colored "$GREEN" "Updating and upgrading all nodes..."
for detail in "${node_details[@]}"; do
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 reboot"
done
# Step 6: Install K8S on the master node
echo_colored "$GREEN" "Installing Kubernetes on the master node..."
master_ip_split=(${master_ip//:/ })
sshpass -p "${master_ip_split[2]}" ssh -o StrictHostKeyChecking=no "${master_ip_split[1]}@${master_ip_split[0]}" << 'EOF'
sudo apt update
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
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt update
sudo apt install -y kubelet=1.24.0-00 kubeadm=1.24.0-00 kubectl=1.24.0-00
sudo systemctl enable --now kubelet
EOF
# Step 7: Configure and restart 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
if [ "$custom_port" == "yes" ]; then
read -p "Enter a custom port number: " k8s_port
else
k8s_port=6443
fi
read -p "Do you want to specify a listening IP or domain? (yes/no): " listen_ip
if [ "$listen_ip" == "yes" ]; then
read -p "Enter the listening IP address or FQDN: " k8s_address
else
k8s_address=0.0.0.0
fi
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/nodePort: 6443/nodePort: $k8s_port/" /etc/kubernetes/manifests/kube-apiserver.yaml
sudo systemctl restart kubelet
EOF
# Step 8: Install K8S on all nodes
echo_colored "$GREEN" "Installing Kubernetes on all nodes..."
for detail in "${node_details[@]}"; do
IFS=':' read -r -a split <<< "$detail"
sshpass -p "${split[2]}" ssh -o StrictHostKeyChecking=no "${split[1]}@${split[0]}" << 'EOF'
sudo apt update
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
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt update
sudo apt install -y kubelet=1.24.0-00 kubeadm=1.24.0-00 kubectl=1.24.0-00
sudo systemctl enable --now kubelet
EOF
done
echo_colored "$GREEN" "Kubernetes cluster deployment completed successfully!"

View File

@ -1,136 +1,136 @@
#!/bin/sh
# 1st Step - Ask user for no. of cluster nodes
echo "How many nodes would you like your cluster to have?"
read NODECOUNT
# 2nd Step - Ask user for node details & store in tmp files
for ((i=0; i < $NODECOUNT; i++))
do
echo "Please enter the IP address of the ${i}th node: "
read IPADDR_$i
echo "${IPADDR_$i}" > /tmp/node${i}_ip.txt
echo "Please enter the username for SSH access to the ${i}th node (defaults to 'root'):"
read USERNAME_$i
if [ -z $USERNAME ]
then USERNAME="root";
fi
echo "${USERNAME}" > /tmp/node${i}_user.txt
echo "Please enter the password for SSH access to the ${i}th node (defaults to 'root'):"
read PASSWORD_$i
if [ -z $PASSWORD ]
then PASSWORD="root";
fi
echo "${PASSWORD}" > /tmp/node${i}_pass.txt
done
# 3rd Step - Confirm node details with user & allow them to edit if necessary
echo "The following IP addresses were entered by the user:"
for ((i=0; i < $NODECOUNT; i++))
do
echo "${IPADDR_$i}"
done
read -p "Please confirm these are correct, or type 'edit' to make changes: " USERCONFIRMATION
if [ "$USERCONFIRMATION" == "edit" ]
then
for ((i=0; i < $NODECOUNT; i++))
do
echo "Please enter the IP address of the ${i}th node: "
read IPADDR_$i
echo "${IPADDR_$i}" > /tmp/node${i}_ip.txt
echo "Please enter the username for SSH access to the ${i}th node (defaults to 'root'):"
read USERNAME_$i
if [ -z $USERNAME ]
then USERNAME="root";
fi
echo "${USERNAME}" > /tmp/node${i}_user.txt
echo "Please enter the password for SSH access to the ${i}th node (defaults to 'root'):"
read PASSWORD_$<s> i
if [ -z $PASSWORD ]
then PASSWORD="root";
fi
echo "${PASSWORD}" > /tmp/node${i}_pass.txt
done
fi
# 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):"
read MASTERNODE_SELECTION
echo "${MASTERNODE_SELECTION}" > /tmp/master.txt
# 5th Step - Add K8S repo & relevant keys to each node, install K8S & restart services
for ((i=0; i < $NODECOUNT; i++))
do
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"'
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 -'
echo "Updating package list on ${IPADDR_$i}..."
ssh -n $USERNAME_$i@${IPADDR_$i} 'sudo sh -c "apt update"'
echo "Upgrading packages on ${IPADDR_$i}..."
ssh -n $USERNAME_$i@${IPADDR_$i} 'sudo sh -c "apt upgrade"'
done
# 6th Step - Install K8S on master node and ask for configuration options from user
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"'
echo "Please enter your preferred port number for the control plane (master node) (defaults to 6443): "
read PORT_SELECTION
if [ -z $PORT_SELECTION ]
then PORT_SELECTION="6443";
fi
echo "Please enter your preferred IP address or FQDN for the control plane (master node) (defaults to '0.0.0.0'): "
read IPADDRESS_SELECTION
if [ -z $IPADDRESS_SELECTION ]
then IPADDRESS_SELECTION="0.0.0.0";
fi
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"'
echo "Please enter the following options to configure the Kubernetes control plane (master node)..."
echo "1. Pod Network CIDR: "
read NETWORKCIDR_SELECTION
echo "${NETWORKCIDR_SELECTION}" > /tmp/network.txt
echo "2. Service Subnet: "
read SERVICESUBNET_SELECTION
echo "${SERVICESUBNET_SELECTION}" > /tmp/servicesubnet.txt
echo "3. Kubernetes DNS Domain: "
read K8SDNS_SELECTION
echo "${K8SDNS_SELECTION}" > /tmp/kube-dns.txt
echo "Please enter your preferred Kubernetes version (defaults to '1.20.1'): "
read K8SVERSION_SELECTION
if [ -z $K8SVERSION_SELECTION ]
then K8SVERSION_SELECTION="1.20.1";
fi
echo "Please enter your preferred pod Network provider (defaults to 'calico'): "
read NETWORKPROVIDER_SELECTION
if [ -z $NETWORKPROVIDER_SELECT<s> ION_SELECTION ]
then NETWORKPROVIDER_SELECTION="calico";
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}..."
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..."
ssh -n $USERNAME_$MASTERNODE_SELECTION@${IPADDR_$MASTERNODE_SELECTION} 'sudo sh -c "systemctl restart kubelet.service"'
echo "Restarting Kubernetes services on all nodes..."
for ((i=0; i < $NODECOUNT; i++))
do
echo "Restarting Kubernetes services on the ${IPADDR_$i} node..."
ssh -n $USERNAME_$i@${IPADDR_$i} 'sudo sh -c "systemctl restart kubelet.service"'
done
#!/bin/sh
# 1st Step - Ask user for no. of cluster nodes
echo "How many nodes would you like your cluster to have?"
read NODECOUNT
# 2nd Step - Ask user for node details & store in tmp files
for ((i=0; i < $NODECOUNT; i++))
do
echo "Please enter the IP address of the ${i}th node: "
read IPADDR_$i
echo "${IPADDR_$i}" > /tmp/node${i}_ip.txt
echo "Please enter the username for SSH access to the ${i}th node (defaults to 'root'):"
read USERNAME_$i
if [ -z $USERNAME ]
then USERNAME="root";
fi
echo "${USERNAME}" > /tmp/node${i}_user.txt
echo "Please enter the password for SSH access to the ${i}th node (defaults to 'root'):"
read PASSWORD_$i
if [ -z $PASSWORD ]
then PASSWORD="root";
fi
echo "${PASSWORD}" > /tmp/node${i}_pass.txt
done
# 3rd Step - Confirm node details with user & allow them to edit if necessary
echo "The following IP addresses were entered by the user:"
for ((i=0; i < $NODECOUNT; i++))
do
echo "${IPADDR_$i}"
done
read -p "Please confirm these are correct, or type 'edit' to make changes: " USERCONFIRMATION
if [ "$USERCONFIRMATION" == "edit" ]
then
for ((i=0; i < $NODECOUNT; i++))
do
echo "Please enter the IP address of the ${i}th node: "
read IPADDR_$i
echo "${IPADDR_$i}" > /tmp/node${i}_ip.txt
echo "Please enter the username for SSH access to the ${i}th node (defaults to 'root'):"
read USERNAME_$i
if [ -z $USERNAME ]
then USERNAME="root";
fi
echo "${USERNAME}" > /tmp/node${i}_user.txt
echo "Please enter the password for SSH access to the ${i}th node (defaults to 'root'):"
read PASSWORD_$<s> i
if [ -z $PASSWORD ]
then PASSWORD="root";
fi
echo "${PASSWORD}" > /tmp/node${i}_pass.txt
done
fi
# 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):"
read MASTERNODE_SELECTION
echo "${MASTERNODE_SELECTION}" > /tmp/master.txt
# 5th Step - Add K8S repo & relevant keys to each node, install K8S & restart services
for ((i=0; i < $NODECOUNT; i++))
do
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"'
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 -'
echo "Updating package list on ${IPADDR_$i}..."
ssh -n $USERNAME_$i@${IPADDR_$i} 'sudo sh -c "apt update"'
echo "Upgrading packages on ${IPADDR_$i}..."
ssh -n $USERNAME_$i@${IPADDR_$i} 'sudo sh -c "apt upgrade"'
done
# 6th Step - Install K8S on master node and ask for configuration options from user
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"'
echo "Please enter your preferred port number for the control plane (master node) (defaults to 6443): "
read PORT_SELECTION
if [ -z $PORT_SELECTION ]
then PORT_SELECTION="6443";
fi
echo "Please enter your preferred IP address or FQDN for the control plane (master node) (defaults to '0.0.0.0'): "
read IPADDRESS_SELECTION
if [ -z $IPADDRESS_SELECTION ]
then IPADDRESS_SELECTION="0.0.0.0";
fi
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"'
echo "Please enter the following options to configure the Kubernetes control plane (master node)..."
echo "1. Pod Network CIDR: "
read NETWORKCIDR_SELECTION
echo "${NETWORKCIDR_SELECTION}" > /tmp/network.txt
echo "2. Service Subnet: "
read SERVICESUBNET_SELECTION
echo "${SERVICESUBNET_SELECTION}" > /tmp/servicesubnet.txt
echo "3. Kubernetes DNS Domain: "
read K8SDNS_SELECTION
echo "${K8SDNS_SELECTION}" > /tmp/kube-dns.txt
echo "Please enter your preferred Kubernetes version (defaults to '1.20.1'): "
read K8SVERSION_SELECTION
if [ -z $K8SVERSION_SELECTION ]
then K8SVERSION_SELECTION="1.20.1";
fi
echo "Please enter your preferred pod Network provider (defaults to 'calico'): "
read NETWORKPROVIDER_SELECTION
if [ -z $NETWORKPROVIDER_SELECT<s> ION_SELECTION ]
then NETWORKPROVIDER_SELECTION="calico";
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}..."
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..."
ssh -n $USERNAME_$MASTERNODE_SELECTION@${IPADDR_$MASTERNODE_SELECTION} 'sudo sh -c "systemctl restart kubelet.service"'
echo "Restarting Kubernetes services on all nodes..."
for ((i=0; i < $NODECOUNT; i++))
do
echo "Restarting Kubernetes services on the ${IPADDR_$i} node..."
ssh -n $USERNAME_$i@${IPADDR_$i} 'sudo sh -c "systemctl restart kubelet.service"'
done

View File

@ -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:
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.

View File

@ -1,77 +1,77 @@
#!/bin/bash
# Function to display the main menu
function show_menu() {
clear
echo "======================================"
echo " Proxmox Helper Script Installer"
echo "======================================"
echo "1. Install PVE-No-Subscription-Warning"
echo "2. Install PVE Kernel Module Patcher"
echo "3. Install PVE VM Backup Script"
echo "4. Exit"
echo "======================================"
}
# Function to install the PVE No Subscription Warning script
function install_pve_no_subscription_warning() {
clear
echo "Installing PVE-No-Subscription-Warning..."
# Backup important configuration files
backup_file "/etc/apt/sources.list"
# 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
chmod +x /usr/local/bin/pve-no-subscription-warning
echo "PVE-No-Subscription-Warning installed successfully!"
read -n 1 -s -r -p "Press any key to continue..."
}
# Function to install the PVE Kernel Module Patcher script
function install_pve_kernel_module_patcher() {
clear
echo "Installing PVE Kernel Module Patcher..."
# Backup important configuration files
backup_file "/etc/modprobe.d/proxmox-no-subscription.conf"
# 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
chmod +x /usr/local/bin/pve-kernel-module-patcher
echo "PVE Kernel Module Patcher installed successfully!"
read -n 1 -s -r -p "Press any key to continue..."
}
# Function to install the PVE VM Backup Script
function install_pve_vm_backup_script() {
clear
echo "Installing PVE VM Backup Script..."
# 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
chmod +x /usr/local/bin/pve-vm-backup
echo "PVE VM Backup Script installed successfully!"
read -n 1 -s -r -p "Press any key to continue..."
}
# Function to backup files
function backup_file() {
local file=$1
if [ -f $file ]; then
local timestamp=$(date +%Y%m%d_%H%M%S)
local backup_file="/root/backup_$timestamp_$(basename $file)"
echo "Backing up $file to $backup_file"
rsync -a --delete $file $backup_file
else
echo "$file does not exist. Skipping backup."
fi
}
# Main loop
while true; do
show_menu
read -p "Please enter your choice: " choice
case $choice in
1) install_pve_no_subscription_warning ;;
2) install_pve_kernel_module_patcher ;;
3) install_pve_vm_backup_script ;;
4) exit 0 ;;
*) echo "Invalid option. Please enter a number between 1 and 4." ;;
esac
#!/bin/bash
# Function to display the main menu
function show_menu() {
clear
echo "======================================"
echo " Proxmox Helper Script Installer"
echo "======================================"
echo "1. Install PVE-No-Subscription-Warning"
echo "2. Install PVE Kernel Module Patcher"
echo "3. Install PVE VM Backup Script"
echo "4. Exit"
echo "======================================"
}
# Function to install the PVE No Subscription Warning script
function install_pve_no_subscription_warning() {
clear
echo "Installing PVE-No-Subscription-Warning..."
# Backup important configuration files
backup_file "/etc/apt/sources.list"
# 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
chmod +x /usr/local/bin/pve-no-subscription-warning
echo "PVE-No-Subscription-Warning installed successfully!"
read -n 1 -s -r -p "Press any key to continue..."
}
# Function to install the PVE Kernel Module Patcher script
function install_pve_kernel_module_patcher() {
clear
echo "Installing PVE Kernel Module Patcher..."
# Backup important configuration files
backup_file "/etc/modprobe.d/proxmox-no-subscription.conf"
# 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
chmod +x /usr/local/bin/pve-kernel-module-patcher
echo "PVE Kernel Module Patcher installed successfully!"
read -n 1 -s -r -p "Press any key to continue..."
}
# Function to install the PVE VM Backup Script
function install_pve_vm_backup_script() {
clear
echo "Installing PVE VM Backup Script..."
# 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
chmod +x /usr/local/bin/pve-vm-backup
echo "PVE VM Backup Script installed successfully!"
read -n 1 -s -r -p "Press any key to continue..."
}
# Function to backup files
function backup_file() {
local file=$1
if [ -f $file ]; then
local timestamp=$(date +%Y%m%d_%H%M%S)
local backup_file="/root/backup_$timestamp_$(basename $file)"
echo "Backing up $file to $backup_file"
rsync -a --delete $file $backup_file
else
echo "$file does not exist. Skipping backup."
fi
}
# Main loop
while true; do
show_menu
read -p "Please enter your choice: " choice
case $choice in
1) install_pve_no_subscription_warning ;;
2) install_pve_kernel_module_patcher ;;
3) install_pve_vm_backup_script ;;
4) exit 0 ;;
*) echo "Invalid option. Please enter a number between 1 and 4." ;;
esac
done

View File

@ -1,82 +1,82 @@
#!/bin/bash
# ASCII Art
echo "================================="
echo " █████╗ ██╗ ██╗ ██╗ ██╗ ██╗███╗ ██╗███████╗████████╗ █████╗ ██╗ ██╗ ███████╗██████╗
██╔══██╗███║███║███║███║ ██║████╗ ██║██╔════╝╚══██╔══╝██╔══██╗██║ ██║ ██╔════╝██╔══██╗
███████║╚██║╚██║╚██║╚██║ ██║██╔██╗ ██║███████╗ ██║ ███████║██║ ██║ █████╗ ██████╔╝
██╔══██║ ██║ ██║ ██║ ██║ ██║██║╚██╗██║╚════██║ ██║ ██╔══██║██║ ██║ ██╔══╝ ██╔══██╗
██║ ██║ ██║ ██║ ██║ ██║ ██║██║ ╚████║███████║ ██║ ██║ ██║███████╗███████╗███████╗██║ ██║
╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝╚═╝ ╚═╝"
echo "================================="
# Function to install Nvidia CUDA toolkit
install_cuda() {
echo "Step 1: Installing Nvidia CUDA Toolkit..."
sudo apt update
sudo apt install -y nvidia-driver-550 cuda-toolkit
echo "NVIDIA CUDA Toolkit installation completed."
}
# Function to install dependencies for AUTOMATIC1111 Stable Diffusion
install_dependencies() {
echo "Step 2: Installing required dependencies for AUTOMATIC1111 Stable Diffusion..."
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
# Install Python 3.11 from source
echo "Downloading and installing Python 3.11..."
wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz
tar -xf Python-3.11.0.tgz
cd Python-3.11.0
./configure --enable-optimizations
make -j $(nproc)
sudo make altinstall
echo "Python 3.11 installation completed."
# Install pip and dependencies for stable-diffusion-webui
python3.11 -m pip install --upgrade pip
echo "Installing Python packages..."
pip3.11 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu118
pip3.11 install gradio transformers diffusers
echo "Dependencies installation completed."
}
# Function to clone and setup AUTOMATIC1111 Stable Diffusion web ui
install_stable_diffusion() {
echo "Step 3: Cloning AUTOMATIC1111 Stable Diffusion web UI..."
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
cd stable-diffusion-webui
}
# Main menu
while true; do
echo "=========================="
echo "AUTOMATIC1111 Stable Diffusion Installer"
echo "=========================="
echo "Please select an option:"
echo "1. Install Nvidia CUDA Toolkit (NVIDIA Driver 550)"
echo "2. Install required dependencies for AUTOMATIC1111 Stable Diffusion (Python 3.11)"
echo "3. Install AUTOMATIC1111 stable diffusion web ui itself"
echo "4. Exit"
read -p "Enter your choice [1-4]: " choice
case $choice in
1)
install_cuda
;;
2)
install_dependencies
;;
3)
install_stable_diffusion
;;
4)
echo "Exiting..."
exit 0
;;
*)
echo "Invalid option. Please try again."
;;
esac
#!/bin/bash
# ASCII Art
echo "================================="
echo " █████╗ ██╗ ██╗ ██╗ ██╗ ██╗███╗ ██╗███████╗████████╗ █████╗ ██╗ ██╗ ███████╗██████╗
██╔══██╗███║███║███║███║ ██║████╗ ██║██╔════╝╚══██╔══╝██╔══██╗██║ ██║ ██╔════╝██╔══██╗
███████║╚██║╚██║╚██║╚██║ ██║██╔██╗ ██║███████╗ ██║ ███████║██║ ██║ █████╗ ██████╔╝
██╔══██║ ██║ ██║ ██║ ██║ ██║██║╚██╗██║╚════██║ ██║ ██╔══██║██║ ██║ ██╔══╝ ██╔══██╗
██║ ██║ ██║ ██║ ██║ ██║ ██║██║ ╚████║███████║ ██║ ██║ ██║███████╗███████╗███████╗██║ ██║
╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝╚═╝ ╚═╝"
echo "================================="
# Function to install Nvidia CUDA toolkit
install_cuda() {
echo "Step 1: Installing Nvidia CUDA Toolkit..."
sudo apt update
sudo apt install -y nvidia-driver-550 cuda-toolkit
echo "NVIDIA CUDA Toolkit installation completed."
}
# Function to install dependencies for AUTOMATIC1111 Stable Diffusion
install_dependencies() {
echo "Step 2: Installing required dependencies for AUTOMATIC1111 Stable Diffusion..."
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
# Install Python 3.11 from source
echo "Downloading and installing Python 3.11..."
wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz
tar -xf Python-3.11.0.tgz
cd Python-3.11.0
./configure --enable-optimizations
make -j $(nproc)
sudo make altinstall
echo "Python 3.11 installation completed."
# Install pip and dependencies for stable-diffusion-webui
python3.11 -m pip install --upgrade pip
echo "Installing Python packages..."
pip3.11 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu118
pip3.11 install gradio transformers diffusers
echo "Dependencies installation completed."
}
# Function to clone and setup AUTOMATIC1111 Stable Diffusion web ui
install_stable_diffusion() {
echo "Step 3: Cloning AUTOMATIC1111 Stable Diffusion web UI..."
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
cd stable-diffusion-webui
}
# Main menu
while true; do
echo "=========================="
echo "AUTOMATIC1111 Stable Diffusion Installer"
echo "=========================="
echo "Please select an option:"
echo "1. Install Nvidia CUDA Toolkit (NVIDIA Driver 550)"
echo "2. Install required dependencies for AUTOMATIC1111 Stable Diffusion (Python 3.11)"
echo "3. Install AUTOMATIC1111 stable diffusion web ui itself"
echo "4. Exit"
read -p "Enter your choice [1-4]: " choice
case $choice in
1)
install_cuda
;;
2)
install_dependencies
;;
3)
install_stable_diffusion
;;
4)
echo "Exiting..."
exit 0
;;
*)
echo "Invalid option. Please try again."
;;
esac
done

View File

@ -1,19 +1,19 @@
# /etc/systemd/system/sd-webui.service
[Service]
ExecStart=/bin/bash /home/oliver/stable-diffusion-webui/webui.sh
Restart=always
WorkingDirectory=/home/oliver/stable-diffusion-webui
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=sd-webui
User=oliver
[Install]
WantedBy=multi-user.target
# usage
#
# sudo mv sd-webui.service /etc/systemd/system/sd-webui.service
# /etc/systemd/system/sd-webui.service
[Service]
ExecStart=/bin/bash /home/oliver/stable-diffusion-webui/webui.sh
Restart=always
WorkingDirectory=/home/oliver/stable-diffusion-webui
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=sd-webui
User=oliver
[Install]
WantedBy=multi-user.target
# usage
#
# sudo mv sd-webui.service /etc/systemd/system/sd-webui.service
# sudo systemctl start sd-webui

View File

@ -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.
The script should include the following options:
1) Make the following modifications to Windows:
1) Revert to the old explorer context menu.
2) Enable hidden files 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:
1) OpenRGB
2) FanControl
3) System Informer
4) WizTree
5) Rustdesk (remote desktop software)
6) XnViewMP (image viewer)
7) Browsers:
1) Mozilla Firefox
2) Waterfox
3) Zen Browser
4) Thorium
5) Chromium
6) Vivaldi
8) UniGetUI (package manager)
9) ShareX
10) Windhawk
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.
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:
1) Make the following modifications to Windows:
1) Revert to the old explorer context menu.
2) Enable hidden files 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:
1) OpenRGB
2) FanControl
3) System Informer
4) WizTree
5) Rustdesk (remote desktop software)
6) XnViewMP (image viewer)
7) Browsers:
1) Mozilla Firefox
2) Waterfox
3) Zen Browser
4) Thorium
5) Chromium
6) Vivaldi
8) UniGetUI (package manager)
9) ShareX
10) Windhawk
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.