-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathOrchestrate.sh
89 lines (80 loc) · 2.19 KB
/
Orchestrate.sh
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
# Configuration Variables
PROJECT_DIR="/workspaces/pmll"
INSTALL_DIR="/opt/pmll"
LOG_FILE="/var/log/pmll_orchestration.log"
# Helper function for logging
log() {
echo "$(date +'%Y-%m-%d %H:%M:%S') $1" | tee -a "$LOG_FILE"
}
# Function to deploy binaries
deploy() {
log "Deploying binaries to $INSTALL_DIR..."
sudo mkdir -p "$INSTALL_DIR" || { log "Failed to create install directory"; exit 1; }
make deploy || { log "Deployment failed"; exit 1; }
log "Deployment successful."
}
# Function to start services
start_services() {
log "Starting services..."
make start_services || { log "Failed to start services"; exit 1; }
log "Services started successfully."
}
# Function to stop services
stop_services() {
log "Stopping services..."
make stop_services || { log "Failed to stop services"; exit 1; }
log "Services stopped successfully."
}
# Function to restart services
restart_services() {
log "Restarting services..."
make restart_services || { log "Failed to restart services"; exit 1; }
log "Services restarted successfully."
}
# Function to clean the environment
clean() {
log "Cleaning the environment..."
make clean || { log "Failed to clean environment"; exit 1; }
log "Clean complete."
}
# Function to build the project
build() {
log "Building the project..."
make all || { log "Build failed"; exit 1; }
log "Build successful."
}
# Menu for orchestrating tasks
log "Starting orchestration script..."
PS3="Select a task: "
options=("Build All" "Deploy" "Start Services" "Stop Services" "Restart Services" "Clean" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Build All")
build
;;
"Deploy")
deploy
;;
"Start Services")
start_services
;;
"Stop Services")
stop_services
;;
"Restart Services")
restart_services
;;
"Clean")
clean
;;
"Quit")
log "Exiting orchestration script."
break
;;
*)
echo "Invalid option. Please select a valid task."
;;
esac
done