#!/bin/sh
# -*- sh-basic-offset: 2; indent-tabs-mode: nil; -*-
#
# Create RW directories.
#

CONFDIR=/etc/rw-dirs.d

case "$1" in
  start)
    for c in $CONFDIR/*.conf; do
      [ ! -r $c ] && continue

      while read type path target; do
        case $type in
          ''|'#') ;;
          d) mkdir -p $path;;
          l) ln -sf $path $target;;
          m) mount --bind $path $target;;
          *) echo "Wrong specifier in $c: '$type $path${target:+ $target}'. Ignoring..." > /dev/stderr;;
        esac
      done < $c
    done
    ;;
  stop)
    ;;
  *)
    echo "Usage: $0 start|stop"
    exit 1
    ;;
esac
