-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpillar
executable file
·117 lines (95 loc) · 2.25 KB
/
pillar
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env bash
function stackHelp {
echo ""
echo " Pillar help"
echo ""
echo " help Display this help information"
echo " build Build up stack"
echo " rebuild Bring down stack, removing volumes, and build back up"
echo " remove Bring down stack, removing volumes"
echo " restart Stop and start stack"
echo " stop Stop stack"
echo " start Start stack"
echo " terminal {container} Get a terminal in a given container"
echo " composer {script} {project} {container} Run a composer script in a project on a given container"
echo " dns {ip} Sets the dns for link 2 on your machine"
echo ""
}
function setDns {
# theres not a huge garuntee this would work
# on other machines due to the link defined as number 2
# but thats a problem for another day
sudo resolvectl dns 2 $1
resolvectl flush-caches
}
function buildStack {
setDns "84.200.69.80"
docker compose up -d --build
setDns "127.0.0.1"
}
function rebuildStack {
docker compose down -v
setDns "84.200.69.80"
docker compose up -d --build
setDns "127.0.0.1"
}
function removeStack {
docker compose down -v
setDns "84.200.69.80"
}
function restartStack {
docker compose down
setDns "84.200.69.80"
docker compose up -d
setDns "127.0.0.1"
}
function stopStack {
docker compose down
setDns "84.200.69.80"
}
function startStack {
setDns "84.200.69.80"
docker compose up -d
setDns "127.0.0.1"
}
function stackTerminal {
docker container exec -it $1 bash -l
}
function stackComposer {
docker container exec -it -w /repos/$2 $3 composer $1
}
case $1 in
help)
stackHelp
;;
build)
buildStack
;;
rebuild)
rebuildStack
;;
remove)
removeStack
;;
restart)
restartStack
;;
stop)
stopStack
;;
start)
startStack
;;
terminal)
stackTerminal "$2"
;;
composer)
stackComposer "$2" "$3" "$4"
;;
dns)
setDns "$2"
;;
*)
stackHelp
;;
esac