Skip to content

Commit

Permalink
Fix SQLite provisioning
Browse files Browse the repository at this point in the history
If we use a local folder volume binding, install_wallabag was failing
because of missing file and permission issues.

This reworks the way we initially create the database when it is missing
or empty.

Superseeds #386

Fixes #316 #346

Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
  • Loading branch information
Kdecherf committed Mar 10, 2024
1 parent f59fb4b commit 9c6aca3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions root/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ install_wallabag() {
provisioner() {
SYMFONY__ENV__DATABASE_DRIVER=${SYMFONY__ENV__DATABASE_DRIVER:-pdo_sqlite}
POPULATE_DATABASE=${POPULATE_DATABASE:-True}
SQLITE_DB_DIR="/var/www/wallabag/data/db"
SQLITE_DB_FILEPATH="$SQLITE_DB_DIR/wallabag.sqlite"

# Replace environment variables
envsubst < /etc/wallabag/parameters.template.yml > app/config/parameters.yml
Expand All @@ -33,10 +35,17 @@ provisioner() {
fi

# Configure SQLite database
SQLITE_FILE_SIZE=$(wc -c "/var/www/wallabag/data/db/wallabag.sqlite" | awk '{print $1}')
if [ "$SYMFONY__ENV__DATABASE_DRIVER" = "pdo_sqlite" ] && ([ ! -f "/var/www/wallabag/data/db/wallabag.sqlite" ] || [ "$SQLITE_FILE_SIZE" = 0 ]) ; then
echo "Configuring the SQLite database ..."
install_wallabag
if [ "$SYMFONY__ENV__DATABASE_DRIVER" = "pdo_sqlite" ]; then
# mkdir and chown are mandatory for local folder binding
if [ ! -f "$SQLITE_DB_FILEPATH" ]; then
mkdir -p "$SQLITE_DB_DIR"
chown nobody: "$SQLITE_DB_DIR"
fi

if [ ! -s "$SQLITE_DB_FILEPATH" ]; then
echo "Configuring the SQLite database ..."
install_wallabag
fi
fi

# Configure MySQL / MariaDB database
Expand Down

0 comments on commit 9c6aca3

Please sign in to comment.