Compare commits

..

11 Commits

12 changed files with 815 additions and 36 deletions

View File

@ -1,42 +1,88 @@
#!/bin/bash
# Update and upgrade the system
sudo apt update
sudo apt upgrade -y
# Function to print a header with a description
print_header() {
echo "------------------------------------------------------------"
echo $1
}
# Add a new user to run Docker
echo "Adding a new user to run Docker (username 'docker' is recommended)..."
read -p "Enter username for the new Docker user: " USERNAME
sudo useradd -m -s /bin/bash $USERNAME
sudo usermod -aG docker $USERNAME
echo "New user $USERNAME added to the docker group."
# 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
}
# Install required dependencies
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
# 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
}
# Add Docker's official GPG key
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
# 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 Docker repository
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
# 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
# Update package index again after adding Docker repository
sudo apt update
# 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
# Install Docker
sudo apt install -y docker-ce
# Update the package list again with progress bar
run_with_progress "sudo apt-get update"
# Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
# 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"
# Install Portainer
sudo docker volume create portainer_data
sudo docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data --restart always --name=portainer portainer/portainer-ce
# Verify that Docker is installed correctly
print_header "Starting and enabling Docker service..."
sudo systemctl start docker
sudo systemctl enable docker
# Check if Portainer container is running
if sudo docker ps | grep -q portainer; then
echo "Portainer container is running successfully."
else
echo "Failed to start Portainer container."
fi
# 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

@ -0,0 +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!"

View File

@ -15,7 +15,7 @@ echo "Installing dependencies..."
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..."1
echo "Checking the minimum system requirements for Graylog..."
# Minimum required RAM (in MB)
minimum_ram=4096

View File

@ -61,10 +61,11 @@ fi
echo "System meets minimum requirements. Proceeding with installation..."
# Add Netbox repository
echo "Adding Netbox repository..."
echo "deb https://packagecloud.io/netbox-community/netbox/ubuntu/ $(lsb_release -sc) main" | tee -a /etc/apt/sources.list.d/netbox-community.list
curl -L https://packagecloud.io/netbox-community/netbox/gpgkey | apt-key add -
# 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

View File

@ -0,0 +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
echo "GPU passthrough setup is complete. Please check your VM for GPU functionality."

View File

@ -0,0 +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!"

View File

@ -0,0 +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

View File

@ -0,0 +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.

View File

@ -17,6 +17,8 @@ function show_menu() {
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
@ -28,6 +30,8 @@ function install_pve_no_subscription_warning() {
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
@ -46,6 +50,19 @@ function install_pve_vm_backup_script() {
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

View File

@ -0,0 +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
done

View File

@ -0,0 +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
# sudo systemctl start sd-webui

View File

@ -0,0 +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.