#!/usr/bin/with-contenv bash
# shellcheck shell=bash
# source env variables
source /etc/cont-init.d/20-setenv
# check if lock file is present
if [[ ! -f /flox/.lock ]]; then
# move app to permanent path
printf 'Copying files to bind mount path\n'
rsync --archive --delete --backup --backup-dir=/tmp /app/flox/ /flox
# create lock file to prevent overwriting existing files
touch /flox/.lock
chmod 600 /flox/.lock
else
printf 'Lock file present. Not copying files\n'
fi