Initial port of KNELServerBuild to FetchApply framework
- Created base FetchApply directory structure with classes, initializers, modules, roles, and variables - Ported SetupNewSystem.sh functionality to modular FetchApply structure - Created server classes: physical, virtual, librenms, database, webserver, dev-workstation - Implemented initializers for system-setup, packages, ssh-keys, and user-configuration - Created modules for oam, system-config, ssh-hardening, and librenms-agent - Defined security and monitoring roles - Copied configuration templates from KNELServerBuild - Updated README with comprehensive FetchApply usage instructions 💘 Generated with Crush Assisted-by: GLM-4.6 via Crush <crush@charm.land>
This commit is contained in:
44
initializers/system-setup/apply
Executable file
44
initializers/system-setup/apply
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
|
||||
# KNEL System Initialization
|
||||
# This initializer performs basic system detection and setup
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
echo "Performing system initialization..."
|
||||
|
||||
# Detect system characteristics
|
||||
export UBUNTU_CHECK="$(grep -c Ubuntu /etc/os-release 2>/dev/null || echo 0)"
|
||||
export IS_PHYSICAL_HOST="$(/usr/sbin/dmidecode -t System 2>/dev/null | grep -c Dell || echo 0)"
|
||||
export SUBODEV_CHECK="$(getent passwd | grep -c subodev || echo 0)"
|
||||
export LOCALUSER_CHECK="$(getent passwd | grep -c localuser || echo 0)"
|
||||
export KALI_CHECK="$(grep -c kali /etc/os-release 2>/dev/null || echo 0)"
|
||||
|
||||
# Detect virtualization
|
||||
if command -v virt-what >/dev/null 2>&1; then
|
||||
export VIRT_TYPE="$(virt-what 2>/dev/null || echo "")"
|
||||
export IS_VIRT_GUEST="$(echo "$VIRT_TYPE" | grep -E -c 'hyperv|kvm' || echo 0)"
|
||||
export IS_KVM_GUEST="$(echo "$VIRT_TYPE" | grep -c 'kvm' || echo 0)"
|
||||
else
|
||||
export VIRT_TYPE=""
|
||||
export IS_VIRT_GUEST="0"
|
||||
export IS_KVM_GUEST="0"
|
||||
fi
|
||||
|
||||
# Detect special host types
|
||||
export LIBRENMS_CHECK="$(hostname | grep -c tsys-librenms || echo 0)"
|
||||
export NTP_SERVER_CHECK="$(hostname | grep -E -c 'pfv-netboot|pfvsvrpi' || echo 0)"
|
||||
export DEV_WORKSTATION_CHECK="$(hostname | grep -E -c 'subopi-dev|CharlesDevServer' || echo 0)"
|
||||
|
||||
# Raspberry Pi detection
|
||||
if command -v vcgencmd >/dev/null 2>&1; then
|
||||
export IS_RASPI="1"
|
||||
else
|
||||
export IS_RASPI="0"
|
||||
fi
|
||||
|
||||
# Set current timestamp for logging
|
||||
export CURRENT_TIMESTAMP="$(date '+%Y-%m-%d %H:%M:%S')"
|
||||
|
||||
echo "System initialization complete"
|
||||
echo "Ubuntu: $UBUNTU_CHECK, Physical: $IS_PHYSICAL_HOST, Virtual: $IS_VIRT_GUEST"
|
||||
Reference in New Issue
Block a user