Skip to content

Commit 76a31d5

Browse files
committed
Make sure to re-initialize the db if previous initialization failed.
1 parent dc397d5 commit 76a31d5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

rootfs/etc/cont-init.d/nginx-proxy-manager.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,20 @@ ln -sf log/nginx /config/logs
3737
[ -f /config/production.json ] || cp /defaults/production.json /config/
3838
[ -f $XDG_CONFIG_HOME/letsencrypt/cli.ini ] || cp /defaults/cli.ini $XDG_CONFIG_HOME/letsencrypt/
3939

40+
# Protect against database initialization failure: make sure to remove the
41+
# database directory if it didn't initialized properly.
42+
if [ -d /config/mysql ] && [ -f /config/db_init_in_progress ]; then
43+
rm -r /config/mysql
44+
fi
45+
4046
# Initialize the database data directory.
4147
if [ ! -d /config/mysql ]; then
4248
MYSQL_DATABASE=nginxproxymanager
4349
MYSQL_USER=nginxproxymanager
4450
MYSQL_PASSWORD=password123
4551

52+
touch /config/db_init_in_progress
53+
4654
log "Initializing database data directory..."
4755
mysql_install_db --datadir=/config/mysql >/config/log/init_db.log 2>&1
4856
log "Database data directory initialized."
@@ -86,6 +94,9 @@ if [ ! -d /config/mysql ]; then
8694
fi
8795
fi
8896

97+
# Database initialized properly.
98+
rm -f /config/db_init_in_progress
99+
89100
# Generate dummy self-signed certificate.
90101
if [ ! -f /config/nginx/dummycert.pem ] || [ ! -f /config/nginx/dummykey.pem ]
91102
then

0 commit comments

Comments
 (0)