#!/bin/sh

set -eu

NAME="jam-web"

USER="$NAME"
GROUP="$NAME"

# copy upstart file
cp /var/lib/$NAME/script/package/$NAME.conf /etc/init/$NAME.conf

mkdir -p /var/lib/$NAME/log
mkdir -p /var/lib/$NAME/tmp
mkdir -p /var/tmp/$NAME
mkdir -p /etc/$NAME
mkdir -p /var/log/$NAME

chown -R $USER:$GROUP /var/lib/$NAME
chown -R $USER:$GROUP /etc/$NAME
chown -R $USER:$GROUP /var/log/$NAME
chown -R $USER:$GROUP /var/tmp/$NAME

# make log folders for jobs
mkdir -p /var/log/any-job-worker
mkdir -p /var/log/scheduler-worker

chown -R $USER:$GROUP /var/log/any-job-worker
chown -R $USER:$GROUP /var/log/scheduler-worker
