Skip to content

Commit

Permalink
Merge pull request #402 from wallabag/fix/sqlite
Browse files Browse the repository at this point in the history
Fix SQLite provisioning
  • Loading branch information
Kdecherf authored Mar 10, 2024
2 parents eaf63d2 + 9c6aca3 commit 4143013
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 4143013

Please sign in to comment.