This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
CADVISOR_PORT=9101 | |
IPSET_NAME=cadvisor_whitelist | |
CHAIN_NAME=cadvisor_firewall | |
# Function to install necessary packages | |
install_packages() { | |
if command -v apt-get >/dev/null 2>&1; then | |
apt-get update -y | |
apt-get install -y ipset iptables |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e # Stop the script if any command fails | |
TMP_APP_FILE="/tmp/node_exporter_install.sh" | |
TMP_FW_FILE="/tmp/node_exporter_firewall.sh" | |
NODE_EXPORTER_APP_URL="https://gist.githubusercontent.com/NotYusta/7f0121db2fb01c60edb3d64ad1b9cd27/raw/dd98f7a7a9ef0dfd552679474a116514a48548ee/install_node_exporter.sh" | |
NODE_EXPORTER_FW_URL="https://gist.githubusercontent.com/NotYusta/a0aa75ccd11f8966ececd50916a08be2/raw/9884a086c9f55615bab741272340c83214f6d1c3/node_exporter_firewall.sh" | |
# Prompt user for IP list | |
echo "Enter IPs separated by commas (e.g., 1.2.3.4,5.6.7.0/24):" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Function to download and extract cadvisor | |
install_cadvisor() { | |
curl -sLo /bin/node-exporter https://github.com/google/cadvisor/releases/download/v0.52.1/cadvisor-v0.52.1-linux-amd64 | |
chmod +x /bin/node-exporter | |
} | |
# Function to create systemd service for cadvisor | |
create_systemd_service() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
PORT=9100 | |
BIN_DIR="/usr/local/bin" | |
SERVICE_NAME="node-exporter" | |
BINARY_NAME="node-exporter" | |
VERSION="1.9.1" | |
DOWNLOAD_URL="https://github.com/prometheus/node_exporter/releases/download/v${VERSION}/node_exporter-${VERSION}.linux-amd64.tar.gz" | |
# Function to download and extract node_exporter | |
install_node_exporter() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo -n "Enter new Go package name: " | |
read pkg_name | |
# Get the previous package name from go.mod | |
prev_pkg_name=$(grep '^module ' go.mod | awk '{print $2}') | |
# Update go.mod | |
go mod edit -module $pkg_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 🔹 Backup directory for rollback | |
BACKUP_DIR="/root/.ssh-security-backup" | |
SUDO_GROUP="sudo" | |
generate_password() { | |
local password length num_count special_count char_count | |
while true; do | |
# Random total length between 24 and 32 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
DIR_PATH="$HOME/database-backup" | |
OUTDIR_PATH="$DIRPATH/out" | |
CLEAR_PERIOD="7" | |
cd $DIR_PATH | |
# Ensure the output directory exists | |
mkdir -p "$OUTDIR_PATH" | |
# Make sure the backup script is executable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if the user provided a path argument | |
if [ -z "$1" ]; then | |
echo "Usage: $0 <path>" | |
exit 1 | |
fi | |
# Set the PATH variable to the user-provided argument | |
SEARCH_PATH=$1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if exactly one argument (vm-id) is provided | |
if [ $# -ne 1 ]; then | |
echo "Usage: $0 <vm-id>" | |
exit 1 | |
fi | |
VMID="$1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Function to check the exit status of the last command | |
check_error() { | |
if [ $? -ne 0 ]; then | |
echo "Error: $1" | |
exit 1 | |
fi | |
} |