#!/bin/sh

set -e

allusers=/usr/share/lightworks
user=~/Lightworks

mkdir -p $user/Media
mkdir -p $user/Logs
mkdir -p $user/Projects
mkdir -p $user/Lists

# Generate a machine number (if there isn't one already)
if [ ! -f $allusers/machine.num ];
then
cat > $allusers/machine.num << EOF
$((`cat /dev/urandom|od -N1 -An -i` % 2500))
EOF
fi

# Generate DefNetDrives.txt (if there isn't one already)
if [ ! -f $user/Projects/DefNetDrive.txt ];
then
cat > $user/Projects/DefNetDrive.txt << EOF
$user/Media/
EOF
fi

/usr/lib/lightworks/spawn "$@"
