-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsdictl
executable file
·86 lines (78 loc) · 2.79 KB
/
sdictl
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
#!/bin/bash
PREFIX=$(dirname $0)
if [ ! -e $PREFIX'/sdi.conf' ]; then
echo "ERROR: The $PREFIX/sdi.conf file does not exist or can not be accessed"
exit 1
fi
source $PREFIX'/sdi.conf'
function usage () {
echo "Usage:"
echo " $0 [options]"
echo "Options:"
echo -ne " --start\n\tStart SDI.\n"
echo -ne " --stop\n\tStop SDI\n"
echo -ne " --close=host\n\tClose the tunnel of the host\n"
echo -ne " --restart\n\tRestart SDI\n"
echo -ne " --cleardata\n\tClear all data files\n"
echo -ne " --container=/full/patch/folder/container.tar.gz\n\tSend and execute a container\n"
echo -ne " --comtar=/full/patch/file.tar.gz --tl=time_limit_in_seconds\n\tSend and execute a command inside a tar.gz\n"
echo -ne " --status=TICKET\n\tShow information about the execution of the container\n"
echo -ne " --resume\n\tShow a resume for all containers executions\n"
echo -ne " --sync-data\n\tSyncronize fast data dir with data dir\n"
echo -ne " --sendimage=/full/patch/folder/image.tar.gz\n\tSend a docker image and install in all hosts\n"
echo -ne " --senddockerfile=/full/patch/folder/file.tar.gz\n\tSend a package with the Dockerfile to generate a container and execute in a host\n"
}
TEMP=$(getopt -o hsScR \
--long 'help,start,stop,close:,restart,sync-data,cleardata,comtar:,sendimage:,container:,tl:,status:,resume,senddockerfile:' \
-n 'sdictl' -- "$@")
eval set -- "$TEMP"
while true; do
case "$1" in
--start)
bash $PREFIX/launchsdi.sh
break ;;
--stop)
bash $PREFIX/sync.sh
bash $PREFIX/launchsditunnel.sh --killall
break ;;
--restart)
bash $PREFIX/sync.sh
bash $PREFIX/launchsditunnel.sh --killall
bash $PREFIX/launchsdi.sh
break ;;
--close)
bash $PREFIX/launchsditunnel.sh --kill="$2"
break ;;
--cleardata)
rm -r data/*
rm -r $TMPDIR/*
break ;;
--container)
bash $PREFIX/sendcontainer.sh --container="$2" --tl="$4"
break ;;
--comtar)
bash $PREFIX/sendcommandtar.sh --tar="$2" --tl="$4"
break ;;
--status)
bash $PREFIX/status.sh --ticket="$2"
break ;;
--resume)
bash $PREFIX/resume.sh
break ;;
--sendimage)
# CONTINUAR AQUI
#printf "envia imagem $2"
bash $PREFIX/sendimage.sh --image="$2"
break ;;
--senddockerfile)
# CONTINUAR AQUI
bash $PREFIX/senddockerfile.sh --file="$2"
break ;;
--sync-data)
bash $PREFIX/sync.sh
break ;;
*)
usage
break ;;
esac
done