# @package      hubzero-mw-service
# @file         Makefile
# @author       Nicholas J. Kisseberth <nkissebe@purdue.edu>
# @copyright    Copyright (c) 2010-2015 HUBzero Foundation, LLC.
# @license      http://opensource.org/licenses/MIT MIT
#
# Copyright (c) 2010-2015 HUBzero Foundation, LLC.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# HUBzero is a registered trademark of HUBzero Foundation, LLC.
#

USRBIN=$(DESTDIR)/usr/bin
ETC=$(DESTDIR)/etc
USRSHARE=$(DESTDIR)/usr/share
VARLOG=$(DESTDIR)/var/log

all:
	@true

install:
	install --mode 0755 -D maxwell_service $(USRBIN)/maxwell_service
	install --mode 0755 -D set_quotas $(USRBIN)/set_quotas
	install --mode 0755 -D mkvztemplate $(USRBIN)/mkvztemplate
	install --mode 0644 -D hub-session-4.0-i386.conf $(ETC)/vz/conf/hub-session-4.0-i386.conf
	install --mode 0755 -D hub-session-4.0-i386.mount $(ETC)/vz/conf/hub-session-4.0-i386.mount
	install --mode 0755 -D hub-session-4.0-i386.umount $(ETC)/vz/conf/hub-session-4.0-i386.umount
	install --mode 0644 -D hub-session-5.0-i386.conf $(ETC)/vz/conf/hub-session-5.0-i386.conf
	install --mode 0755 -D hub-session-5.0-i386.mount $(ETC)/vz/conf/hub-session-5.0-i386.mount
	install --mode 0755 -D hub-session-5.0-i386.umount $(ETC)/vz/conf/hub-session-5.0-i386.umount
	install --mode 0644 -D hub-session-6.0-i386.conf $(ETC)/vz/conf/hub-session-6.0-i386.conf
	install --mode 0755 -D hub-session-6.0-i386.mount $(ETC)/vz/conf/hub-session-6.0-i386.mount
	install --mode 0755 -D hub-session-6.0-i386.umount $(ETC)/vz/conf/hub-session-6.0-i386.umount
	install --mode 0644 -D hub-session-7.0-i386.conf $(ETC)/vz/conf/hub-session-7.0-i386.conf
	install --mode 0755 -D hub-session-7.0-i386.mount $(ETC)/vz/conf/hub-session-7.0-i386.mount
	install --mode 0755 -D hub-session-7.0-i386.umount $(ETC)/vz/conf/hub-session-7.0-i386.umount
	install --mode 0644 -D hub-session-8.0-i386.conf $(ETC)/vz/conf/hub-session-8.0-i386.conf
	install --mode 0755 -D hub-session-8.0-i386.mount $(ETC)/vz/conf/hub-session-8.0-i386.mount
	install --mode 0755 -D hub-session-8.0-i386.umount $(ETC)/vz/conf/hub-session-8.0-i386.umount
	install --mode 0644 -D hub-session-4.0-amd64.conf $(ETC)/vz/conf/hub-session-4.0-amd64.conf
	install --mode 0755 -D hub-session-4.0-amd64.mount $(ETC)/vz/conf/hub-session-4.0-amd64.mount
	install --mode 0755 -D hub-session-4.0-amd64.umount $(ETC)/vz/conf/hub-session-4.0-amd64.umount
	install --mode 0644 -D hub-session-5.0-amd64.conf $(ETC)/vz/conf/hub-session-5.0-amd64.conf
	install --mode 0755 -D hub-session-5.0-amd64.mount $(ETC)/vz/conf/hub-session-5.0-amd64.mount
	install --mode 0755 -D hub-session-5.0-amd64.umount $(ETC)/vz/conf/hub-session-5.0-amd64.umount
	install --mode 0644 -D hub-session-6.0-amd64.conf $(ETC)/vz/conf/hub-session-6.0-amd64.conf
	install --mode 0755 -D hub-session-6.0-amd64.mount $(ETC)/vz/conf/hub-session-6.0-amd64.mount
	install --mode 0755 -D hub-session-6.0-amd64.umount $(ETC)/vz/conf/hub-session-6.0-amd64.umount
	install --mode 0644 -D hub-session-7.0-amd64.conf $(ETC)/vz/conf/hub-session-7.0-amd64.conf
	install --mode 0755 -D hub-session-7.0-amd64.mount $(ETC)/vz/conf/hub-session-7.0-amd64.mount
	install --mode 0755 -D hub-session-7.0-amd64.umount $(ETC)/vz/conf/hub-session-7.0-amd64.umount
	install --mode 0644 -D hub-session-8.0-amd64.conf $(ETC)/vz/conf/hub-session-8.0-amd64.conf
	install --mode 0755 -D hub-session-8.0-amd64.mount $(ETC)/vz/conf/hub-session-8.0-amd64.mount
	install --mode 0755 -D hub-session-8.0-amd64.umount $(ETC)/vz/conf/hub-session-8.0-amd64.umount
	install --mode 0755 -d $(ETC)/mw-service
	install --mode 0750 -d $(VARLOG)/mw-service
	install --mode 0750 -d $(VARLOG)/mw-service/open-sessions
	install --mode 0644 -D quota.conf $(USRSHARE)/hubzero-mw-service/quota.conf

uninstall:
	@true

postinst:
	chown root:adm /var/log/mw-service
	chown root:adm /var/log/mw-service/open-sessions
	if [ ! -f /etc/mw-service/quota.conf ]; then cp -p /usr/share/hubzero-mw-service/quota.conf /etc/mw-service; fi
	if [ -f /etc/mw-client/notify.key -a ! -f /etc/mw-service/notify.key ]; then cp /etc/mw-client/notify.key /etc/mw-service/notify.key; fi
	if [ -f /etc/mw-service/notify.key ]; then chown root:root /etc/mw-service/notify.key; chmod 0400 /etc/mw-service/notify.key; fi	
	sh ./make_xvnc_cert.sh

clean:
	@true

.PHONY: all install uninstall postinst clean
