Skip to content
Snippets Groups Projects
Commit 97168872 authored by Florian Bieringer's avatar Florian Bieringer
Browse files

Install only when no database tables are there

parent 710d0866
Branches
Tags
No related merge requests found
...@@ -12,9 +12,7 @@ if [ ! -f $CONFIGFILE ]; then ...@@ -12,9 +12,7 @@ if [ ! -f $CONFIGFILE ]; then
cp "$DOCKERCONFIGFILE" "$CONFIGFILE" cp "$DOCKERCONFIGFILE" "$CONFIGFILE"
cp "$CONF.dist" "$CONF" cp "$CONF.dist" "$CONF"
fi
# Setup mysql database
echo "INSTALL DB"
# wait until MySQL is really available # wait until MySQL is really available
maxcounter=45 maxcounter=45
...@@ -29,6 +27,11 @@ if [ ! -f $CONFIGFILE ]; then ...@@ -29,6 +27,11 @@ if [ ! -f $CONFIGFILE ]; then
fi; fi;
done done
# Check if the connected database has tables, otherwise install the database
if [[ $(mysql -f -u $MYSQL_USER -h $MYSQL_HOST -p$MYSQL_PASSWORD $MYSQL_DATABASE -e "show tables;" --batch | wc -l) -eq 0 ]]; then
# Setup mysql database
echo "INSTALL DB"
mysql -f -u $MYSQL_USER -h $MYSQL_HOST -p$MYSQL_PASSWORD $MYSQL_DATABASE < ${STUDIP}/db/studip.sql mysql -f -u $MYSQL_USER -h $MYSQL_HOST -p$MYSQL_PASSWORD $MYSQL_DATABASE < ${STUDIP}/db/studip.sql
echo "INSTALL DEFAULT DATA" echo "INSTALL DEFAULT DATA"
mysql -f -u $MYSQL_USER -h $MYSQL_HOST -p$MYSQL_PASSWORD $MYSQL_DATABASE < ${STUDIP}/db/studip_default_data.sql mysql -f -u $MYSQL_USER -h $MYSQL_HOST -p$MYSQL_PASSWORD $MYSQL_DATABASE < ${STUDIP}/db/studip_default_data.sql
...@@ -44,6 +47,8 @@ if [ ! -f $CONFIGFILE ]; then ...@@ -44,6 +47,8 @@ if [ ! -f $CONFIGFILE ]; then
fi fi
echo "INSTALLATION FINISHED" echo "INSTALLATION FINISHED"
else
echo "Found some SQL table. Skipping installation"
fi fi
if [ ! -z $AUTO_MIGRATE ]; then if [ ! -z $AUTO_MIGRATE ]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment