feat: rework entire repo structure

This commit is contained in:
2026-02-28 21:31:18 +01:00
parent 98ae07ae88
commit fcbfd3a838
12 changed files with 214 additions and 254 deletions

View File

@@ -1,32 +1,17 @@
#!/bin/bash
set -euo pipefail
PROJECT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
readonly PROJECT_DIR 2>/dev/null
source "$PROJECT_DIR/utils.sh"
readonly PROJECT_NAME="serverconfig"
readonly PROJECT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# set -euo pipefail
readonly REQ=("curl" "docker")
readonly ENV_FILE="${PROJECT_DIR}/.env"
readonly GREEN='\033[0;32m'
readonly RED='\033[0;31m'
readonly YELLOW='\033[1;33m'
readonly BLUE='\033[0;34m'
readonly NC='\033[0m'
DATETIME_FORMAT="%d-%m-%Y %H:%M:%S"
function log() {
local type="${1}"
local color="${2}"
local message="${3}"
echo -e "${color}[$(date +"$DATETIME_FORMAT")] [${type}]${NC} ${message}"
}
function log_info() { log "INFO" "$BLUE" "$1"; }
function log_success() { log "OK " "$GREEN" "$1"; }
function log_error() { log "ERR " "$RED" "$1" >&2; }
ENV_LIST=(
"EMAIL" "HOSTNAME"
"TELEGRAM_TOKEN" "TELEGRAM_CHAT_ID"
"AWS" "ENDPOINT" "AWS_ACCESS_KEY_ID" "AWS_SECRET_ACCESS_KEY"
"GITHUB_AUTH_SECRET"
)
function check_root() {
if [[ $EUID -ne 0 ]]; then
@@ -49,8 +34,13 @@ function check_dependencies() {
function install_scripts() {
log_info "Installing scripts..."
for script in "$SCRIPT_FILE"/*.sh; do
for script in "$PROJECT_DIR"/*.sh; do
[ -e "$script" ] || continue
if [[ "$script" == "$(realpath "$0")" ]]; then
continue
fi
log_info "Configuring $(basename "$script")..."
if ! bash "$script" --install; then
log_error "Hook failed for $script"
@@ -68,9 +58,17 @@ function main() {
log_info "Creating directories and files..."
touch "$ENV_FILE"
for env in "${ENV_LIST[@]}"; do
read -sp "Enter value for $env: " value
echo
env_variable "$env" "$value"
done
install_scripts
log_success "Installation Complete"
}
main "$@"
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
main "$@"
fi