#!/bin/sh
 
while [ $# -gt 0 ] ; do
  case $1 in
    --projectroot) PROJECTROOT=$2; shift 2;;
         --pgroot) PGROOT=$2; shift 2;;
        --project) PROJECT=$2; shift 2;;
               * )  shift 1;;
  esac
done

mkdir -p /var/run/samba >/dev/null 2>&1
for dir in cache lib lock locks private run
do
    mkdir -p /var/lib/mne/samba/$dir 2>&1
done

if [ "$PPAARCH" = "armhf" ]; then
  ln -s $PROJECTROOT/lib/libnss_winbind.so.2 /lib/arm-linux-gnueabihf >/dev/null 2>&1
  ln -s /lib/arm-linux-gnueabihf/libnss_winbind.so.2 /lib/arm-linux-gnueabihf/libnss_winbind.so >/dev/null 2>&1
else
  ln -s $PROJECTROOT/lib/libnss_winbind.so.2 /lib/x86_64-linux-gnu >/dev/null 2>&1
  ln -s /lib/x86_64-linux-gnu/libnss_winbind.so.2 /lib/x86_64-linux-gnu/libnss_winbind.so >/dev/null 2>&1
fi
ldconfig

systemctl daemon-reload

exit 0