#!/bin/bash
if [[ $1 == "" ]]; then
	echo "No Image tag provided"
	exit
fi
echo Creating directories...
mkdir ./postgres 
mkdir ./uploads
mkdir ./static
touch config.exs
chown -R 911:911 ./uploads

echo Stopping old `pleroma-web` container...
podman stop pleroma-web
podman rm pleroma-web

echo Creating new `pleroma-web` container...
podman run -d \
    --name pleroma-web \
    --pod pleroma-pod \
    -v ./uploads:/var/lib/pleroma/uploads:z \
    -v ./static:/var/lib/pleroma/static:z \
    -v ./config.exs:/etc/pleroma/config.exs:ro \
    -e DOMAIN=social.example.com \
    -e INSTANCE_NAME=Pleroma \
    -e ADMIN_EMAIL=admin@example.com \
    -e NOTIFY_EMAIL=notify@example.com \
    -e DB_USER=pleroma \
    -e DB_PASS=pleroma \
    -e DB_NAME=pleroma \
    -e DB_HOST=localhost \
    -e POSTGRES_HOST=localhost \
    pleroma:$1