1. ai postgresql
  2. systemctl status postgresql
  3. /etc/postgresql/15/main/pg_hba.conf

psql

  1. LANG=C
  2. psql -U postgres -c "SELECT datname FROM pg_catalog.pg_database;"
  3. psql -U postgres -c "DROP DATABASE DBNAME;"
  4. psql -U postgres -c "SELECT * FROM pg_catalog.pg_user;"

📦 Gitea Pull & Push Workflow

⚡ Schnellstart

mkdir -p ~/scripts && \
curl -L https://gitea.bubuit.net/oib/at2-workstation-scripts/raw/branch/main/gitea_push.sh \
  -o ~/scripts/gitea_push.sh && \
chmod +x ~/scripts/gitea_push.sh && \
echo "[INFO] gitea_push.sh ready in ~/scripts"

➡️ Lädt die aktuelle Version direkt von Gitea, macht sie ausführbar und gibt eine Info aus.

Tags
#!/bin/zsh
# Version 01.0
# Script to test DNS zone propagation across ns1, ns2, and ns3
# Script Name: test_ns_zones.sh

# Variables
NS1="23.88.113.138"
NS2="116.202.112.180"
NS3="95.216.198.140"

# Check if a domain name argument is provided
if [ -z "$1" ]; then
	echo "Usage: $0 <domain.tld>"
	exit 1
fi

DOMAIN=$1

