Skip to content

Add "if_needed" value for CREATE_NEW_DATABASE #7

Merged
merged 1 commit into from
Sep 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion container_files/bin/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if [ -e "/tmp/firsttimerunning" ]; then

echo "Setting DataDir: $MYSQL_DATADIR" >> $log

if [ "$CREATE_NEW_DATABASE" == "1" ]; then
if [[ $CREATE_NEW_DATABASE == 1 || ($CREATE_NEW_DATABASE == if_needed && ( ! -d $MYSQL_DATADIR || -z $(ls -A $MYSQL_DATADIR) ) ) ]]; then

echo "Installing MariaDB" >> $log

Expand Down Expand Up @@ -71,6 +71,12 @@ if [ -e "/tmp/firsttimerunning" ]; then
/usr/bin/mysqld_safe --init-file="$tempSqlFile" --datadir="$MYSQL_DATADIR"
else
echo "Not Creating a MariaDB - Using Existing from DataDir: $MYSQL_DATADIR" >> $log
echo "Fixing Permissions" >> $log
chown -R mysql:mysql $MYSQL_DATADIR
/opt/bin/fix-permissions.sh $MYSQL_DATADIR >> $log
/opt/bin/fix-permissions.sh /var/log/mariadb/ >> $log
/opt/bin/fix-permissions.sh /var/run/ >> $log
echo "Done Fixing Permissions" >> $log
rm -f /tmp/firsttimerunning
/usr/bin/mysqld_safe --datadir="$MYSQL_DATADIR"
fi
Expand Down