#! /bin/sh
### BEGIN INIT INFO
# Provides:          debathena-reactivate
# Required-Start:
# Required-Stop: 
# Default-Start:     2 3 4 5
# Default-Stop:
# X-Start-Before:    gdm
# Short-Description: Re-activate Athena cluster machine
# Description:       This script sets up an Athena cluster machine at boot.
#                    Currently, it mutes the sound and sets up a filesystem
#                    for snapshots.
### END INIT INFO

PATH=/sbin:/bin:/usr/bin

case "$1" in
  start)
	# Clean up the per-user files cached locally by gdm.
	rm -rf /var/cache/gdm/*

	# Set the volume to zero for all sound cards, and save that state.
	(/etc/init.d/alsa-utils stop all && alsactl store) > /dev/null 2>&1

	# Create a tmpfs where schroot puts overlays. This is needed
	# because aufs won't let you put an overlay and underlay on the
	# same file system.
	if ! mountpoint -q /var/lib/schroot/union/overlay; then
	    mount -t tmpfs -o size=1073741824 tmpfs /var/lib/schroot/union/overlay
	fi

	# Enable subtree operations on /media by making it a mount point,
	# then share it.
	media_mount=$(mount | awk '$1 == "/media" && $3 == "/media"')
	if [ -z "$media_mount" ]; then
	    mount --bind /media /media
	    mount --make-shared /media
	fi
	;;
  restart|reload|force-reload)
	echo "Error: argument '$1' not supported" >&2
	exit 3
	;;
  stop)
	# No-op
	;;
  *)
	echo "Usage: $0 start|stop" >&2
	exit 3
	;;
esac

:
