Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix sqlite init
  • Loading branch information
thespad committed Feb 8, 2024
commit 60bde2b501766155c36e6b7ef3f56786859b288c
61 changes: 44 additions & 17 deletions root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,55 @@
lsiown abc:abc \
/config

lsiown -R abc:abc \
/app/www/bootstrap/cache \
/app/www/storage \
/app/www/database

if [[ ${DB_CONNECTION:="sqlite"} = "sqlite" ]]; then
# create symlinks
symlinks=( \
/app/www/database/database.sqlite \
)

for i in "${symlinks[@]}"
do
if [[ -e "$i" && ! -L "$i" ]]; then
rm -rf "$i"
if [[ "${DB_CONNECTION:=sqlite}" = "sqlite" ]]; then
touch /config/database.sqlite
if [[ -e "/app/www/database/database.sqlite" && ! -L "/app/www/database/database.sqlite" ]]; then
rm -rf "/app/www/database/database.sqlite"
fi
if [[ ! -L "/app/www/database/database.sqlite" ]]; then
ln -s "/config/database.sqlite" "/app/www/database/database.sqlite"
fi
elif [[ "${DB_CONNECTION}" = "mysql" ]]; then
echo "Waiting for DB to be available"
END=$((SECONDS + 30))
while [[ ${SECONDS} -lt ${END} ]] && [[ -n "${DB_HOST+x}" ]]; do
if [[ $(/usr/bin/nc -w1 "${DB_HOST}" "${DB_PORT}" | tr -d '\0') ]]; then
if [[ -n "${RUN}" ]]; then
break
fi
RUN="RAN"
# we sleep here again due to first run init on DB containers
if [[ ! -f /dbwait.lock ]]; then
sleep 5
fi
else
sleep 1
fi
if [[ ! -L "$i" ]]; then
ln -s /config/"$(basename "$i")" "$i"
done
elif [[ "${DB_CONNECTION}" = "pgsql" ]]; then
echo "Waiting for DB to be available"
END=$((SECONDS + 30))
while [[ ${SECONDS} -lt ${END} ]] && [[ -n "${DB_HOST+x}" ]]; do
if pg_isready -h "${DB_HOST}" -p "${DB_PORT}" -q; then
if [[ -n "${RUN}" ]]; then
break
fi
RUN="RAN"
# we sleep here again due to first run init on DB containers
if [[ ! -f /dbwait.lock ]]; then
sleep 5
fi
else
sleep 1
fi
done
fi

lsiown -R abc:abc \
/app/www/bootstrap/cache \
/app/www/storage \
/app/www/database

# Check for env file
if [[ ! -f /config/.env ]]; then
cp /app/www/.env.production /config/.env
Expand Down