-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall_module
executable file
·58 lines (49 loc) · 1.15 KB
/
uninstall_module
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
#!/usr/bin/env bash
DOTFILES_REPO_URL="https://github.com/guerrero/dotfiles.git"
DOTFILES_PATH="$HOME/.dotfiles"
function main() {
run_modules_install_tasks "$1"
}
function run_modules_install_tasks() {
info "Executing Ansible setup tasks"
/opt/homebrew/bin/ansible-playbook \
-i "$DOTFILES_PATH/inventory" \
"$DOTFILES_PATH/main.yml" \
--extra-vars "command=uninstall module=$1" \
--ask-become-pass \
|| exit 1
}
#
# Utilities
#
# Adapted from https://github.com/Sajjadhosn/dotfiles
function colored_echo() {
local color="$1";
local exp="$2";
local arrow="$3";
if ! [[ $color =~ '^[0-9]$' ]] ; then
case $(echo $color | tr '[:upper:]' '[:lower:]') in
black) color=0 ;;
red) color=1 ;;
green) color=2 ;;
yellow) color=3 ;;
blue) color=4 ;;
magenta) color=5 ;;
cyan) color=6 ;;
white|*) color=7 ;; # white or invalid color
esac
fi
tput bold;
tput setaf "$color";
echo "$arrow $exp";
tput sgr0;
}
function info() {
colored_echo blue "$1" "==>"
}
main "$@"
unset -f \
colored_echo \
info \
run_modules_install_tasks \
main