-
Notifications
You must be signed in to change notification settings - Fork 34
/
entrypoint.sh
executable file
·62 lines (53 loc) · 2.03 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
#!/usr/bin/env bash
function check_env {
if [ -z "$CONFIG_LOCATION" ]; then
echo "INFO: No CONFIG_LOCATION variable provided. Using default '/config/ora2pg.conf'"
export CONFIG_LOCATION=/config/ora2pg.conf
else
echo "INFO: CONFIG_LOCATION variable detected: '$CONFIG_LOCATION'"
fi
if [ -z "$OUTPUT_LOCATION" ]; then
echo "INFO: No OUTPUT_LOCATION variable provided. Using default '/data'"
export OUTPUT_LOCATION=/data
else
echo "INFO: OUTPUT_LOCATION variable detected: '$OUTPUT_LOCATION'"
mkdir -p ${OUTPUT_LOCATION}
fi
ORA_HOST_FLAG=""
if [ -z "$ORA_HOST" ]; then
echo "INFO: No ORA_HOST variable provided. Using value of 'ORACLE_DSN' from '$CONFIG_LOCATION'"
else
echo "INFO: ORA_HOST_FLAG variable detected: '$ORA_HOST'"
ORA_HOST_FLAG=" --source $ORA_HOST "
fi
ORA_USER_FLAG=""
if [ -z "$ORA_USER" ]; then
echo "INFO: No ORA_USER variable provided. Using value of 'ORACLE_USER' from '$CONFIG_LOCATION'"
else
echo "INFO: ORA_USER variable detected: '$ORA_USER'"
ORA_USER_FLAG=" --user $ORA_USER "
fi
ORA_PWD_FLAG=""
ORA_PWD_FLAG_MASKED=""
if [ -z "$ORA_PWD" ]; then
echo "INFO: No ORA_PWD variable provided. Using value of 'ORACLE_PWD' from '$CONFIG_LOCATION'"
else
echo "INFO: ORA_PWD variable detected: '*******'"
ORA_PWD_FLAG=" --password $ORA_PWD "
ORA_PWD_FLAG_MASKED=" --password ******* "
fi
}
if [ "$1" = 'ora2pg' ]; then
check_env
# Set host name for oracle
/bin/bash -c "echo '127.0.1.1 ${HOSTNAME}' >> /etc/hosts"
if [ -z "$2" ]; then
echo "INFO: no args provided. Using default: '--debug -c $CONFIG_LOCATION --basedir $OUTPUT_LOCATION ${ORA_HOST_FLAG} ${ORA_USER_FLAG} ${ORA_PWD_FLAG_MASKED} ' "
ora2pg --debug -c ${CONFIG_LOCATION} --basedir ${OUTPUT_LOCATION} ${ORA_HOST_FLAG} ${ORA_USER_FLAG} ${ORA_PWD_FLAG}
else
echo "INFO: executing: '$@'"
exec "$@"
fi
exit 0
fi
exec "$@"