-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathManager.sh
More file actions
executable file
·93 lines (89 loc) · 3.79 KB
/
Manager.sh
File metadata and controls
executable file
·93 lines (89 loc) · 3.79 KB
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
#!/bin/bash
function LIST_OCIS {
source Scripts/Titles.sh
echo " =============================List Container============================="
sudo docker ps $1 --format '> {{.ID}} {{.Names}} {{.Image}} {{upper .State}}\n\t\t Networks: {{.Networks | printf "%6s"}} Status: {{.Status}}'
echo " ==========================Enter Key to Continue========================="
}
while [ true ];
do
source Scripts/Titles.sh
echo " ==================================Menu=================================="
echo " --------------------------- Container Manage ---------------------------"
echo " [n] [Created] Create a new docker container from an image"
echo " [l] [Display] Display all docker containers in the system"
echo " [s] [Started] Start your docker container already created"
echo " [t] [Pausing] Pause your docker container already running"
echo " -NOTE- [r] [Restart] Restart your docker container which ctarted"
echo " *WARN* [K] [Killall] Stop your docker container which is running"
echo " *WARN* [D] [Deleted] Select and delete your docker container now"
echo " ----------------------------- Image Manage -----------------------------"
echo " -NOTE- [b] [ Build ] Build your docker image from the DockerFile"
echo " *WARN* [C] [ Clean ] Clean all unuse images and untag image file"
echo " *WARN* [P] [ Prune ] Prune system(all unuse images & containers)"
echo " ------------------------------------------------------------------------"
echo " [q] [ Exit~ ] Do nothing, just exit this script! Byebye~~"
echo " ========================================================================"
echo
OP_TYPE="."
echo -n " Choose Operation Type Number(*): "
read OP_TYPE
# Quit -----------------------------------------------------------------------------
if [ $OP_TYPE == 'q' ]; then
clear
exit 0
# Create ---------------------------------------------------------------------------
elif [ $OP_TYPE == 'n' ]; then
source Scripts/Create.sh
# List -----------------------------------------------------------------------------
elif [ $OP_TYPE == 'l' ]; then
LIST_OCIS -a
read KEY
# Start ----------------------------------------------------------------------------
elif [ $OP_TYPE == 's' ]; then
DEL_NAME=""
LIST_OCIS -a
echo -n " Enter Container Name or ID to Launch(*): "
read DEL_NAME
docker start $DEL_NAME
# Pause ----------------------------------------------------------------------------
elif [ $OP_TYPE == 't' ]; then
DEL_NAME=""
LIST_OCIS " "
echo -n " Enter Container Name or ID to Stop (*): "
read DEL_NAME
docker stop $DEL_NAME
# Restart --------------------------------------------------------------------------
elif [ $OP_TYPE == 'r' ]; then
DEL_NAME=""
LIST_OCIS " "
echo -n " Enter Container Name or ID to Stop (*): "
read DEL_NAME
docker restart $DEL_NAME
# Killall --------------------------------------------------------------------------
elif [ $OP_TYPE == 'K' ]; then
DEL_NAME=""
LIST_OCIS " "
echo -n " Are You Sure Stop ALL Container Now(Y/N): "
read DEL_NAME
if [ $DEL_NAME == 'Y' ]; then
docker stop $(docker ps -a -q)
fi
# Delete ---------------------------------------------------------------------------
elif [ $OP_TYPE == 'D' ]; then
DEL_NAME=""
LIST_OCIS -a
echo -n " Enter Container Name or ID to Delete(*): "
read DEL_NAME
docker stop $DEL_NAME
docker rm $DEL_NAME
elif [ $OP_TYPE == 'b' ]; then
source Builder.sh
elif [ $OP_TYPE == 'C' ]; then
echo -n " "
docker rmi $(docker images -a | grep none | awk '{print $3}')
elif [ $OP_TYPE == 'P' ]; then
echo -n " "
docker system prune --volumes
fi
done