-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
dockerUpdate.sh
executable file
·83 lines (70 loc) · 2.86 KB
/
dockerUpdate.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
#!/bin/bash
######################################################################
# Title : PCSMenu
# By : NorkzYT
# License : General Public License GPL-3.0-or-later
######################################################################
source /opt/Wolflith/PCSMenu/src/PCSFunc.sh
function docker_update() {
default_menu_screen
cyanprint "This option will guide you through updating Docker on machine(s)."
echo ""
while true; do
cyanprint "Do you still want to run this command? (yes/no) "
read -rp "" run_command
echo ""
if [[ "$run_command" =~ ^[Yy][Ee]?[Ss]?$ ]]; then
cyanprint "Do you want to run the playbook for all machines listed in hosts.yaml? (y/n)"
read -r run_for_all
if [[ "$run_for_all" =~ ^[Yy]$ ]]; then
ansible_playbook_targets="all"
greenprint "Proceeding with all machines..."
else
cyanprint "Enter the name of the machine you want to run the playbooks for:"
read -r ansible_playbook_targets
greenprint "Proceeding with the machine: $ansible_playbook_targets"
fi
export ANSIBLE_CONFIG=/opt/Wolflith/Ansible/inventory/ansible.cfg
cyanprint "Executing Playbook... (Please be patient, may take more than 10 minutes to complete)"
# Execute the Ansible playbook for the specified target(s), capturing output
if ! output=$(ansible-playbook /opt/Wolflith/Ansible/playbooks/docker-update.yml -i "/opt/Wolflith/Ansible/inventory/hosts.yaml" -l "$ansible_playbook_targets" 2>&1); then
redprint "An error occurred during playbook execution:"
echo "$output" # Display the captured error output
yellowprint "Error occurred, press 'x' to exit."
read -n 1 -r key
echo
if [[ $key =~ ^[Xx]$ ]]; then
clear
exit 2
return
fi
else
greenprint "Playbook executed successfully."
fi
# Prompt at the end
echo "Press 'c' to continue..."
while read -r -n 1 key; do
if [[ $key == c ]]; then
echo "Key 'c' pressed. Continuing..."
break
else
echo "Press 'c' to continue..."
fi
done
# Return to main menu
exit 2
elif [[ "$run_command" =~ ^[Nn][Oo]?$ ]]; then
magentaprint "Operation canceled. Returning to the main menu..."
sleep 1
exit 2
return
else
# The user entered an invalid answer
invalid_answer
clear
menu_cover
docker_update
fi
done
}
docker_update