-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
152 lines (113 loc) · 2.59 KB
/
entrypoint.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
set -e
echo Your container args are: "$@"
echo ""
### START - Functions
function usage_entrypoint() {
BASE_COMMAND="docker run -it --rm -v \$(pwd)/data/shakemap_profiles:/root/shakemap_profiles -v \$(pwd)/data/shakemap_data:/root/shakemap_data shakemap4 bash"
cat << EOF
This docker starts shakemap4 software
usage:
$ ${BASE_COMMAND} -p <profile> -c <command>
Values for option -c: [italy|world]
Examples:
1) $ ${BASE_COMMAND} -p italy -c'shake 8863681 select assemble -c "test" model mapping'
2) $ ${BASE_COMMAND} -p world -c'shake 8863681 select assemble -c "test" model mapping'
EOF
}
### END - Functions
### START - Check parameters ###
IN__PROFILE=
IN__COMMAND=
while getopts :p:c: OPTION
do
case ${OPTION} in
p) IN__PROFILE="${OPTARG}"
;;
c) IN__COMMAND="${OPTARG}"
;;
\?) echo "Invalid option: -$OPTARG" >/dev/null
shift
;;
*) #echo $OPTARG >/dev/null
echo "Invalid OPTARG: -$OPTARG" >&2
;;
esac
done
# Check input parameter
if [[ -z ${IN__PROFILE} ]]; then
echo ""
echo " Please, set the PROFILE param"
echo ""
usage_entrypoint
exit 1
else
PROFILE=${IN__PROFILE}
fi
if [[ -z ${IN__COMMAND} ]]; then
echo ""
echo " Please, set the COMMAND param"
echo ""
usage_entrypoint
exit 1
else
COMMAND=${IN__COMMAND}
fi
### END - Check parameters ###
#set -e
#echo "UID=${UID} (from host)"
#echo "GID=${GID} (from host)"
#echo "GROUP_NAME=${GROUP_NAME} (from Dockerfile)"
#echo "USER_NAME=${USER_NAME} (from Dockerfile)"
#if id "${USER_NAME}" &>/dev/null; then
# echo "Start usermod:"
# time usermod -u "${UID}" -g ${GID} ${USER_NAME}
# echo "Done"
#else
# echo "The user \"${USER_NAME}\" doesn't exist"
# exit 1
#fi
#echo "Start chown:"
#time chown -R ${UID}:${GID} /home/${USER_NAME} &
#echo "Done"
#whoami
#
#su - ${USER_NAME}
#whoami
# Pull last changes
echo "--->START - GIT commands:<---"
cd /home/shake/gitwork/shakemap_src/
echo "git status:"
git status
echo ""
#echo "git stash:"
#git stash
#echo ""
#echo "git pull:"
#git pull
#echo ""
#echo "git stash pop:"
#git stash pop
#echo ""
echo "git fetch:"
git fetch
echo ""
#echo "git merge 03be81dfdab95bb4562e491ab14d4261b9662e8e:"
#git merge 03be81dfdab95bb4562e491ab14d4261b9662e8e
#echo ""
echo "git status:"
git status
echo ""
echo "--->END - GIT commands:<---"
echo ""
#
echo "-----"
echo "COMMAND: ${COMMAND}"
echo "-----"
echo ""
. /home/shake/miniconda/etc/profile.d/conda.sh \
&& conda activate base \
&& conda info --envs \
&& conda activate shakemap \
&& sm_profile -s ${PROFILE} \
&& eval ${COMMAND}