-
Notifications
You must be signed in to change notification settings - Fork 0
/
.fjell
96 lines (85 loc) · 1.59 KB
/
.fjell
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
fjell() {
COMMAND="$1"
shift
case "$COMMAND" in
"ps")
fjell_ps "$@"
;;
"start")
fjell_start "$@"
;;
"stop")
fjell_stop "$@"
;;
"rm")
fjell_rm "$@"
;;
"restart")
fjell_restart "$@"
;;
"up")
fjell_up "$@"
;;
"down")
fjell_down "$@"
;;
"ip")
fjell_ip "$@"
;;
"logs")
fjell_logs "$@"
;;
"shell")
fjell_shell "$@"
;;
*)
echo "Invalid command"
;;
esac
}
fjell_ps() {
sudo docker ps -a --format "table {{.ID}}\t{{.Image}}\t{{.Size}}\t{{.Status}}\t{{.Names}}" "$@"
}
fjell_start() {
sudo docker start "$@"
}
fjell_stop() {
sudo docker stop "$@"
}
fjell_rm() {
sudo docker stop "$@"
sudo docker rm "$@"
}
fjell_restart() {
sudo docker restart "$@"
}
fjell_up() {
for file in "$@"; do
if [ -f "/homeserver/$file/docker-compose.yaml" ]; then
sudo docker compose -f "/homeserver/$file/docker-compose.yaml" up -d
else
echo "Stack '$file' does not exist."
fi
done
}
fjell_down() {
for file in "$@"; do
if [ -f "/homeserver/$file/docker-compose.yaml" ]; then
sudo docker compose -f "/homeserver/$file/docker-compose.yaml" down
else
echo "Stack '$file' does not exist."
fi
done
}
fjell_ip() {
publicip=$(wget -O - -q https://checkip.amazonaws.com)
localip=$(hostname -I | cut -f1 -d' ')
echo "Local: $localip"
echo "Public: $publicip"
}
fjell_logs() {
sudo docker logs -f "$@"
}
fjell_shell() {
sudo docker exec -it "$@" sh
}