# Initialize the database files with schema_migrations tables
echo"Initializing database files with schema_migrations tables..."
for db_file in /root/img_manager/storage/production.sqlite3 /root/img_manager/storage/production_cache.sqlite3 /root/img_manager/storage/production_queue.sqlite3 /root/img_manager/storage/production_cable.sqlite3;do
sqlite3 "$db_file""CREATE TABLE IF NOT EXISTS schema_migrations (version varchar(255) NOT NULL); CREATE UNIQUE INDEX IF NOT EXISTS unique_schema_migrations ON schema_migrations (version);"||echo"Failed to initialize $db_file"
done
echo"Checking SELinux status..."
if command-v getenforce &> /dev/null;then
selinux_status=$(getenforce)
echo"SELinux status: $selinux_status"
if["$selinux_status"=="Enforcing"];then
echo"SELinux is enforcing. Setting proper contexts..."
# Set SELinux context for the directories
if command-vchcon &> /dev/null;then
chcon-Rt svirt_sandbox_file_t /root/img_manager
else
echo"chcon command not found. Unable to set SELinux context."
fi
fi
else
echo"getenforce command not found. Unable to check SELinux status."