#!/usr/bin/bash
#
# create ~/.unison/SyncHome.prf if not exists
#
set -eu

[[ -f ~/.unison/SyncHome.prf ]] && exit 0

mkdir -p ~/.unison

if id | grep teachers; then
  NETHOME="$(find /srv/samba/schools/default-school/teachers/ -maxdepth 1 -type d -name "${USER}")"
else
  NETHOME="$(find /srv/samba/schools/default-school/students/ -maxdepth 2 -type d -name "${USER}")"
fi

if [[ ! -f ~/.unison/SyncHome.prf ]]; then
  echo "# Unison preferences
label = Sync Home on Server
path = Bilder
path = Dokumente
path = Musik
path = Videos
root = $HOME
root = $NETHOME
dontchmod = true
perms = 0" > ~/.unison/SyncHome.prf
fi

