dx/dxkit/modules/apache.module.sh

75 lines
No EOL
1.9 KiB
Bash

#!/usr/bin/env bash
# modules/apache.module.sh
#
# Apache management module.
# Handles vhost generation, config validation, reloads, and module toggling.
#
# Runs commands through runtime::exec so it works identically with
# Docker and native runtimes.
# ============================================
# Vhost generation
# ============================================
function apache::generate_vhosts() {
log::env_load "Generating Virtual Hosts (${ENVIRONMENT})..."
template::render \
"$(app::vhost_template_path)" \
"$(ctx::artifact::path apache vhosts vhosts.conf)" \
APP_PATH="$(ctx::container::root)"
}
# ============================================
# Config validation
# ============================================
function apache::validate_config() {
runtime::exec apache2ctl configtest
}
# ============================================
# Lifecycle
# ============================================
function apache::reload() {
runtime::exec apache2ctl graceful
}
function apache::restart() {
runtime::exec apache2ctl restart
}
# ============================================
# Inspection
# ============================================
function apache::list_vhosts() {
runtime::exec apache2ctl -S
}
function apache::list_modules() {
runtime::exec apache2ctl -M
}
function apache::version() {
runtime::exec apache2 -v
}
# ============================================
# Logs
# ============================================
function apache::logs::error() { runtime::exec tail -f /var/log/apache2/error.log; }
function apache::logs::access() { runtime::exec tail -f /var/log/apache2/access.log; }
# ============================================
# Module management
# ============================================
function apache::module::enable() { runtime::exec a2enmod "$@"; }
function apache::module::disable() { runtime::exec a2dismod "$@"; }
function apache::module::is_enabled() {
runtime::exec a2query -m "$1" >/dev/null 2>&1
}