home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1998 July & August
/
Pcwk78a98.iso
/
Wtestowe
/
Clico
/
UNIX
/
SAMBA
/
SMB_SCO3.Z
/
SMB_SCO3
/
install
< prev
next >
Wrap
Text File
|
1997-08-27
|
9KB
|
481 lines
#!/bin/sh
#
# SAMBA SMB Server Installation Script
#
# %Z% %M%; Version %I%; Created %E% %U%
# ------------------------------------------------------------------------
# Copyright (C) JSB Computer Systems Ltd, 1997.
#
# This module contains proprietary information of JSB Computer Systems Ltd,
# and should be treated as Confidential.
##
# Common Environment Variables.
##
HOMEDIR=`pwd`
LOCALDIR=/usr/local
DEFAULTCENTRAL=$LOCALDIR/samba ## the default central directory
CENTRAL=$DEFAULTCENTRAL ## the default central directory for install
DEFAULTCONFILE=$CENTRAL/lib/smb.conf
BINDIR=/usr/bin
CONFILE=$DEFAULTCONFILE
SLIST=server.list
WORKGROUP=WORKGROUP
if [ -x /usr/5bin/echo ]
then
ECHO=/usr/5bin/echo
else
ECHO=echo
fi
PAGER=${PAGER:-more}
README=README
## make sure permissions in the central directory are OK
CHECK_PERMS=TRUE
##
## Internationalisation begins here
##
# Error Messages.
##
ERR01=" Could not find "
ERR02="failed with following error :"
ERR03="aborted\n"
ERR05=" Could not create directory "
ERR06=" Could not change permissions on directory "
ERR07=" You are installing from the wrong directory - check installation notes"
ERR08=" Missing file - "
ERR09=" Could not change ownership for "
ERR10=" Could not change group for "
ERR11=" Could not copy files "
ERR13=" Serialisation aborted at user request "
ERR14=" Installation aborted at user request "
ERR15=" Could not change permissions for "
BRAND03="\nInvalid upgrade path - no action taken."
BRAND05="\nYou must run as root to install / upgrade."
##
# Prompts
##
PRM01="\nInstallation of SAMBA SMB Server\n================================\n"
PRM03="\nDo you wish to try again \c"
PRM05="completed successfully."
PRM14="Checking file permissions\c"
PRM15="\nInstallation"
PRM17="\nThere is a readme file containing notes specific to this release.\nDo you wish to read it now \c"
PRM18="\nMoving files into place\c"
CHKYN00=Y
CHKYN01=y
CHKYN02=N
CHKYN03=n
CHKYN04=Q
CHKYN05=q
CHKYN06="(y/n)? \c"
##
## Internationalisation ends here
##
##
# UNIX Tools List
##
TOOLSLIST="/bin/cat /bin/chmod /bin/mkdir /bin/mv /bin/pwd /bin/rm \
/usr/bin/cut /bin/find /bin/cp /bin/cpio /bin/sed /bin/grep"
##
# infail() - report error and exit
##
infail()
{
$ECHO "\n\n$PRM15 $ERR02\n"
$ECHO $1 $2
$ECHO "$PRM15 $ERR03"
exit 1
}
##
# set_conf()
##
set_conf()
{
# $1 - file to convert
# $2 - value of JSB_WORKGROUP to replace
DIR=`echo $2 | sed 's/\//\\\\\//g'`
cat $1 | sed '{
s/JSB_WORKGROUP/'$DIR'/g
}'
}
##
# isserver() - check is samba server running
##
isserver()
{
ps -ef | grep smbd | grep -v grep >/dev/null 2>&1
if [ $? -eq 0 ]
then
infail "Cannot install while SAMBA Server running"
fi
}
##
# CopyFiles() - copy files from temp dir to installation dir
##
CopyFiles()
{
$ECHO "\nCopying files to $CENTRAL \c"
if [ ! -d $LOCALDIR ]
then
mkdir $LOCALDIR 2> /dev/null
fi
if [ ! -d $LOCALDIR/man ]
then
mkdir $LOCALDIR/man 2> /dev/null
chmod 755 $LOCALDIR/man
fi
mkdir $CENTRAL 2> /dev/null
mkdir $CENTRAL/bin 2> /dev/null
mkdir $CENTRAL/var 2> /dev/null
mkdir $CENTRAL/var/locks 2> /dev/null
mkdir $CENTRAL/lib 2> /dev/null
mkdir $CENTRAL/docs 2> /dev/null
cp $HOMEDIR/server.list $CENTRAL
cp $HOMEDIR/COPYING $CENTRAL
cp $HOMEDIR/README $CENTRAL
cd $HOMEDIR/bin
find . -print | cpio -pdu $CENTRAL/bin 2> /dev/null || infail "$ERR11"
cd $HOMEDIR/docs
cp * $CENTRAL/docs
if [ $UpGradeProduct = FALSE ]
then
############# fresh install ##########
set_conf $HOMEDIR/lib/smb.conf $WORKGROUP > $CONFILE
fi
}
##
# MoveBin() - move files into place
##
MoveBin()
{
$ECHO "\n$PRM18 \c"
$ECHO ".\c"
mv -f $CENTRAL/bin/startsmb $BINDIR || infail "$ERR11"
$ECHO ".\c"
chmod 555 $BINDIR/startsmb || infail "$ERR15" $SERVBIN
$ECHO ".\c"
chown root $BINDIR/startsmb || infail "$ERR15" $SERVBIN
$ECHO ".\c"
chgrp 1 $BINDIR/startsmb || infail "$ERR15" $SERVBIN
cd $HOMEDIR
}
##
# chkyn() - Get yes or no answer
##
chkyn()
{
while :
do
$ECHO $CHKYN06
read reply
case $reply in
$CHKYN00*|$CHKYN01*) return 0 ;;
$CHKYN02*|$CHKYN03*) return 1 ;;
esac
done
}
##
# start_up() - Start Up message
##
start_up()
{
$ECHO $PRM01
DIRNAME=`dirname $0`
if [ $DIRNAME != "." ]
then
infail "$ERR07"
fi
UpGradeProduct=FALSE
if [ -f "$CENTRAL/bin/smbd" ]
then
# see if server running before installing
isserver
while [ TRUE ]
do
echo "\nInstall has detected a previous installation in $CENTRAL"
echo "\n\nChoose one of the following options;"
echo "\n1. Upgrade the existing installation"
echo "2. Create a new installation"
echo "3. Quit"
echo "\nSelect 1,2,3 or enter for default <1> ? \c"
read REP
if [ "$REP" = "3" ]
then
infail "$ERR13"
fi
if [ "$REP" = "2" ]
then
CENTRAL=$DEFAULTCENTRAL
CONFILE=$DEFAULTCONFILE
break
else
if [ "$REP" = "" -o "$REP" = "1" ]
then
UpGradeProduct=TRUE
return
fi
fi
done
fi
if [ $UpGradeProduct = FALSE ]
then
echo "\nEnter the workgroup for the server to use (default is $WORKGROUP) ? \c"
REP=
read REP
if [ ! -z "$REP" ]
then
WORKGROUP=$REP
fi
fi
}
##
# unix_tools() - Ensure UNIX utilities are available.
##
unix_tools()
{
for tool in `$ECHO $TOOLSLIST`
do
[ -x $tool ] || infail "$ERR01" $tool
done
}
##
# SuCheck() - returns 0 if running root ( Super-user )
# 1 if not
##
SuCheck()
{
cd /tmp
TMP=smb.$$
cat /dev/null > $TMP
FIND=`find . -user 0 -name $TMP -print 2>/dev/null`
rm -f $TMP
if [ "$FIND" != ./$TMP ]
then
infail "$BRAND05"
fi
cd $HOMEDIR
}
##
# checkpermissions() - Ensure file permissions and ownerships
# file is read in on standard input and each line is set
# into the environment where
# $1 is the owner
# $2 is the group
# $3 is the permissions
# $4 is the filename
##
checkpermissions()
{
cd $CENTRAL
list=`line`
while [ -n "$list" ]
do
$ECHO ".\c"
set `$ECHO "$list`
FirstChar=`$ECHO $1 | cut -c1 `
if [ $FirstChar != "#" ] ## its a comment
then
if [ -f "$4" -o -d "$4" ]
then
chmod $3 $4 || $ECHO $PRM13 $ERR15 $4
chown $1 $4 || $ECHO $PRM13 $ERR09 $4
chgrp $2 $4 || $ECHO $PRM13 $ERR10 $4
else
$ECHO "\n$PRM13 $ERR08 $4"
fi
fi
list=`line`
done
}
##
# do_links() - set file permissions
##
do_links()
{
$ECHO ".\n"
chmod 755 $CENTRAL
chown root $CENTRAL
chgrp 1 $CENTRAL
if [ $CHECK_PERMS = TRUE ]
then
$ECHO "$PRM14 \c"
if [ -f $CENTRAL/$SLIST ]
then
cat $CENTRAL/$SLIST | checkpermissions
rm -f $CENTRAL/$SLIST
fi
fi
}
##
# page_readme() - page the readme file if requested by user
##
page_readme()
{
if [ -s $CENTRAL/$README ]
then
chmod 444 $CENTRAL/$README
$ECHO
$ECHO "$PRM17" ## do yo want to see the readme file
chkyn ## y/n
if [ $? -eq 0 ]
then
cat $CENTRAL/README | $PAGER ## page the readme file
fi
fi
}
##
# main()
##
##
# Catch any efforts to abort
##
trap 'infail "$ERR14"' 1 2 4 9 15
SCRIPTNAME=`basename $0`
##
# initialisation messages
##
start_up
##
# check you're Super-User
##
SuCheck
##
# check that we have all the required utilities
##
unix_tools
##
# copy files from temp dir into installation dir
##
CopyFiles
##
# move binaries etc into path
##
MoveBin
##
# check permissions of files
##
do_links
##
# install man pages
#
$ECHO
$ECHO
$CENTRAL/bin/installman.sh $LOCALDIR/man $CENTRAL/docs
##
# show readme
#
page_readme
$ECHO
$ECHO "$PRM15 $PRM05" ## Installation successful
if [ `uname` = "HP-UX" ]
then
echo
echo "WARNING: Before running the SAMBA SMB Server make sure that the"
echo " server guest account directive is set to a valid"
echo " account on this system in the file $CONFILE"
echo " or create a nobody account."
echo
echo " Failure to do so will compromise the security of the"
echo " server.\n"
fi
echo "\nTo start the SAMBA SMB Server type startsmb at the command prompt"
$ECHO
exit 0