57 lines
1.7 KiB
Bash
57 lines
1.7 KiB
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
# Container Utility Functions
|
||
|
|
# Consolidated functions from small container-related scripts
|
||
|
|
# Usage: source "$(dirname "${BASH_SOURCE[0]}")/../utils/container-utils.sh"
|
||
|
|
|
||
|
|
set -euo pipefail
|
||
|
|
|
||
|
|
# Load IP configuration
|
||
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||
|
|
source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
|
||
|
|
|
||
|
|
|
||
|
|
# Load shared modules
|
||
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||
|
|
source "$SCRIPT_DIR/../lib/ip-config.sh" 2>/dev/null || true
|
||
|
|
source "$SCRIPT_DIR/../lib/logging.sh" 2>/dev/null || true
|
||
|
|
source "$SCRIPT_DIR/../lib/proxmox-api.sh" 2>/dev/null || true
|
||
|
|
|
||
|
|
# Container status check
|
||
|
|
container_status() {
|
||
|
|
local vmid="$1"
|
||
|
|
local host="${2:-${PROXMOX_HOST_ML110:-192.168.11.10}}"
|
||
|
|
check_container_status "$vmid" "$host"
|
||
|
|
}
|
||
|
|
|
||
|
|
# Container restart
|
||
|
|
container_restart() {
|
||
|
|
local vmid="$1"
|
||
|
|
local host="${2:-${PROXMOX_HOST_ML110:-192.168.11.10}}"
|
||
|
|
log_info "Restarting container $vmid on $host"
|
||
|
|
ssh_proxmox "$host" "pct restart $vmid" || true
|
||
|
|
}
|
||
|
|
|
||
|
|
# Container start
|
||
|
|
container_start() {
|
||
|
|
local vmid="$1"
|
||
|
|
local host="${2:-${PROXMOX_HOST_ML110:-192.168.11.10}}"
|
||
|
|
log_info "Starting container $vmid on $host"
|
||
|
|
ssh_proxmox "$host" "pct start $vmid" || true
|
||
|
|
}
|
||
|
|
|
||
|
|
# Container stop
|
||
|
|
container_stop() {
|
||
|
|
local vmid="$1"
|
||
|
|
local host="${2:-${PROXMOX_HOST_ML110:-192.168.11.10}}"
|
||
|
|
log_info "Stopping container $vmid on $host"
|
||
|
|
ssh_proxmox "$host" "pct stop $vmid" || true
|
||
|
|
}
|
||
|
|
|
||
|
|
# List all containers
|
||
|
|
container_list() {
|
||
|
|
local host="${1:-${PROXMOX_HOST_ML110:-192.168.11.10}}"
|
||
|
|
ssh_proxmox "$host" "pct list" || true
|
||
|
|
}
|