# @package      hubzero-mw2-front-virtualssh
# @file         Makefile
# @author       Pascal Meunier <pmeunier@purdue.edu>
# @copyright    Copyright (c) 2010-2018 HUBzero Foundation, LLC.
# @license      http://opensource.org/licenses/MIT MIT
#
# Copyright (c) 2010-2018 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.
#

# Common libraries are installed as owned by root so the client can't modify them, as root may need to use them 

VARLIBDIR=$(DESTDIR)/var/lib
LOGDIR=$(DESTDIR)/var/log
OWNER=root
USRBIN=$(DESTDIR)/usr/bin
USRSBIN=$(DESTDIR)/usr/sbin
USRLIB=$(DESTDIR)/usr/lib
ETC=$(DESTDIR)/etc
USRSHARE=$(DESTDIR)/usr/share
USRSHAREMAN=$(DESTDIR)/usr/share/man
USRSHAREDOC=$(DESTDIR)/usr/share/doc
SBIN=$(DESTDIR)/sbin
VARLOG=$(DESTDIR)/var/log
USRSHAREMANMAN8=$(DESTDIR)/usr/share/man/man8
USRLOCAL=$(DESTDIR)/usr/local

all:
	@true

install:
	install --mode 0750 -d $(VARLOG)/mw-virtualssh
	install --mode 0755 -d $(ETC)/mw-virtualssh
	install --mode 0644 -D front_ssh_config $(ETC)/mw-virtualssh/front_ssh_config
	install --mode 0755 -D ensure-known-host $(USRBIN)/ensure-known-host
	install --mode 0755 -D populate-sftp $(USRBIN)/populate-sftp
	install --mode 0755 -D unpopulate-sftp $(USRBIN)/unpopulate-sftp
	install --mode 0755 -D usr_bin_session.sh $(USRBIN)/session.sh
	install --mode 0755 -D vssh_front_proxy $(USRBIN)/vssh_front_proxy
	install --mode 0755 -D xauth-incoming $(USRBIN)/xauth-incoming
	install --mode 0755 -D xauth-outgoing $(USRBIN)/xauth-outgoing
	install --mode 0644 -D logrotate_front-virtualssh $(ETC)/logrotate.d/hubzero-mw2-front-virtualssh
	install --mode 0755 -D etc_sudoers.d_virtualssh $(ETC)/sudoers.d/virtualssh
	ln -s session.sh $(USRBIN)/session

manual_install: install
	@true

uninstall:
	rm -f $(USRBIN)/populate-sftp
	rm -f $(USRBIN)/ssh_session.py
	rm -f $(USRBIN)/unpopulate-sftp
	rm -f $(USRBIN)/session.sh
	rm -f $(USRBIN)/xauth-incoming
	rm -f $(USRBIN)/xauth-outgoing
	rm -f $(USRBIN)/session
	rm -f $(ETC)/sudoers.d/virtualssh

postinst:
	@true

clean:
	@true

.PHONY: all install uninstall postinst clean
