#!/bin/sh
# some misc terminal-server boot cleanups

# Source function library.
. /etc/rc.d/init.d/functions

# See how we were called.
case "$1" in
  start)

    gprintf "Create/mount additional directories: "  
    [[ -d /var/run/console ]] || mkdir /var/run/console

    # remount client specific mount point rw
    UMOUNTS=$(/usr/sbin/unionctl / --list | wc -l)
    if [ "$UMOUNTS" = 3 ]; then
      /usr/sbin/unionctl / --mode rw /
    fi
   
    # seperate /home partititon
    HOMES=$(ls /home)
    if [ -z "$HOMES" ]; then
      gprintf "NFS mount /home: "
      SIP=$(mount | grep 'type nfs' | head -1 | awk -F: '{print $1}')
      mount -t nfs -o nolock,rsize=8192,wsize=8192 $SIP:/home /home
    fi

    # only exists if nautilus is installed
    [[ -d /var/lib/gnome/desktop ]] && mount /var/lib/gnome/desktop
    echo
    ;;
  stop)
    gprintf "Nothing to do for stop: "
    echo
    ;;
  *)
    gprintf "*** Usage: terminal-server {start|stop}\n"
    exit 1
esac

exit 0
