#!/bin/bash # ================================================================ # E-Voting System - Docker Compose Stop Script # ================================================================ set -e # Colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' print_header() { echo -e "${BLUE}================================${NC}" echo -e "${BLUE}$1${NC}" echo -e "${BLUE}================================${NC}" } print_success() { echo -e "${GREEN}✓ $1${NC}" } print_warning() { echo -e "${YELLOW}! $1${NC}" } # Main print_header "E-Voting System - Stopping Services" echo "" echo "Options:" echo " 1. Stop services (containers kept)" echo " 2. Stop and remove containers" echo " 3. Stop and remove everything (including data)" echo "" read -p "Select option (1-3): " option case $option in 1) print_warning "Stopping containers..." docker-compose stop print_success "Services stopped (data preserved)" echo "" echo "To start again: docker-compose up -d" ;; 2) print_warning "Stopping and removing containers..." docker-compose down print_success "Containers removed (data preserved)" echo "" echo "To start again: docker-compose up -d" ;; 3) print_warning "This will DELETE all data!" read -p "Are you sure? (yes/no): " confirm if [ "$confirm" = "yes" ]; then docker-compose down -v print_success "Services stopped and all data deleted" else print_warning "Cancelled" fi ;; *) print_warning "Invalid option" exit 1 ;; esac