#!/bin/sh
##############################################################################
#
#  Copyright (c) 2005, Doremi Labs, Inc.
#    All rights reserved.
#
#  Redistribution in source or binary forms, with or without
#  modification, are NOT permitted.
#
#    Doremi Labs, Inc.
#    306 East Alameda Avenue
#    Burbank, CA 91502
#    Tel : (818) 562 1101
#    Fax : (818) 562 1109
#
#  version 1.0: hmorillon, August 11th 2010
#  
##############################################################################

. ${PKGLIB_SH}

is_debian 3.x
if [ $? -eq 0 ] ; then
	# do NOT install www-data package on Debian version < 4
	exit 1
fi

# Delete old web directory
test -d /doremi/web && rm -rf /doremi/web 

# Stop daemon
test -x /doremi/etc/init.d/drmsoapd.init && \
	/doremi/etc/init.d/drmsoapd.init stop > /dev/null 2>&1
test -x /doremi/etc/init.d/shellinaboxd.init && \
	/doremi/etc/init.d/shellinaboxd.init stop > /dev/null 2>&1

# Cleanup web folder, keeping the themes
test -e /doremi/tmp/themes.$$ && rm -rf /doremi/tmp/themes.$$
test -e /doremi/www/web/themes && mv /doremi/www/web/themes /doremi/tmp/themes.$$
rm -rf /doremi/www/web
install -m 0755 -o www-data -g www-data -d /doremi/www/web
if [ -e /doremi/tmp/themes.$$ ]; then
	mv /doremi/tmp/themes.$$ /doremi/www/web/themes
fi

exit 0
