Fix checks for persistent disk
@@ -66,29 +66,33 @@ if [ -d ${datadir} ]; then
fi
<% end %>
-DATADIR_DEVICE=$(stat -c "%d" "${datadir}")
-EPHEMERAL_DEVICE=$(stat -c "%d" "/")
-if [[ "$DATADIR_DEVICE" == "$EPHEMERAL_DEVICE" ]]
+function check_mysql_filesystem() {
+ if [[ $(mountpoint -d "${datadir}") == $(mountpoint -d /) ]]
then
echo "###################################################################################################################################" >> "${LOG_FILE}"
echo "!!! Data directory (${datadir}) is on the same filesystem as /. Have you attached persistent disk? !!!" >> "${LOG_FILE}"
echo "####################################################################################################################################" >> "${LOG_FILE}"
exit 1
fi
+}
-DATADIR_CAPACITY=$(df -B1 --output=target,size "${datadir}" | awk ' NR==2 { print $2 } ')
-MINIMUM_REQUIRED_SPACE=10737418240
-if [[ "${DATADIR_CAPACITY}" < "${MINIMUM_REQUIRED_SPACE}" ]]
+function check_mysql_disk_capacity() {
+ local datadir_capacity=$(df -B1 --output=target,size "${datadir}" | awk ' NR==2 { print $2 } ')
+ local minimum_required_space=10737418240 # 10GiB
+ if [[ "${datadir_capacity}" < "${minimum_required_space}" ]]
then
echo "########################################################################################" >> "${LOG_FILE}"
- echo "!!! Datadir capacity is ${DATADIR_CAPACITY}, which is under the minimum required: ${MINIMUM_REQUIRED_SPACE} !!!" >> "${LOG_FILE}"
+ echo "!!! Datadir capacity is ${datadir_capacity}, which is under the minimum required: ${minium_required_space} !!!" >> "${LOG_FILE}"
echo "########################################################################################" >> "${LOG_FILE}"
exit 1
fi
+}
if ! test -d ${datadir}; then
log "pre-start setup script: making ${datadir} and running /var/vcap/packages/mariadb/scripts/mysql_install_db"
mkdir -p ${datadir}
+ check_mysql_filesystem
+ check_mysql_disk_capacity
/var/vcap/packages/mariadb/scripts/mysql_install_db \
--basedir=/var/vcap/packages/mariadb \
--user=vcap \