# Function to test a DNS query
function test_ns {
	local NS=$1
	echo "
=== Testing $DOMAIN on $NS ==="
	dig @$NS $DOMAIN SOA +short
echo ""
	echo "MX Record:"
	dig @$NS $DOMAIN MX +short
echo ""
	echo "A Record for mail.$DOMAIN:"
	dig @$
Tags
#!/bin/zsh
# Version 01.0
# Script to add a new slave zone to /etc/bind/named.conf.local on ns2.dynproxy.net
# Script Name: bind_add_slave_zone.sh

# Variables
NAMED_CONF="/etc/bind/named.conf.local"
CACHE_DIR="/var/cache/bind"

# Check if a domain name argument is provided
if [ -z "$1" ]; then
	echo "Usage: $0 <domain.tld>"
	exit 1
fi

DOMAIN=$1
ZONE_FILE="$CACHE_DIR/db.$DOMAIN"

# Check if the zone configuration already exists
if grep -q "zone \"$DOMAIN\"" $NAMED_CONF; then
	echo "Zone $DOMAIN already exists in $NAMED_CONF.
Tags
#!/bin/zsh
# Version 01.0
# Script to add a new slave zone to /etc/bind/named.conf.local on ns3.dynproxy.net
# Script Name: bind_add_slave_zone_ns3.sh

# Variables
NAMED_CONF="/etc/bind/named.conf.local"
CACHE_DIR="/var/cache/bind"

# Check if a domain name argument is provided
if [ -z "$1" ]; then
	echo "Usage: $0 <domain.tld>"
	exit 1
fi

DOMAIN=$1
ZONE_FILE="$CACHE_DIR/$DOMAIN.db"

# Check if the zone configuration already exists
if grep -q "zone \"$DOMAIN\"" $NAMED_CONF; then
	echo "Zone $DOMAIN already exists in $NAMED_CONF.
Tags
#!/bin/zsh
# Version 01.0
# Script to add a new zone to /etc/bind/named.conf.local on ns1.dynproxy.net
# Script Name: bind_add_zone.sh

# Variables
NAMED_CONF="/etc/bind/named.conf.local"
ZONES_DIR="/etc/bind/zones"

# Check if a domain name argument is provided
if [ -z "$1" ]; then
	echo "Usage: $0 <domain.tld>"
	exit 1
fi

DOMAIN=$1
ZONE_FILE="$ZONES_DIR/db.$DOMAIN"

# Check if the zone file already exists
if [ -f "$ZONE_FILE" ]; then
	echo "Zone file $ZONE_FILE already exists.
Tags

#!/bin/zsh
# Script Version: 10
# Description: Dyn DNS update script, checks token, compares IPs, and updates DNS zone if needed.

# Set variables
# ========
TOKEN_FILE="/root/scripts/dynProxy/token.txt"
IP_FILE="/root/scripts/dynProxy/ip.txt"
UPDATE_URL="http://ip.dynproxy.net/update_zone"
LOG_FILE="/var/log/update_zone.log"

# Functions
# ========
log() {
    print "$(date '+%Y-%m-%dT%H:%M:%S.%6N'): $1" >> "$LOG_FILE"
}

#!/bin/zsh
# Script Version: 12.4
# Description: Dyn DNS update script, checks token and updates DNS zone.

# Set variables
DIRECTORY="/var/www/ip/token"
LOG_FILE="/var/log/dynProxy.log"
TOKEN_DNS_ZONE_FILE="/etc/bind/tokendnszone.conf"
NSUPDATE_SERVER="127.0.0.1"
DEBUG=true

log() {
   local message="$1"
   echo "$(date '+%Y-%m-%dT%H:%M:%S.%6N'): $message" >> "$LOG_FILE"
   if $DEBUG; then echo "$message"; fi
}

log_debug() {
   if $DEBUG; then log "$1"; fi
}

#!/bin/bash
# Script Version: 02
# Description: Drops all tables in a specified MySQL database. If only one argument is given, the user and database name will be the same.

# Check arguments
if [ $# -lt 1 ]; then
    echo "Usage: $0 <DB_USER> [DB_NAME]"
    exit 1
fi

# Assign arguments
DB_USER=$1
DB_NAME=${2:-$1} # If no second argument is provided, use the first as the database name.

# Prompt for password
read -sp "Enter MySQL password: " DB_PASS
echo

# Confirmation prompt
read -p "Are you sure you want to drop all tables in $DB_NAME?
Tags
#!/bin/zsh
# Script Version: 1.1
# Description: Create MySQL Database and User (same name) with generated password

# Set variables
DBNAME=$1
PASSWORD=""
LOG_FILE="/var/log/mysql_db_user_creation.log"

# Functions
ask_for_input() {
    if [ -z "$DBNAME" ]; then
        read "DBNAME?Enter the database and username: "
    fi
}

generate_password() {
    PASSWORD=$(openssl rand -base64 12)
}

create_db_and_user() {
    echo "Creating MySQL Database and User..."
    mysql -u root -p <<EOF
CREATE DATABASE IF NOT EXISTS \`$DBNAME\`;
CREATE USER IF NOT EXIS
Tags
#!/bin/bash
# Script Name: sendmail_test.sh
# Version: 03
# Description: This script sends a test email using sendmail. The recipient's email address is the first argument.
#              It logs messages to the console only.

# Check if an argument (email address) is provided
if [ -z "$1" ]; then
    TO="root"
else
    TO="$1"
fi

# Email details
SUBJECT="Postfix Test"
FROM="$(whoami)@$(hostname)"
BODY="This is the email body!"

# Function to send email
send_email() {
    if !
#!/bin/bash
# =============================================================================
# Script Name: lxc_list_login.sh
# Version: 03
# Description: Lists LXC containers, checks their statuses, and allows login.
# =============================================================================

# Required commands
REQUIRED_CMDS=("lxc-ls" "lxc-info" "lxc-start" "lxc-attach")

# Check if required commands are available
for CMD in "${REQUIRED_CMDS[@]}"; do
    if ! command -v "$CMD" &> /dev/null; then
        echo "The command $CMD is not installed.
Tags
#!/bin/zsh
# Script Version: 02
# Description: List available Borg backups in the specified repository

# Set variables
# ========
REPO1="ssh://"
BORG_PASSPHRASE_FILE="/root/.borg_passphrase"

# Functions
# ========
log_message() {
    echo "$(date +"%Y-%m-%d %H:%M:%S") - $1"
}

# Main Process
# ========
log_message "Listing available backups in repository."

# Ensure Borg passphrase file is available
if [ -f "$BORG_PASSPHRASE_FILE" ]; then
    export BORG_PASSPHRASE=$(<"$BORG_PASSPHRASE_FILE")
else
    log_message "Borg passphrase file not found."
    
Tags
#!/usr/bin/zsh
# Script Version: 01
# Description: Script to obtain the public IP and post it to a server securely.

# Define the path to store the token
TOKEN_FILE="/root/scripts/token.txt"
LOG_FILE="/var/log/ipgetpost.log"
IP_URL="http://ip.dynproxy.net"

# Function to log messages
log_message() {
    print "$(date): $1" >> "$LOG_FILE"
}

# Set umask to ensure files are created with the correct permissions
umask 077

# Check if the token file already exists, if not, generate a new token
if [ !
  1. openssl passwd -apr1 your_password
  2. echo 'your_username:hashed_password' >> /etc/nginx/.htpasswd
  3. chmod 640 /etc/nginx/.htpasswd
  4. chown root:www-data /etc/nginx/.htpasswd
  5. vim /etc/nginx/sites-available/
location / {
auth_basic "Restricted Access";
auth_basic_user_file /etc/nginx/.htpasswd;
}

script

#!/bin/zsh
# Script Version: 01
# Description: Prompt for username, generate password, hash it, and save to Nginx .htpasswd

# Set variables
# ========
Tags
#!/bin/sh
# Version: 1.2
# Description: Automates Borg backup process with logging, error handling,
#              and repository initialization if required.

set -e

# =============================================================================
# Configuration
# =============================================================================

# Hostname setup
FULL_HOSTNAME=$(hostname)
SHORT_HOSTNAME=$(hostname -s)

# Passphrase file
BORG_PASSPHRASE_FILE=~/.borg_passphrase

# SSH key file location
SSH_KEY="/root/.ssh/id_ed25519_$SHORT_HOSTNAME"

# Backup ser
Tags
#!/bin/bash
# Version: 1.0
# Description: This script lists all the archives in a Borg repository

set -euo pipefail

# Check if whiptail is installed
if ! command -v whiptail &> /dev/null; then
  echo "whiptail is required but not installed.
Tags
#!/bin/bash
# v01

# List and check LXC containers
echo "Listing all LXC containers..."
CONTAINERS=($(lxc-ls -1))

# Check if there are any containers
if [[ ${#CONTAINERS[@]} -eq 0 ]]; then
    echo "There are no LXC containers."
    exit 1
fi

echo "Found ${#CONTAINERS[@]} container(s): ${CONTAINERS[@]}"
echo "----------------------------------"

# Loop over each container
for LXCHOSTNAME in "${CONTAINERS[@]}"; do
    echo "Processing container: $LXCHOSTNAME"

    # Stop the container
    echo "Stopping container $LXCHOSTNAME..."
    if !
#!/bin/bash
# Script Version: 1.0
# Description: This script searches through BorgBackup archives for files matching a specific pattern.

set -euo pipefail

# Variables
HOSTNAME=$(hostname)
BORG_PASSPHRASE_FILE="$HOME/.borg_passphrase"
SSH_KEY="/root/.ssh/id_ed25519_$HOSTNAME"
REPO1=".at:/./borg"
LOG="/var/log/borg_find.log"
PATTERN="${1:-}" # File pattern to search for (provided as the first argument)

# Load Borg passphrase
if [ -f "$BORG_PASSPHRASE_FILE" ]; then
  export BORG_PASSPHRASE=$(cat "$BORG_PASSPHRASE_FILE")
else
  echo "Passphrase file not fou
Tags
#!/bin/bash
# =============================================================================
# Script Name: lxc_create_container.sh
# Version: 1.1
# Description: This script creates a new LXC container from a template, assigns
#              a unique MAC address, updates the hostname and /etc/hosts file,
#              and verifies internet access.
# =============================================================================

# Prompt for the new container hostname
read -e -p "LXCHOSTNAME: " LXCHOSTNAME
export LXCHOSTNAME

# Check if the template containe
Tags
#!/bin/bash
# Script Version: 1.2
# Description: Send a file via email to a specified recipient

# Set variables
EMAIL_SUBJECT="File Attachment"
EMAIL_BODY="Please find the attached file."

# Check if both email and file path are provided as arguments
if [ $# -ne 2 ]; then
   echo "Usage: $0 recipient@example.com /path/to/your/file.gz"
   exit 1
fi
RECIPIENT_EMAIL="$1"
ATTACHMENT_PATH="$2"

# Check if the file exists
if [ !
Tags
#!/bin/bash
# =============================================================================
# Script Name: f2b_status.sh
# Version: 1.6
# Description: This script retrieves and displays the status of all Fail2Ban
#              jails, including error handling and logging.
# =============================================================================

# Log file path
LOG_FILE="/var/log/fail2ban-status.log"

# Function to log messages with timestamp
log_message() {
    echo "$(date +"%Y-%m-%d %H:%M:%S") - $1" | tee -a "$LOG_FILE"
}

# Function to retrieve t
#!/bin/sh
# Version: 1.3
# Description: Update DNS blocklist and ensure script runs in the background

LOCKFILE="/var/run/dnsbl-ipset.lock"
LOGFILE="/var/log/dnsbl-ipset.log"

# Ensure the script runs in the background
if [ -z "$BACKGROUND" ]; then
  BACKGROUND=true nohup "$0" "$@" >> $LOGFILE 2>&1 &
  exit 0
fi

{
  echo "[$(date)] Starting dnsbl-update script"

  if [ !
#!/bin/bash
# =============================================================================
# Script Name: lxc_list_sed.sh
# Version: 1.10
# Description: This script lists all LXC containers, checks their statuses, and
#              updates the SENDMAILTO field in /etc/logcheck/logcheck.conf for 
#              running containers.
Tags
#!/bin/bash
# =============================================================================
# Script Name: ipset_blacklist_reload.sh
# Version: 1.1
# Author: Andreas Fleckl
# Description: This script reloads an ipset with CIDR /24 network ranges from a 
#              specified file, including error handling and logging.
# =============================================================================

# Define your ipset name
IPSET_NAME="blacklist"

# Path to your list of IP network ranges, one per line
IP_LIST_PATH="/etc/firehol/blacklist.netset"

# Log fi
#!/bin/bash
# =============================================================================
# Script Name: docker_pgsql_backup.sh
# Version: 1.0
# Author: Andreas Fleckl
# Description: This script performs backups of PostgreSQL databases running in 
#              Docker containers.
#!/bin/sh
# =============================================================================
# Script Name: dnsbl_stats.sh
# Version: 1.1
# Author: Andreas Fleckl
# Description: This script processes the DNSBL blacklist log, generates reports
#              on IP addresses at different levels of granularity, and emails 
#              these reports.
#!/bin/zsh
# =============================================================================
# Script Name: f2b_check_ips.sh
# Version: 1.1
# Author: Andreas Fleckl
# Description: This script extracts and prints all banned IPs from Fail2Ban
#              jails, with an option to filter IPs based on a search argument.
#              Includes error handling and logging.
# =============================================================================

# Function to extract the list of jails
extract_jail_list() {
    # Run fail2ban-client status and extract the 
#!/bin/bash
# =============================================================================
# Script Name: lxc_package_install.sh
# Version: 1.1
# Author: Andreas Fleckl
# Description: This script installs a specified package in all running LXC
#              containers.
#!/bin/sh
# =============================================================================
# Script Name: hostname_update.sh
# Version: 1.1
# Author: Andreas Fleckl
# Description: This script retrieves the public IP address, performs a reverse 
#              DNS lookup, updates the system's hostname, and restarts the 
#              Postfix service.
Tags

listmonk/listmonk_create.sh

#!/bin/bash
# =============================================================================
# Script Name: listmonk_create.sh
# Version: 1.1
# Author: Andreas Fleckl
# Description: This script sets up a new Listmonk instance with a unique
#              configuration, database, and nginx setup.
Tags
#!/bin/sh
# =============================================================================
# Script Name: borg_backup_hetzner.sh
# Version: 1.2
# Author: Andreas Fleckl
# Description: This script performs backups using Borg to a Hetzner Storage Box.
#              It reads directories to backup and exclude from specified files,
#              handles logging, performs pruning of old backups, and sends
#              notifications about the backup status.
# =============================================================================

# Backup repository loc
Tags