Compare commits

...

9 Commits

8 changed files with 540 additions and 33 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

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

@ -6,9 +6,9 @@ Please generate me a bash script to deploy a Kubernetes cluster across multiple
3) It should then ask the user which node (by number or IP) they would like to define as the master node/control plane. All other nodes should be assumed to be worker nodes.
4) It should then proceed to use the previously defined SSH credentials to log in to each node sequentially and add the K8S repository and relevant keys.
4) It should then proceed to use the previously defined SSH credentials to log in to each node sequentially and add the K8S repository and relevant keys.
5) Following this, it should log in to each node sequentially and run apt update and apt upgrade, followed by the rebooting of each node. Following the successful execution of this task (and while the nodes are rebooting), the script should include a time delay of 5 minutes while displaying a countdown in seconds to allow each node to reboot.
5) Following this, it should log in to each node sequentially and prompt the user to escalate their session to sudo. It should then run the 'apt update' and 'apt upgrade', followed by the rebooting of each node. Following the successful execution of this task (and while the nodes are rebooting), the script should include a time delay of 5 minutes while displaying a countdown in seconds to allow each node to reboot.
6) It should then proceed to use the credentials of the corresponding node to install K8S on the master node initially. The install must add the official K8S repository to the system sources list and then run apt update before proceeding with the installation.

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.