forked from Snapchat/KeyDB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhcloud-delete-build-server.sh
More file actions
executable file
·49 lines (38 loc) · 1.08 KB
/
hcloud-delete-build-server.sh
File metadata and controls
executable file
·49 lines (38 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
SERVER_NAME="keydb-build-amd64"
echo -e "${YELLOW}Deleting Hetzner Cloud build server: $SERVER_NAME${NC}"
# Check if hcloud CLI is installed
if ! command -v hcloud &> /dev/null; then
echo -e "${RED}Error: hcloud CLI is not installed.${NC}"
exit 1
fi
# Check if server exists
if ! hcloud server describe "$SERVER_NAME" &> /dev/null; then
echo -e "${RED}Server '$SERVER_NAME' not found.${NC}"
exit 1
fi
# Get server details before deletion
SERVER_IP=$(hcloud server ip "$SERVER_NAME")
echo -e "${YELLOW}Server to be deleted:${NC}"
echo " Name: $SERVER_NAME"
echo " IP: $SERVER_IP"
echo ""
read -p "Are you sure you want to delete this server? (yes/no): " -r
echo
if [[ ! $REPLY =~ ^[Yy][Ee][Ss]$ ]]; then
echo -e "${GREEN}Deletion cancelled.${NC}"
exit 0
fi
hcloud server delete "$SERVER_NAME"
if [ $? -eq 0 ]; then
echo -e "${GREEN}Server '$SERVER_NAME' deleted successfully.${NC}"
else
echo -e "${RED}Failed to delete server.${NC}"
exit 1
fi