#!/usr/bin/env bash

mkdir /var/log/admin-app 2> /dev/null
chmod 775 /var/log/admin-app
chown mail:mail -R /var/log/admin-app

chown -R mail:mail /var/lib/php/sessions
chmod 755 /var/lib/php/sessions

rm -Rf /opt/admin/var/log
ln -s /var/log/admin-app /opt/admin/var/log 2> /dev/null

mkdir /var/log/auth 2> /dev/null

chown mail:mail -R /var/log/auth
chmod 775 /var/log/auth

rm -Rf /opt/admin/var/cache/dev
rm -Rf /opt/admin/var/cache/prod
mkdir /opt/admin/var/cache/dev
mkdir /opt/admin/var/cache/prod
chown mail:mail -R /opt/admin/var

sudo -u mail /opt/admin/bin/console cache:warmup --env=prod --no-debug 1> /dev/null

# for testing
mkdir -p /opt/admin/var/cache/test 2> /dev/null

touch /data/log/admin-app/test.log
chown mail:mail /data/log/admin-app/test.log

chmod 755 /etc/cron.d/*
