-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmenu.sh
executable file
·106 lines (94 loc) · 3.15 KB
/
menu.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
###################################################
# Info: Shell script to manage different Docker options
# Author: Manu Molina
# Date: 23/01/2019
# version: 2.0
###################################################
checkAlias()
{
data=$1
if [ -z "$data" ]; then
return "0"
else
return "1"
fi
}
# Params: alias value
#
#
getAliasFromInput() {
alias=`$fundialog --stdout --clear --title "name" --inputbox $1 0 0`
return $alias
}
checkAliasAndWork() {
current="$(pwd)/shared"
if [ "$1" = "0" ]; then
dialog --infobox "No alias, no Docker \n " 0 0
else
case $3 in
2) dialog --infobox "Your alias: $2 \n
Your shared folder: $current \n
Running container: \n `docker run -dit --name=$2 -v $current:/root/src/haplotypo/shared --rm cgenomics/haplotypopip:1.0`" 0 0;;
#3) dialog --infobox "Starting container:-\n `docker exec -it $2 /bin/bash`" 0 0;;
3) dialog --infobox "You are now inside $2. Type 'exit' to back.\n" 0 0
docker exec -it $2 /bin/bash
break;;
4) dialog --infobox "Stoping container: \n `docker stop $2`" 0 0;;
5) dialog --infobox "Removing container: \n `docker rm $2`" 0 0;;
esac
fi
}
alias=
menu=
result=
current="$(pwd)/shared"
app_name=haplotypo
#
# set infinite loop
#
while true
do
### display main menu ###
fundialog=${fundialog=dialog}
menuitem=`$fundialog --stdout --backtitle "$app_name Docker Menu" \
--title "[ M A I N - M E N U ]" \
--menu "You can use the UP/DOWN arrow keys, the first \n\
letter of the choice as a hot key, or the \n\
number keys 1-8 to choose an option.\n\
Choose the OPTION" 0 0 0 \
1 "Build image" \
2 "Create container" \
3 "Start container " \
4 "Stop container" \
5 "Remove container" \
6 "View running processes" \
7 "View Docker images" \
8 "Quit"`
# make decsion
case $menuitem in
1) dialog --infobox "Building image: \n " 0 0
docker build -t cgenomics/haplotypopip:1.0 .
break;;
2) alias=`$fundialog --stdout --clear --title "name" --inputbox "Type the alias of the container you want to create:" 0 0`
checkAlias $alias
result=$?
checkAliasAndWork $result $alias "2";;
3) alias=`$fundialog --stdout --clear --title "name" --inputbox "Type the alias of the container you want to start:" 0 0`
checkAlias $alias
result=$?
checkAliasAndWork $result $alias "3";;
4) alias=`$fundialog --stdout --clear --title "name" --inputbox "Type the alias of the container you want to stop:" 0 0`
checkAlias $alias
result=$?
checkAliasAndWork $result $alias "4";;
5) alias=`$fundialog --stdout --clear --title "name" --inputbox "Type the alias of the container you want to remove:" 0 0`
checkAlias $alias
result=$?
checkAliasAndWork $result $alias "5";;
6) dialog --infobox "Docker container details: \n `docker ps`" 0 0;;
7) dialog --infobox "Docker image details: \n `docker images`" 0 0;;
8) echo "Bye!"; break;;
esac
read -r -p "Press space to continue..." key
done