Compare commits
6 Commits
e2c81a7359
...
master
Author | SHA1 | Date | |
---|---|---|---|
cf94b48a42 | |||
247a12ffba | |||
059a09992a | |||
b2ad3c800a | |||
0682717caa | |||
b94b7b0c64 |
217
grafana-stack-new/install.sh
Normal file
217
grafana-stack-new/install.sh
Normal 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!"
|
@ -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.
|
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.
|
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.
|
||||||
|
|
||||||
|
82
stable-diffusion/sd-install.sh
Normal file
82
stable-diffusion/sd-install.sh
Normal 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
|
19
stable-diffusion/sd-webui.service.sh
Normal file
19
stable-diffusion/sd-webui.service.sh
Normal 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
|
Reference in New Issue
Block a user