mirror of
https://github.com/informaticker/uek-109-LBb.git
synced 2024-11-22 01:31:58 +01:00
Cleaned up scripts
This commit is contained in:
parent
fdf9ff9198
commit
2b4a2f3532
62
cleanup.sh
Normal file
62
cleanup.sh
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Function to display progress bar
|
||||||
|
show_progress() {
|
||||||
|
local current=$1
|
||||||
|
local total=$2
|
||||||
|
local width=100
|
||||||
|
local percentage=$((current * 100 / total))
|
||||||
|
local completed=$((width * current / total))
|
||||||
|
local remaining=$((width - completed))
|
||||||
|
|
||||||
|
printf "\rProgress: [%-${width}s] %d%%" "$(printf '#%.0s' $(seq 1 $completed))$(printf ' %.0s' $(seq 1 $remaining))" "$percentage"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Start timing
|
||||||
|
start_time=$(date +%s)
|
||||||
|
|
||||||
|
# Total number of steps
|
||||||
|
total_steps=7
|
||||||
|
current_step=0
|
||||||
|
|
||||||
|
# Execute commands with progress updates
|
||||||
|
oc delete -f deployment/configmap.yaml > /dev/null
|
||||||
|
((current_step++))
|
||||||
|
show_progress $current_step $total_steps
|
||||||
|
|
||||||
|
oc delete -f deployment/secrets.yaml > /dev/null
|
||||||
|
((current_step++))
|
||||||
|
show_progress $current_step $total_steps
|
||||||
|
|
||||||
|
oc delete -f deployment/database.yaml > /dev/null
|
||||||
|
((current_step++))
|
||||||
|
show_progress $current_step $total_steps
|
||||||
|
|
||||||
|
oc delete -f deployment/pvc.yaml > /dev/null
|
||||||
|
((current_step++))
|
||||||
|
show_progress $current_step $total_steps
|
||||||
|
|
||||||
|
oc delete -f deployment/backend.yaml > /dev/null
|
||||||
|
((current_step++))
|
||||||
|
show_progress $current_step $total_steps
|
||||||
|
|
||||||
|
oc delete -f deployment/frontend.yaml > /dev/null
|
||||||
|
((current_step++))
|
||||||
|
show_progress $current_step $total_steps
|
||||||
|
|
||||||
|
oc delete -f deployment/hpa.yaml > /dev/null
|
||||||
|
((current_step++))
|
||||||
|
show_progress $current_step $total_steps
|
||||||
|
|
||||||
|
# End timing
|
||||||
|
end_time=$(date +%s)
|
||||||
|
|
||||||
|
# Calculate duration
|
||||||
|
duration=$((end_time - start_time))
|
||||||
|
|
||||||
|
# Print newline after progress bar
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Display final timing information
|
||||||
|
echo "Cleaned up ^w^"
|
||||||
|
echo "Execution completed in $duration seconds."
|
104
deploy.sh
104
deploy.sh
@ -1,25 +1,91 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
GITHUB_USERNAME="your_github_username"
|
|
||||||
|
GITHUB_USERNAME="informaticker"
|
||||||
VERSION="v1"
|
VERSION="v1"
|
||||||
|
|
||||||
|
# Function to display progress bar and status
|
||||||
|
show_progress() {
|
||||||
|
local current=$1
|
||||||
|
local total=$2
|
||||||
|
local status=$3
|
||||||
|
local width=100
|
||||||
|
local percentage=$((current * 100 / total))
|
||||||
|
local completed=$((width * current / total))
|
||||||
|
local remaining=$((width - completed))
|
||||||
|
|
||||||
|
# Move cursor to the beginning of the line and clear it
|
||||||
|
echo -ne "\r\033[K"
|
||||||
|
|
||||||
|
# Print status and progress bar
|
||||||
|
echo -ne "$status\n"
|
||||||
|
printf "Progress: [%-${width}s] %d%%" "$(printf '#%.0s' $(seq 1 $completed))$(printf ' %.0s' $(seq 1 $remaining))" "$percentage"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to run command and check for errors
|
||||||
|
run_command() {
|
||||||
|
local command="$1"
|
||||||
|
local status="$2"
|
||||||
|
|
||||||
|
# Save cursor position
|
||||||
|
tput sc
|
||||||
|
|
||||||
|
show_progress $current_step $total_steps "$status"
|
||||||
|
if ! eval "$command" > /dev/null 2>&1; then
|
||||||
|
echo -e "\nError: Failed to execute: $command"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
((current_step++))
|
||||||
|
|
||||||
|
# Restore cursor position
|
||||||
|
tput rc
|
||||||
|
}
|
||||||
|
|
||||||
|
# Start timing
|
||||||
|
start_time=$(date +%s)
|
||||||
|
|
||||||
|
# Total number of steps
|
||||||
|
total_steps=11
|
||||||
|
current_step=0
|
||||||
|
|
||||||
|
# Clear screen and move cursor to top-left
|
||||||
|
clear
|
||||||
|
tput cup 0 0
|
||||||
|
|
||||||
if [ "$GITHUB_USERNAME" == "your_github_username" ]; then
|
if [ "$GITHUB_USERNAME" == "your_github_username" ]; then
|
||||||
echo "you buffoon change your github username in the file."
|
echo "You buffoon, change your github username in the file."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
replace_placeholders() {
|
|
||||||
sed -i "s|ghcr.io/informaticker/zli-counter-frontend:v1|ghcr.io/${GITHUB_USERNAME}/zli-counter-frontend:${VERSION}|g" deployment/frontend.yaml
|
|
||||||
sed -i "s|ghcr.io/informaticker/zli-counter-backend:v1|ghcr.io/${GITHUB_USERNAME}/zli-counter-backend:${VERSION}|g" deployment/backend.yaml
|
|
||||||
}
|
|
||||||
docker build -t ghcr.io/${GITHUB_USERNAME}/zli-counter-backend:${VERSION} counter_kand/backend
|
|
||||||
docker build -t ghcr.io/${GITHUB_USERNAME}/zli-counter-frontend:${VERSION} counter_kand/frontend
|
|
||||||
docker push ghcr.io/${GITHUB_USERNAME}/zli-counter-backend:${VERSION}
|
|
||||||
docker push ghcr.io/${GITHUB_USERNAME}/zli-counter-frontend:${VERSION}
|
|
||||||
replace_placeholders
|
|
||||||
oc apply -f deployment/configmap.yaml
|
|
||||||
oc apply -f deployment/secrets.yaml
|
|
||||||
oc apply -f deployment/database.yaml
|
|
||||||
oc apply -f deployment/pvc.yaml
|
|
||||||
oc apply -f deployment/backend.yaml
|
|
||||||
oc apply -f deployment/frontend.yaml
|
|
||||||
oc apply -f deployment/hpa.yaml
|
|
||||||
|
|
||||||
echo "Deployment completed successfully! ^w^"
|
replace_placeholders() {
|
||||||
|
run_command "sed -i \"s|ghcr.io/informaticker/zli-counter-frontend:v1|ghcr.io/${GITHUB_USERNAME}/zli-counter-frontend:${VERSION}|g\" deployment/frontend.yaml && \
|
||||||
|
sed -i \"s|ghcr.io/informaticker/zli-counter-backend:v1|ghcr.io/${GITHUB_USERNAME}/zli-counter-backend:${VERSION}|g\" deployment/backend.yaml" \
|
||||||
|
"Replacing placeholders in deployment files"
|
||||||
|
}
|
||||||
|
|
||||||
|
run_command "docker build -t ghcr.io/${GITHUB_USERNAME}/zli-counter-backend:${VERSION} counter_kand/backend" "Building backend Docker image"
|
||||||
|
run_command "docker build -t ghcr.io/${GITHUB_USERNAME}/zli-counter-frontend:${VERSION} counter_kand/frontend" "Building frontend Docker image"
|
||||||
|
run_command "docker push ghcr.io/${GITHUB_USERNAME}/zli-counter-backend:${VERSION}" "Pushing backend Docker image"
|
||||||
|
run_command "docker push ghcr.io/${GITHUB_USERNAME}/zli-counter-frontend:${VERSION}" "Pushing frontend Docker image"
|
||||||
|
|
||||||
|
replace_placeholders
|
||||||
|
|
||||||
|
run_command "oc apply -f deployment/configmap.yaml" "Applying configmap"
|
||||||
|
run_command "oc apply -f deployment/secrets.yaml" "Applying secrets"
|
||||||
|
run_command "oc apply -f deployment/database.yaml" "Applying database configuration"
|
||||||
|
run_command "oc apply -f deployment/pvc.yaml" "Applying PVC"
|
||||||
|
run_command "oc apply -f deployment/backend.yaml" "Applying backend configuration"
|
||||||
|
run_command "oc apply -f deployment/frontend.yaml" "Applying frontend configuration"
|
||||||
|
run_command "oc apply -f deployment/hpa.yaml" "Applying HPA"
|
||||||
|
|
||||||
|
# End timing
|
||||||
|
end_time=$(date +%s)
|
||||||
|
|
||||||
|
# Calculate duration
|
||||||
|
duration=$((end_time - start_time))
|
||||||
|
|
||||||
|
# Move cursor down and clear the progress bar
|
||||||
|
tput cud 2
|
||||||
|
tput el
|
||||||
|
|
||||||
|
echo "Deployment completed successfully! ^w^"
|
||||||
|
echo
|
Loading…
Reference in New Issue
Block a user