-
Notifications
You must be signed in to change notification settings - Fork 251
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·121 lines (110 loc) · 4.62 KB
/
Copy pathdocker-entrypoint.sh
File metadata and controls
executable file
·121 lines (110 loc) · 4.62 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
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
#!/usr/bin/env bash
paths=(inc/utils/locks)
for path in ${paths[@]}; do
if [ -w ${HASHTOPOLIS_DOCUMENT_ROOT}/${path} ] ; then
echo "${path} writeable"
else
echo "${path} is not writeable, please fix."
exit 1
fi
done
if [[ -z "${HASHTOPOLIS_DB_TYPE+x}" ]]; then
HASHTOPOLIS_DB_TYPE="mysql"
fi
echo "Testing database..."
if [[ "$HASHTOPOLIS_DB_TYPE" == "mysql" ]]; then
echo "Using MySQL..."
DB_CMD="mysql -u${HASHTOPOLIS_DB_USER} -p${HASHTOPOLIS_DB_PASS} -h ${HASHTOPOLIS_DB_HOST} --skip-ssl"
DB_TYPE="mysql"
if [[ -n "${HASHTOPOLIS_DB_PORT}" ]]; then
DB_CMD="${DB_CMD} -P${HASHTOPOLIS_DB_PORT}"
fi
elif [[ "$HASHTOPOLIS_DB_TYPE" == "postgres" ]]; then
echo "Using postgres..."
DB_CMD="psql -U${HASHTOPOLIS_DB_USER} -h ${HASHTOPOLIS_DB_HOST} ${HASHTOPOLIS_DB_DATABASE}"
DB_TYPE="postgres"
if [[ -n "${HASHTOPOLIS_DB_PORT}" ]]; then
DB_CMD="${DB_CMD} -p${HASHTOPOLIS_DB_PORT}"
fi
else
echo "INVALID DATABASE TYPE PROVIDED: $HASHTOPOLIS_DB_TYPE"
exit 1
fi
while :; do
if [[ $DB_TYPE == "mysql" ]]; then
$DB_CMD -e "SELECT 1" > /dev/null 2>&1
ERROR=$?
elif [[ $DB_TYPE == "postgres" ]]; then
PGPASSWORD="${HASHTOPOLIS_DB_PASS}" $DB_CMD -c "SELECT 1" > /dev/null 2>&1
ERROR=$?
fi
if [ $ERROR -eq 0 ]; then
break
fi
echo "Database not ready or unable to connect. Retrying in 5s."
sleep 5
done
echo "Database ready!"
directories=(
"${HASHTOPOLIS_FILES_PATH}"
"${HASHTOPOLIS_CONFIG_PATH}"
"${HASHTOPOLIS_LOG_PATH}"
"${HASHTOPOLIS_IMPORT_PATH}"
"${HASHTOPOLIS_BINARIES_PATH}"
"${HASHTOPOLIS_TUS_PATH}"
"${HASHTOPOLIS_TEMP_UPLOADS_PATH}"
"${HASHTOPOLIS_TEMP_META_PATH}"
)
echo "Setting up folders"
for dir in "${directories[@]}"; do
if [ ! -d "$dir" ];then
mkdir -p "$dir" && chown www-data:www-data "$dir"
fi
done
# required to trigger the initialization
echo "Start initialization process..."
php -f ${HASHTOPOLIS_DOCUMENT_ROOT}/inc/startup/setup.php
rc=$? # capture the status
if (( rc != 0 )); then
echo "Hashtopolis setup.php failed (exit code $rc)" >&2
exit $rc # propagate the failure to stop docker continuing
fi
echo "Initialization complete!"
echo " @@@@@@@@@@@@@@@@@@"
echo " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo " @@@@@@@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo " @@@@@@@@@@@@@@@@@@@@@@@@@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@@@@@@@@@@@@"
echo ""
echo ""
echo " Hashtopolis is now ready to use!"
echo " *\0/*"
echo ""
echo ""
docker-php-entrypoint apache2-foreground