#!/bin/sh

TMP_DIR=/var/tmp

rm -f /etc/osso-af-init/gconf-dir
ln -s /var/lib/gconf /etc/osso-af-init/gconf-dir

update-rc.d af-services start 22 2 3 4 5 . stop 22 0 1 6 . > /dev/null
update-rc.d af-startup start 50 2 3 4 . stop 21 0 1 6 . > /dev/null
update-rc.d af-base-apps start 60 2 3 4 . stop 20 0 1 5 6 . > /dev/null
update-rc.d hwclock start 01 S 1 2 3 4 5 . stop 02 0 1 2 3 4 5 6 . > /dev/null
update-rc.d zzzremove-first-boot-flag start 99 S 1 2 3 4 5 . stop 01 0 1 2 3 4 5 6 . > /dev/null

# create memory card mount points ("if" is for Scratchbox)
if [ -w / ]; then
  mkdir -p /media/mmc1 2> /dev/null
  mkdir -p /home/user/MyDocs 2> /dev/null
fi

# evil hack to ensure execute permissions
chmod +x /etc/osso-af-init/get-devlock.sh

# AF environment is included to every shell
line="source /etc/osso-af-init/af-defines.sh"
if ! grep -F -q "$line" /etc/profile; then
  echo "+$line"
  echo "$line" >> /etc/profile
fi

if [ -x /usr/sbin/update-sudoers ]; then
  /usr/sbin/update-sudoers
fi
