# Name: filelist
# Project: Sharity
# Author: Christian Starkjohann <cs@obdev.at>
# Creation Date: 1999-04-30
# Tabsize: 4
# Copyright: (c) 1999 by Christian Starkjohann, all rights reserved.
#     For details of the license see the file doc/License.txt.
# This Revision: $Id: filelist,v 1.33 2002/06/03 22:13:08 cs Exp $

# General Description:
# This file contains a list of all directories and files that must be
# installed in order to run Sharity. It is parsed by "sh".

$setname "Sharity"	# Name of this package

############################################################################
##### the defaults in this section can be configured by administrators #####
############################################################################

# Note to administrators: This section asks the user several questions
# by means of the $defvar function. This function takes two parameters:
# (1) The name of the configuration variable (this is used by the file and
# directory definitions later in this script and may also be substituted
# in installed files) and (2) the default value. If the setup script is
# called in quiet mode (-q), it uses the default values without asking.

defaultBrowsedir="/CIFS"
defaultClientMap="unimap8859-1.cfg"
enableAutoUnmount="yes"
creationDisable="no"

# Detect Nextstep/Openstep and MacOS X, because these have special
# character mappings and a different GUI.

if [ -f /usr/lib/NextStep/loginwindow ]; then
	isOpenstep=yes
	isNeXT=yes
	defaultClientMap="unimapNeXT.cfg"
elif [ -f /System/Library/Frameworks/AppKit.framework/AppKit ]; then
	isOpenstep=yes
	isMac=yes
	defaultClientMap="unimapUTF-8.cfg"
	defaultBrowsedir="/Network/CIFS"
	if [ -d /System/Library/StartupItems ]; then
		isMacClient=yes
		defaultClientMap="unimapAppleFullUTF8.cfg"
		enableAutoUnmount="no"
		creationDisable="yes"
	else
		isMacServer=yes
	fi
fi

$defvar "variant" "1" 2<<EOF
The installation script is going to ask you some questions now. Please relax
and read all questions carefully. If you are not an administrator, the
defaults are probably OK for you and you can simply press <RETURN> on each
question. If you are an experienced administrator and have to install on a lot
of clients, you probably don't want to go through this set of questions on
each client. In this case we recommend that you edit the defaults in the file
"filelist" and start setup with the "-q" option (for "quiet").

What kind of installation do you want to perform? Valid options are:
  1 stand-alone       for a completely independent installation of Sharity
                      (recommended!)
  2 server            for a (NFS) file server installation on the server
  3 client-shared     for a file server installation on the client with
                      shared configuration
  4 client-local      for a file server installation on the client with
                      local configuration
If you install on only one (or a few) clients, 'stand-alone' is probably the
type of installation you prefer. If you administer a bigger network, please
read the installation section in the manual for more information about these
options.
EOF

databaseParseInterval=0		# don't re-parse user database regularly except...
cfgParseInterval=5000		# re-parse config every 5 seconds except on NeXT
if [ "$isNeXT" = yes -o "$isMacClient" = yes ]; then
	cfgParseInterval=0		# workaround for NeXT's/Apple's NFS locking bug
fi

case $variant in
	1)		installShared=y; installConfig=y;;
	2)		installShared=y; installConfig=y;;
	3)		databaseParseInterval=10000;;	# needs to load userdb dynamically
	4)		installConfig=y;;
	*)		echo "The installation variant you selected ($variant) does not exist."
			echo "Please check for typos and start the script again."
			exit;;
esac

if [ "$variant" = 1 ]; then

$defvar "globaldir" "/usr/local/sharity" 2<< EOF
Where do you want to install Sharity? Since you decided for the stand-alone
installation, this directory must be on the local disk, not on any server.
Please enter the directory path without trailing slash.
EOF
	privatedir="$globaldir"
	configdir="$globaldir"

else

$defvar "globaldir" "/usr/local/sharity" 2<< EOF
You have selected a server-based installation. We therefore need to know
where on the server Sharity should be installed. If you are installing on
the server, this is the local path where the bulk of the installed files
will go. If you are installing on the client, this is the path where the
installed files are visible on the client. To make it absolutely clear:
This directory must be on the server! Please enter the directory path
without trailing slash.
EOF

