#!/bin/sh
### BEGIN INIT INFO
# Provides:          x2gothinclient-chroot
# Required-Start:    $local_fs
# Required-Stop:
# Default-Start:     S
# Default-Stop:
# X-Start-Before:    nfs-common alsa-utils
# Short-Description:
# Description:       Prepare X2Go TCE tmpfs directories for usage
### END INIT INFO

set -e

. /lib/lsb/init-functions

# pre-init X2Go Thin Client through init script...
if [ -d /usr/share/doc/x2gothinclient-displaymanager ]; then
	test -x /etc/x2go/x2gothinclient_init && . /etc/x2go/x2gothinclient_init
fi

case "$1" in
  start|"")
        # prep tmpfs subfolders for nfs-common
        mkdir -p /var/lib/nfs/rpc_pipefs
        mkdir -p /var/lib/nfs/sm
        mkdir -p /var/lib/nfs/sm.bak
        chown statd:nogroup /var/lib/nfs/rpc_pipefs
        chown statd:nogroup /var/lib/nfs/sm
        chown statd:nogroup /var/lib/nfs/sm.bak
        exit 0
        ;;
  restart|reload|force-reload|status)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
  stop)
        # No-op
        ;;
  *)
        echo "Usage: x2gothinclient-chroot start" >&2
        exit 3
        ;;
esac
