diff --git a/install.sh b/install.sh index c9077a8..fb7a6a0 100644 --- a/install.sh +++ b/install.sh @@ -7,75 +7,81 @@ source "$PROJECT_DIR/utils.sh" set -euo pipefail ENV_LIST=( - "EMAIL" "HOSTNAME" - "TELEGRAM_TOKEN" "TELEGRAM_CHAT_ID" + "EMAIL" "HOSTNAME" + "TELEGRAM_TOKEN" "TELEGRAM_CHAT_ID" "AWS" "ENDPOINT" "AWS_ACCESS_KEY_ID" "AWS_SECRET_ACCESS_KEY" "GITHUB_AUTH_SECRET" ) readonly REQ=( - "curl" - "docker" + "curl" + "docker" "crontab" - "procps" + "ps" + "top" + "free" + "pgrep" + "pkill" + "uptime" + "sysctl" ) function check_root() { - if [[ $EUID -ne 0 ]]; then - log_error "The script needs to run as root." - exit 1 - fi + if [[ $EUID -ne 0 ]]; then + log_error "The script needs to run as root." + exit 1 + fi } function check_dependencies() { - log_info "Checking system dependencies..." - for cmd in "${REQ[@]}"; do - if ! command -pv "$cmd" &>/dev/null; then - log_error "${cmd} is not installed." - exit 1 - else - log_success "${cmd} is installed." - fi - done + log_info "Checking system dependencies..." + for cmd in "${REQ[@]}"; do + if ! command -pv "$cmd" &>/dev/null; then + log_error "${cmd} is not installed." + exit 1 + else + log_success "${cmd} is installed." + fi + done } function install_scripts() { - log_info "Installing scripts..." - for script in "$PROJECT_DIR"/*.sh; do - [ -e "$script" ] || continue - - if [[ "$script" == "$(realpath "$0")" ]]; then - continue - fi + log_info "Installing scripts..." + for script in "$PROJECT_DIR"/*.sh; do + [ -e "$script" ] || continue - log_info "Configuring $(basename "$script")..." - if ! bash "$script" --install; then - log_error "Hook failed for $script" - fi - done + if [[ "$script" == "$(realpath "$0")" ]]; then + continue + fi + + log_info "Configuring $(basename "$script")..." + if ! bash "$script" --install; then + log_error "Hook failed for $script" + fi + done } function main() { - clear - echo -e "${YELLOW}${PROJECT_NAME} Installation${NC}" + clear + echo -e "${YELLOW}${PROJECT_NAME} Installation${NC}" - check_root - check_dependencies - - log_info "Creating directories and files..." - touch "$ENV_FILE" + check_root + check_dependencies + + log_info "Creating directories and files..." + touch "$ENV_FILE" for env in "${ENV_LIST[@]}"; do - read -sp "Enter value for $env: " value + read -sp "Enter value for $env: " value echo - env_variable "$env" "$value" - done + env_variable "$env" "$value" + done - install_scripts + install_scripts - log_success "Installation Complete" + log_success "Installation Complete" } -if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then - main "$@" -fi \ No newline at end of file +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + main "$@" +fi