$defvar "privatedir" "/usr/local/sharity" 2<< EOF
Now we need to know where to install files which must be local to the machine.
The directory you enter *must* be on the local disk. Please enter the
directory path without trailing slash.
EOF

	if [ "$variant" = 4 ]; then
		configdir="$privatedir"
	else
		configdir="$globaldir"
	fi
fi

if [ -f "$privatedir/uninstall" -o -d "$privatedir/uninstall" ]; then
cat <<EOF
Now that we know all installation pathes, we have found out that there's
already a version of Sharity installed at the given path. Please remove this
previous version and restart the installation script.

You can remove the previous version by executing the script
$privatedir/uninstall.
EOF
	exit 1
fi

$defvar "bindir" "/usr/local/bin" 2<< \EOF
The sharity commandline utilities should be in your search path for easy
access. This can be accomplished in two ways: Either you edit your PATH
environment variable accordingly (you have to do this by hand, the setup
script can't do it for you), or the binaries are symbolically linked to a
directory which is already in your search path.
If you decide for the first variant (edit PATH environment variable), enter
a single dash at the following prompt (*not* an empty line because this
represents the default value!). If you want this install script to create a
bunch of links for the binaries, please enter a directory (without trailing
slash) which is in your search path.
EOF

if [ "$bindir" = "-" ]; then
	bindir=""
fi
if [ "$bindir" = "$globaldir/bin" ]; then
	bindir=""	# avoid overwriting binaries with links
fi

$defvar "browsedir" "$defaultBrowsedir" 2<< EOF
Sharity will install a browsing directory. This directory will contain a list
of servers in your network in the same way as the "Network Neighborhood" in
the Windows(tm) operating systems. Where should this browsing directory be
located (must be on the local disk!)?
EOF

$defvar "wins" "" 2<< \EOF
In order to get browsing working, we need to know whether your network uses
a WINS server (netbios name server) and if it uses one, we need to know it's
IP address. If you don't know, go to a working Windows machine in your
network and look at it's network configuration. If you have a WINS server,
enter it's IP address here. If you don't have one, leave the line blank.
If you have a WINS server and don't know it's address, you might get away
with 255.255.255.255, if there's no router between you and the WINS.
You can change this setting at any time from the GUI configuration tool.
EOF

$defvar "workgroup" "WORKGROUP" 2<< EOF
An other setting which is required for browsing is your workgroup or domain.
As far as Sharity is concerned, these two terms mean the same thing. If you
don't know your workgroup, please go to a working Windows machine and look
it up in the network configuration. Browsing of hosts DEPENDS on the correct
configuration of the Workgroup and the WINS server!
You can change this setting at any time from the GUI configuration tool.
EOF

$defvar "useNfs3" "no" 2<< EOF
Do you want to use the new NFS3 frontend by default to mount shares?
Sharity has can use version 2 or 3 of the NFS protocol to mount things
in your file system. The NFS2 implementation is older and better tested,
but NFS3 buys you access to files larger than 2GB. If you need to access
large files, you must decide for NFS3. However, just because you use
NFS3 does not guarantee that large files will work: Some operating
systems have bugs in their NFS3 implementation in the kernel.
If you use NFS3, we would like to hear about your experiences.
The default frontend module can currently not be changed from the GUI.
You must change the "sortPrecedence" of the "nfs3" module in sharity.cfg.

Please answer "yes" or "no". An invalid answer means "no".
EOF

if [ "$useNfs3" = yes -o "$useNfs3" = Yes -o "$useNfs3" = YES -o "$useNfs3" = y -o "$useNfs3" = Y ]; then
	nfs3SortPrecedence=2000
	echo "Using NFS3 frontend by default"
else
	nfs3SortPrecedence=500
	echo "Using NFS2 frontend by default"
fi

$defvar "optimizeChoice" "speed" 2<< EOF
Do you want to optimize Sharity for speed or for security?
The answer to this question may affect the speed of writes to the server
and the security of cached data. If you optimize for speed, your operating
system may pass cached data to other users on the same client without
going through Sharity's security mechanisms. If you are the only user
on your machine or if you trust all users logged in to your machine, you
can safely optimize for speed. Otherwise you should optimize for security
and see whether the write performance is sufficient.

You can change this setting at any time from the user interface in the
section "CIFS servers" variable "NFS Kernel Attribute Cache Time" or in
the configuration file variable "nfsKernelCacheTime".

Please answer with either speed or security. An invalid answer is equivalent
to "speed".
EOF

if [ "$optimizeChoice" = "security" -o "$optimizeChoice" = "Security" -o "$optimizeChoice" = "SECURITY" ]; then
	echo "*** Optimizing for security!"
	attributeCacheTime=0
else
	echo "*** Optimizing for speed!"
	attributeCacheTime=2
fi

servermap="unimapCP437.cfg"
# This variable defines the unicode character mapping for the server. It
# is only used if the server can't do Unicode. For a list of available options
# see the 'unitables' directory and the README file therein.
# We don't use 'defvar' because the user should better change this through
# the GUI.

clientmap="$defaultClientMap"
# This variable defines the unicode character mapping for the client. This
# mapping is used for all path names, share names and user names. For a list
# of available options see the 'unitables' directory and the README file
# therein.
# We don't use 'defvar' because the user should better change this through
# the GUI.

if [ -n "$isMacClient" ]; then
	automountPath="/Volumes"
else
	automountPath="$privatedir/var/mount"
fi
# This variable defines how the "automountPath" of the default browser
# in sharity.cfg will be configured.

############################################################################
##################### end of user configurable section #####################
############################################################################
# If you are an EXPERIENCED system administrator, you might still want to
# change things below this line, but you should REALLY know what you are
# doing.

#----------------------------------------------------
#           directory				owner   unix-mode
#-------------------------------------------------
$directory  "$privatedir"			root    0755
$directory  "$privatedir/var"		root    0755
$directory  "$privatedir/var/mount"	root    0755
$directory  "$browsedir"			root    0755
if [ "$isMacClient" = yes ]; then
	$directory	/Library/StartupItems			root.admin	0775
	$directory	/Library/StartupItems/Sharity	root.admin	0775
	$file StartupParameters.plist	/Library/StartupItems/Sharity/StartupParameters.plist	root.admin	0664	no
	$link	"$globaldir/sbin/sharity.init"	/Library/StartupItems/Sharity/Sharity
fi
if [ "$isMacServer" = yes ]; then
	$link	"$globaldir/sbin/sharity.init"	/etc/startup/2500_Sharity
fi

#------------------------------------
# the uninstall script:
#------------------------------------
$uninstallscript  "$privatedir/uninstall"

if [ "$installShared" = y ]; then
#----------------------------------------------------
#           	directory           owner   unix-mode
#----------------------------------------------------
	$directory  "$globaldir"		root    0755
	$directory  "$globaldir/bin"	root    0755
	$directory  "$globaldir/sbin"	root    0755
	$directory  "$globaldir/etc"	root    0755

#-----------------------------------------------------------------------------
#	  	file name		destination path            	owner	mode  localize
#-----------------------------------------------------------------------------
	$file sharityd		"$globaldir/sbin/sharityd"		root	0700		no
	$file sharity.init	"$globaldir/sbin/sharity.init"	root	0755		yes
	$file sharity		"$globaldir/bin/sharity"		root	0755		no
	$file sharity.cfg	"$globaldir/etc/sharity.cfg"	root	0644		yes
	$file help.html		"$globaldir/etc/help.html"		root	0644		yes
	$tree unitables		"$globaldir/etc/unitables"		root	a+rX,go-w
if [ "$isOpenstep" != yes ]; then
# NeXT and MacOS-X don't have X11, therefore no X-Windows GUI. The GUI is
# a separate package for these operating systems.
	$file Sharity		"$globaldir/bin/Sharity"		root	0755		no
fi
# don't install the manual with $tree because it needs to be localized
	if [ -d manual ]; then
		$directory  "$globaldir/manual"	root    0755
		for manfile in manual/*; do
			if [ `expr "$manfile" ':' '.*[.]html$'` != 0 ]; then
				$file "$manfile" "$globaldir/$manfile" root 0644 yes
			else
				$file "$manfile" "$globaldir/$manfile" root 0644 no
			fi
		done
	else
		echo "*** Directory \"manual\" missing -- skipping."
	fi

#-----------------------------------------------------------------------------
#          	source path                 destination path
#-----------------------------------------------------------------------------
	$link	sharity						"$globaldir/bin/cifslicense"
	$link	sharity						"$globaldir/bin/cifslist"
	$link	sharity						"$globaldir/bin/cifslogin"
	$link	sharity						"$globaldir/bin/cifslogout"
	$link	sharity						"$globaldir/bin/cifsmount"
	$link	sharity						"$globaldir/bin/cifsstore"
	$link	sharity						"$globaldir/bin/cifsstoremnt"
	$link	sharity						"$globaldir/bin/cifsumount"
fi

if [ "$installConfig" = y ]; then
#----------------------------------------------------
#           	directory           owner   unix-mode
#----------------------------------------------------
	$directory  "$configdir"		root    0755
	$directory  "$configdir/var"	root    0755

#-----------------------------------------------------------------------------
#	  	file name		destination path            	owner	mode  localize
#-----------------------------------------------------------------------------
	$file cfgdb.ppl		"$configdir/var/cfgdb.ppl"		root	0644		yes
fi

if [ -n "$bindir" ]; then
#----------------------------------------------------
#           	directory           owner   unix-mode
#----------------------------------------------------
	$directory  "$bindir"		root    0755

#-----------------------------------------------------------------------------
#          	source path                 destination path
#-----------------------------------------------------------------------------
	$link	"$globaldir/bin/sharity"	"$bindir/cifslicense"
	$link	"$globaldir/bin/sharity"	"$bindir/cifslist"
	$link	"$globaldir/bin/sharity"	"$bindir/cifslogin"
	$link	"$globaldir/bin/sharity"	"$bindir/cifslogout"
	$link	"$globaldir/bin/sharity"	"$bindir/cifsmount"
	$link	"$globaldir/bin/sharity"	"$bindir/cifsstore"
	$link	"$globaldir/bin/sharity"	"$bindir/cifsstoremnt"
	$link	"$globaldir/bin/sharity"	"$bindir/cifsumount"
	$link	"$globaldir/bin/sharity"	"$bindir/sharity"
	if [ -f "$globaldir/bin/Sharity" ]; then
		$link	"$globaldir/bin/Sharity"	"$bindir/Sharity"
	fi
fi

#--------------------------------------------
# additional files/directories to uninstall:
#--------------------------------------------
$removeaction "rm -f '$privatedir/var/sharity.udb'"
$removeaction "rm -f '$privatedir/var/sharity.pid'"
$removeaction "rmdir $privatedir/var/mount/* 2>/dev/null"
$removeaction "'$globaldir/sbin/sharity.init' stop"

if [ "$isMac" != yes ]; then
cat <<EOF

The installation is now complete.

How to go ahead from here:
==========================

There are two things you have to do by hand. The first is the automatic start
of the sharityd daemon during system boot. How this is done depends on the
Unix flavor you have. Most systems have a startup directory containing startup
scripts for each service. In this case just make a symbolic link from that
directory pointing to $globaldir/sbin/sharity.init.
If your system uses an rc.local script which starts all local services, just
call $globaldir/sbin/sharity.init from there.

The second thing is the Sharity GUI. You should always have it running as
long as you are logged in because it pops up password dialogs on demand. The
GUI application is at $globaldir/bin/Sharity.
Within the GUI application use the "Help" button for the context sensitive
online help and please READ THE INTRODUCTION to the help system which pops up
after clicking "Help". Most of the settings will not be editable. If you hold
the mouse cursor over a setting's description, the status bar will tell you
why a setting is not editable. Please don't switch to "Expert Mode" unless you
are sure you have to change an expert setting! If you ever want to uninstall
Sharity, use the script $privatedir/uninstall.
The manual can be found at $globaldir/manual/index.html
EOF

fi
