################################################################################
#      This file is part of OpenELEC - http://www.openelec.tv
#      Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
#
#  This Program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2, or (at your option)
#  any later version.
#
#  This Program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with OpenELEC.tv; see the file COPYING.  If not, write to
#  the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
#  http://www.gnu.org/copyleft/gpl.html
################################################################################

#
# make variable directory structure
#
# runlevels: openelec, installer, textmode

progress "make variable directory structure"
  mkdir -p /var/cache \
           /var/lib \
           /var/lock \
           /var/media \
           /var/run \
           /var/tmp \
           /var/run/sepermit \
           /var/run/lirc

  chmod 1777 /var/run /var/tmp

  touch /var/run/utmp
    chmod 1777 /var/run/utmp

progress "make runtime directory structure"
  ln -sf /storage/.config/modprobe.d /run/modprobe.d

progress "make logging directory structure"
  if test "$DEBUG" = "yes"; then
    mkdir -p $HOME/log
    ln -sf $HOME/log /var/log
  else
    mkdir -p /var/log
  fi

  touch /var/log/wtmp
    chmod 1777 /var/log/wtmp

progress "make variable library directory structure"
# others:
  mkdir -p /var/lib/polkit-1
    chmod 700 /var/lib/polkit-1
  mkdir -p /var/lib/polkit-1/localauthority/10-vendor.d
  mkdir -p /var/lib/polkit-1/localauthority/20-org.d
  mkdir -p /var/lib/polkit-1/localauthority/30-site.d
  mkdir -p /var/lib/polkit-1/localauthority/50-local.d
  mkdir -p /var/lib/polkit-1/localauthority/90-mandatory.d

  mkdir -p /var/lib/udisks
  mkdir -p /var/lib/upower

progress "make caching directory structure"
  mkdir -p $HOME/.cache/bluetooth
  ln -sf $HOME/.cache/bluetooth /var/lib/bluetooth
