#!/bin/sh

#
# CDWserver/CDWinstall.sh
#
# This file is part of webCDwriter - Network CD Writing.
#
# Copyright (C) 2003 Jörg P. M. Haeger
#
# webCDwriter is free software. See CDWserver.cpp for details.
#

DEST=/home/CDWserver/bin/

if ([ "$1" != cdrdao ] \
			&& [ "$1" != cdrecord ] \
			&& [ "$1" != mkisofs ]) \
		|| [ -z "$2" ]; then
	echo
	echo "$0 cdrdao BINARY"
	echo "$0 cdrecord BINARY"
	echo "$0 mkisofs BINARY"
	echo
	exit 1
fi

if [ ! -e "$2" ]; then
	echo
	echo "$2 does not exist!"
	echo
	exit 1
fi

if [ ! "`id -u`" = "0" ]; then
	echo
	echo "$0 will copy $2 to $DEST$1"
	echo "and prepare for setuid root execution."
	echo
	echo "Restart as root!"
	echo
	exit 1
fi

echo
echo -n "Copying $2 to $DEST... "

cp -pf $2 $DEST$1
chown root.cdwriter $DEST$1
chmod 4750 $DEST$1

echo "done"
echo
