schon/scripts/Unix/export-environment-file.sh
Egor fureunoir Gorbunov 7d1bcaa8d4 Features: 1) Added validation to ensure scripts execute from project root with 'evibes' directory check; 2) Introduced color formatting and ASCII art for enhanced script output; 3) Added RAM, CPU, and disk space verification to installation scripts; 4) Ensured Docker images existence before service startup; 5) Unified spinner-based progress display in Windows and Unix scripts.
Fixes: 1) Replaced hardcoded paths with script-relative paths for better portability; 2) Corrected CPU and memory calculation logic for system checks; 3) Replaced inconsistent script formatting and error handling; 4) Resolved redundant cleanup steps post service startup.

Extra: Refactored and cleaned up script logic for maintainability; added WISELESS branding across scripts for consistency; enhanced terminal output and user messaging.
2025-06-16 15:40:44 +03:00

62 lines
1.5 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
if [ ! -d "./evibes" ]; then
printf "\e[31m❌ Please run this script from the project's root (where the 'evibes' directory lives).\e[0m\n"
exit 1
fi
PURPLE="\e[38;2;121;101;209m"
RESET="\e[0m"
GRAY="\e[90m"
SOURCE="${BASH_SOURCE[0]:-$0}"
SCRIPT_DIR="$(cd "$(dirname "$SOURCE")" && pwd)"
ART_PATH="$SCRIPT_DIR/../ASCII_ART_EVIBES"
if [ ! -f "$ART_PATH" ]; then
printf "\e[31m❌ Could not find ASCII art at %s\e[0m\n" "$ART_PATH"
exit 1
fi
while IFS= read -r line; do
printf "%b%s%b\n" "$PURPLE" "$line" "$RESET"
done < "$ART_PATH"
printf "\n%bby WISELESS TEAM%b\n\n" "$GRAY" "$RESET"
ENV_FILE=".env"
if [ ! -f "$ENV_FILE" ]; then
printf "\e[31m.env file not found in the current directory.\e[0m\n"
exit 1
fi
declare -A env_vars
declare -a keys
while IFS= read -r raw; do
line="${raw%%#*}"
line="${line%"${line##*[![:space:]]}"}"
line="${line#"${line%%[![:space:]]*}"}"
[ -z "$line" ] || [[ "$line" != *=* ]] && continue
key="${line%%=*}"
value="${line#*=}"
if [[ "${value:0:1}" == '"' && "${value: -1}" == '"' ]] || \
[[ "${value:0:1}" == "'" && "${value: -1}" == "'" ]]; then
value="${value:1:-1}"
fi
export "$key"="$value"
env_vars["$key"]="$value"
keys+=("$key")
done < "$ENV_FILE"
if [ "${#keys[@]}" -gt 0 ]; then
IFS=$'\n' sorted=($(sort <<<"${keys[*]}"))
unset IFS
formatted=""
for k in "${sorted[@]}"; do
[ -z "$formatted" ] && formatted="$k=${env_vars[$k]}" \
|| formatted="$formatted;$k=${env_vars[$k]}"
done
printf "%s\n" "$formatted"
fi