All pastes #757717 Raw Edit

Mine

public text v1 · immutable
·published 2007-11-01 15:35 UTC
rendered paste body
#! /bin/sh
#	install.sh
#	Copyright (c) 1999, by Powerware (R) Corporation. All rights reserved.
#	A shell script which installs LanSafe for Unix
#	It extracts the data from the media and copies it to /usr/ls3,
#	edits /etc/services, /etc/inittab and a few other things.
#	At the end it runs install.ls
:
PATH=$PATH:/bin:/usr/bin:/usr/ucb:.; export PATH

initDefines() {
DGUX_SYS_ERROR=1
ERR_UNKNOWN_SYS_STR1=2
ERR_UNKNOWN_SYS_STR2=3
ERR_UNKNOWN_SYS_STR3=4
ERR_CHECK_FATAL_OVERRIDE=5
ERR_CHECK_FATAL_EXIT=6
ERR_CHECK_STATUS=7
INSTALL_FROM=8
INSTALL_TO=9
INSTALLED_STR=10
INSTALLED_DONE=11
GET_DEVICE_NAME=12
INSTALL_DEVICE=13
ERR_INVALID_DIR=14
ERR_INVALID_DEVICE_STR1=15
ERR_INVALID_DEVICE_STR2=16
OK_STR=17
ERR_NO_DEVICE=18
EXTRACTING_FILE=19
ERR_EXTRACTING_FILE=20
UPS_DRIVER_STR1=21
UPS_DRIVER_STR2=22
UPS_DRIVER_STR3=23
UW2_UPS_DRIVER_STR1=24
UW2_UPS_DRIVER_STR2=25
UW2_UPS_DRIVER_STR3=26
UW2_UPS_DRIVER_STR4=27
UW2_UPS_DRIVER_STR5=28
UW2_UPS_DRIVER_STR6=29
UW2_UPS_DRIVER_STR7=30
UW2_UPS_DRIVER_STR8=31
IA_UPS_DRIVER_STR1=32
IA_UPS_DRIVER_STR2=33
IA_UPS_DRIVER_STR3=34
IA_UPS_DRIVER_STR4=35
IA_UPS_DRIVER_STR5=36
IA_UPS_DRIVER_STR6=37
IA_UPS_DRIVER_STR7=38
IA_UPS_DRIVER_STR8=39
GENERAL_UPS_DRIVER_STR1=40
GENERAL_UPS_DRIVER_STR2=41
GENERAL_UPS_DRIVER_STR3=42
ASK_INSTALL_DEVICE_DRV=43
NO_INSTALL_DRV_STR1=44
NO_INSTALL_DRV_STR2=45
NO_INSTALL_DRV_STR3=46
ERR_SERVICES_FILE_STR1=47
ERR_SERVICES_FILE_STR2=48
ERR_SERVICES_FILE_STR3=49
ADDING_LS_SERVICE=50
MODIFIED_SERVICES=51
REMOVE_SERVICE_STR=52
ADD_SERVICE_STR=53
PM_DESCRIPTION=54
REMOVED_STR=55
COPY_INIT_FILE=56
INSTALLING_INIT_FILE=57
INSTALLED_STR=58
DELETING_FILE_STR=59
LINK_FILE_STR=60
LINKED_STR=61
WELCOME_STR1=62
WELCOME_STR2=63
WELCOME_STR3=64
CONTINUE_INSTALLATION=65
INSTALL_INTRO_STR1=66
INSTALL_INTRO_STR2=67
INSTALL_INTRO_STR3=68
INSTALL_INTRO_STR4=69
INSTALL_INTRO_STR5=70
INSTALL_INTRO_STR6=71
INSTALL_INTRO_STR7=72
INSTALL_INTRO_STR8=73
AGENT_INSTALL_INTRO_STR1=74
AGENT_INSTALL_INTRO_STR2=75
AGENT_INSTALL_INTRO_STR3=76
AGENT_INSTALL_INTRO_STR4=77
AGENT_INSTALL_INTRO_STR5=78
AGENT_INSTALL_INTRO_STR6=79
AGENT_INSTALL_INTRO_STR7=80
ERR_UNKNOWN_SYSTEM=81
SVR4_AGENT_INSTALL_STR1=82
SVR4_AGENT_INSTALL_STR2=83
INSTALL_SOURCE_CDROM=84
INSTALL_SOURCE_TARFILE=85
DEFAULT_PATH_STR=86
ASK_CHANGE_INSTALL_PATH=87
ENTER_INSTALL_PATH=88
NEW_PATH=89
ERR_INSTALL_PATH=90
ERR_AGENT_INSTALL_PATH_STR1=91
ERR_AGENT_INSTALL_PATH_STR2=92
AUTO_START_STR1=93
AUTO_START_STR2=94
AUTO_START_STR3=95
AUTO_START_STR4=96
AUTO_START_STR5=97
AUTO_START_STR6=98
CONFIRM_INSTALL_PARAMS_STR1=99
CONFIRM_INSTALL_PARAMS_STR2=100
CONFIRM_INSTALL_PARAMS_STR3=101
CONFIRM_INSTALL_PARAMS_STR4=102
CONFIRM_INSTALL_PARAMS_STR5=103
LICENSE_AGREEMENT=104
ERR_LIC_AGREE=105
ERR_AUTO_LOAD_STR1=106
ERR_AUTO_LOAD_STR2=107
ERR_AUTO_LOAD_STR3=108
CONFIRM_OK=109
ERR_UW2_DRY_CONTACT_UPS=110
EXTRACT_AGENT_WAIT=111
ERR_EXTRACT_AGENT=112
ERR_LINK_HPUX_STR1=113
ERR_LINK_HPUX_STR2=114
ERR_LINK_HPUX_STR3=115
ERR_LINK_HPUX_STR4=116
ERR_LINK_HPUX_STR5=117
PRESS_CONTINUE=118
ERR_LINK_SUNOS_STR1=119
ERR_LINK_SUNOS_STR2=120
ERR_LINK_SUNOS_STR3=121
ERR_LINK_SUNOS_STR4=122
ERR_LINK_SUNOS_STR5=123
ERR_LINK_SUNOS_STR6=124
ERR_LINK_SUNOS_STR7=125
ERR_LINK_SUNOS_STR8=126
SUCCESS_INSTALLED_LS=127
REGISTRATION_STR1=128
REGISTRATION_STR2=129
WARN_WEB_BROWSER=130
UNSUCCESS_INSTALLED_LS=131
ERR_UNKNOWN_SYS_STR4=132
REFRESH_SNMP=133
MIB_MODIFY_STR1=134
MIB_MODIFY_STR2=135
ERR_HPUX_PATCH=136
HPUX_EXT_AGENT_GOOD=137
ERR_NORUN_HPUX_EXT_AGENT_STR1=138
ERR_NORUN_HPUX_EXT_AGENT_STR2=139
ERR_NORUN_HPUX_EXT_AGENT_STR3=140
ERR_NORUN_HPUX_EXT_AGENT_STR4=141
ERR_NO_EXIST_HPUX_EXT_AGENT_STR1=142
ERR_NO_EXIST_HPUX_EXT_AGENT_STR2=143
ERR_NO_EXIST_HPUX_EXT_AGENT_STR3=144
ERR_NO_EXIST_HPUX_EXT_AGENT_STR4=145
WARN_HPUX_MODIFY_EXTFILE_STR1=146
WARN_HPUX_MODIFY_EXTFILE_STR2=147
ERR_HPUX_TRAP_STR1=148
ERR_HPUX_TRAP_STR2=149
SOL_EXT_AGENT_GOOD=150
ERR_NORUN_SOL_EXT_AGENT_STR1=151
ERR_NORUN_SOL_EXT_AGENT_STR2=152
ERR_NORUN_SOL_EXT_AGENT_STR3=153
ERR_NORUN_SOL_EXT_AGENT_STR4=154
ERR_NO_EXIST_SOL_EXT_AGENT_STR1=155
ERR_NO_EXIST_SOL_EXT_AGENT_STR2=156
ERR_NO_EXIST_SOL_EXT_AGENT_STR3=157
ERR_NO_EXIST_SOL_EXT_AGENT_STR4=158
ERR_SOL_SNMP_TRAP_STR1=159
ERR_SOL_SNMP_TRAP_STR2=160
ERR_SOL_SNMP_TRAP_STR3=161
ERR_SOL_SNMP_TRAP_STR4=162
ERR_SOL_SNMP_TRAP_STR5=163
PM_RUNNING=164
WARN_PM_NOT_RUN_STR1=165
WARN_PM_NOT_RUN_STR2=166
WARN_PM_NOT_RUN_STR3=167
WARN_PM_NOT_RUN_STR4=168
WARN_PM_NOT_RUN_STR5=169
AUTO_START_AGENT_STR1=170
AUTO_START_AGENT_STR2=171
AUTO_START_AGENT_STR3=172
AGENT_PARAMS_TO_STR1=173
AGENT_PARAMS_TO_STR2=174
AGENT_PARAMS_TO_STR3=175
AGENT_PARAMS_TO_STR4=176
AGENT_CUSTOM_PATH_STR1=177
AGENT_CUSTOM_PATH_STR2=178
ERR_NO_PM_EXE=179
ERR_ABS_PATH=180
ERR_AGENT_SYS_STR1=181
ERR_AGENT_SYS_STR2=182
ERR_NOT_DEVICE_NAME=183
ERR_NO_DIR=184
AGENT_WELCOME_STR1=185
AGENT_WELCOME_STR2=186
AGENT_WELCOME_STR3=187
AGENT_WELCOME_STR4=188
AGENT_WELCOME_STR5=189
AGENT_WELCOME_STR6=190
AGENT_WELCOME_STR7=191
AGENT_WELCOME_STR8=192
SNMP_DEAMON_RUNNING=193
ERR_SNMP_DEAMON_NOT_RUN_STR1=194
ERR_SNMP_DEAMON_NOT_RUN_STR2=195
ERR_SNMP_DEAMON_NOT_RUN_STR3=196
ERR_SNMP_DEAMON_NOT_RUN_STR4=197
ERR_SNMP_DEAMON_NOT_RUN_STR5=198
AGENT_SAME_DIR_STR1=199
AGENT_SAME_DIR_STR2=200
AGENT_FOUND_DEF_PATH_STR1=201
AGENT_FOUND_DEF_PATH_STR2=202
WARN_NO_DEF_PATH_STR1=203
WARN_NO_DEF_PATH_STR2=204
AGENT_CUSTOM_PATH=205
AGENT_SUCCESS_INSTALLED=206
ERR_INVALID_ARGUMENTS=207
AGENT_USAGE_STR=208
USAGE_STR=209
REGISTER_WEBSITE=210
ERR_INSTALL_ROOT_PATH=211
LS_VERSION=212
}

compute_files () {
cat <<EOF
PowerMonitor.email
PowerMonitor.broadcast
PowerMonitor.shutdown
PowerMonitor.unload
PowerMonitor.sh
upslist.ups
PowerMonitorEvents.def
install.ls
install.txt
PowerMonitorC
PowerMonitorM
PowerMonitorX
PowerMonitorIcon
uninstall.sh
OEMModel.ini
license.txt
EOF

#if [ $system = "sco" ]; then
#	cat <<EOF
#s1.objscr
#picture.px
#Ls3.node
#EOF
#fi

#if [ $system = "sunos" ]; then
#	cat <<EOF
#XKeysymDB
#chk4patch.sh
#EOF
#fi

#if [ "$system" = "linux" ]; then
#	cat <<EOF
#ls3conX.sco
#README.TXT
#EOF
#fi
}

Convert_Case () {
	if [ -n "$uppercase_mount" ]; then
		echo `Convert_UpperCase $1`
	else
		echo `Convert_LowerCase $1`
	fi
}

Convert_UpperCase () {
	case $1 in
	PowerMonitor.email)
		echo POWERMONITOR.EMAIL
		;;
	PowerMonitor.broadcast)
		echo POWERMONITOR.BROADCAST
		;;
	PowerMonitor.shutdown)
		echo POWERMONITOR.SHUTDOWN
		;;
	PowerMonitor.unload)
		echo POWERMONITOR.UNLOAD
		;;
	PowerMonitor.sh)
		echo POWERMONITOR.SH
		;;
#	ls3icon)
#		echo LS3ICON
#		;;
#	ls3conX.ico)
#		echo LS3CONX.ICO
#		;;
	hoh.hlp)
		echo HOH.HLP
		;;
#	ls3conX.hlp)
#		echo LS3CONX.HLP
#		;;
	PowerMonitor.hlp)
		echo POWERMONITOR.HLP
		;;
	manualu.hlp)
		echo MANUALU.HLP
		;;
	manualu.rtf)
		echo MANUALU.RTF
		;;
#	install.mfg)
#		echo INSTALL.MFG
#		;;
#	install.ups)
#		echo INSTALL.UPS
#		;;
	upslist.ups)
		echo UPSLIST.UPS
		;;
	PowerMonitorEvents.def)
		echo POWERMONITOREVENTS.DEF
		;;
	install.ls)
		echo INSTALL.LS
		;;
	install.txt)
		echo INSTALL.TXT
		;;
	PowerMonitorC)
		echo POWERMONITORC
		;;
	PowerMonitorM)
		echo POWERMONITORM
		;;
	PowerMonitorX)
		echo POWERMONITORX
		;;
	PowerMonitorIcon)
		echo POWERMONITORICON
		;;
	PowerMonitorHelp)
		echo POWERMONITORHELP
		;;
	PowerMonitorRetainLog.cfg)
		echo POWERMONITORRETAINLOG.CFG
		;;
	uninstall.sh)
		echo UNINSTALL.SH
		;;
	OEMModel.ini)
		echo OEMMODEL.INI
		;;
	license.txt)
		echo LICENSE.TXT
		;;
#	s1.objscr)
#		echo S1.OBJ
#		;;
#	picture.px)
#		echo PICTURE.PX
#		;;
#	Ls3.node)
#		echo LS3.NOD
#		;;
#	XKeysymDB)
#		echo XKEYSYMD
#		;;
#	chk4patch.sh)
#		echo CHK4PATC.SH
#		;;
#	ls3conX.sco)
#		echo LS3CONX.SCO
#		;;
#	readme.txt|README.TXT)
#		echo README.TXT
#		;;
	*)
		echo UNKNOWN
		;;
	esac
}

Convert_LowerCase () {
	case $1 in
	PowerMonitor.email)
		echo powermonitor.email
		;;
	PowerMonitor.broadcast)
		echo powermonitor.broadcast
		;;
	PowerMonitor.shutdown)
		echo powermonitor.shutdown
		;;
	PowerMonitor.unload)
		echo powermonitor.unload
		;;
	PowerMonitor.sh)
		echo powermonitor.sh
		;;
#	ls3icon)
#		echo ls3icon
#		;;
#	ls3conX.ico)
#		echo ls3conx.ico
#		;;
	hoh.hlp)
		echo hoh.hlp
		;;
#	ls3conX.hlp)
#		echo ls3conx.hlp
#		;;
	PowerMonitor.hlp)
		echo powermonitor.hlp
		;;
	manualu.hlp)
		echo manualu.hlp
		;;
	manualu.rtf)
		echo manualu.rtf
		;;
#	install.mfg)
#		echo install.mfg
#		;;
	install.ups)
		echo install.ups
		;;
	upslist.ups)
		echo upslist.ups
		;;
	PowerMonitorEvents.def)
		echo powermonitorevents.def
		;;
	install.ls)
		echo install.ls
		;;
	install.txt)
		echo install.txt
		;;
	PowerMonitorC)
		echo powermonitorc
		;;
	PowerMonitorM)
		echo powermonitorm
		;;
	PowerMonitorX)
		echo powermonitorx
		;;
	PowerMonitorIcon)
		echo powermonitoricon
		;;
	PowerMonitorHelp)
		echo powermonitorhelp
		;;
	PowerMonitorRetainLog.cfg)
		echo powermonitorretainlog.cfg
		;;
	uninstall.sh)
		echo uninstall.sh
		;;
	OEMModel.ini)
		echo oemmodel.ini
		;;
	license.txt)
		echo license.txt
		;;
#	s1.objscr)
#		echo s1.obj
#		;;
#	picture.px)
#		echo picture.px
#		;;
#	Ls3.node)
#		echo ls3.nod
#		;;
#	XKeysymDB)
#		echo xkeysymd
#		;;
#	chk4patch.sh)
#		echo chk4patch.sh
#		;;
#	ls3conX.sco)
#		echo ls3conx.sco
#		;;
#	readme.txt|README.TXT)
#		echo readme.txt
#		;;
	*)
		echo UNKNOWN
		;;
	esac
}

get_parameters() {
	case $1 in
	English)
		lang=EN
		;;
	Japanese)
		lang=JP
		;;
	*.tar)
		tardev=$1
		;;
	Linux)
		SYSTEM=LINUX
		;;
	Linux_EL4)
		SYSTEM=LINUX_EL4
		;;
	Linux_EL4_AMD64)
		SYSTEM=LINUX_EL4_AMD64
		;;
	Linux_EL4_IA64)
		SYSTEM=LINUX_EL4_IA64
		;;
	P5Linux_EL4)
		SYSTEM=P5LINUX_EL4
		;;
	P5Linux)
		SYSTEM=P5LINUX
		;;
	HPUX)
		SYSTEM=$1
		;;
	IRIX)
		SYSTEM=$1
		;;
	AIX4)
		SYSTEM=$1
		;;
	AIX5)
		SYSTEM=AIX4
		;;
	Darwin)
		SYSTEM=MACOSX
		;;
	esac
	
}

check_locale_language() {
if [ "$system" = macosx -o "$SYSTEM" = MACOSX ]; then
echo 
else
	set `locale` >/dev/null 2>&1
	case $1 in
	LANG=en_US)
		lang=EN
		;;
	LANG=C)
		lang=EN
		;;
	esac
fi
}

compute_echo () {
	if [ `echo "\c" | wc -l` = 1 ]; then
		echo true
	else
		echo ""
	fi
}

compute_sco_system () {
	set `uname -a`
	case $1 in
	SCO_SV)
		echo sco5
		;;
	*)
		echo sco3
		;;
	esac
}

fixup_linux_system () {
	stty ocrnl onocr onlret echonl inlcr echok echoe erase 0x7f 

	if [ -d /usr/lib/terminfo ]; then
		ln -s /usr/lib/terminfo /usr/share/terminfo >/dev/null 2>&1
	elif [ -d /usr/share/terminfo ]; then
		ln -s /usr/share/terminfo /usr/lib/terminfo >/dev/null 2>&1
	else
		echo "No terminfo files in either /usr/share/ or /usr/lib/"
	fi
}

compute_dgux_system () {
	set `uname -a`
	case $3 in
	R4.20|R4.1*|R4.0*)
		lineStr=`head -$DGUX_SYS_ERROR $INSTALLRES |tail -1`
#		echo "You need to have at least DG/UX release 4.20MU01. Can't continue LanSafe installation."
		echo $lineStr
		exit 1
		;;
	*)
		;;
	esac
}

compute_SYSTEM () {
	set `uname -a`
	case $1 in
	IRIX|IRIX64)
		SYSTEM=IRIX
		;;
	Linux)
		# SYSTEM=LINUX
		# case $3 in
			# 2.6.*EL*)
				# set `uname -m`
				# case $1 in
				# *64*)
					# SYSTEM=LINUX
					# ;;
				# *)
					# SYSTEM=LINUX_EL4
					# ;;
				# esac
				# ;;
			# *) 
				# SYSTEM=LINUX
				# ;;
			# esac
			# ;;
		#64 bit linux installation
		SYSTEM=LINUX
		set `uname -m`
		 case $1 in
		 ppc*)
			set `/lib/libc.so.6*`
			case $7 in
			2.3.0*)
				SYSTEM=P5LINUX_EL4
				;;
			2.3.1*)
				SYSTEM=P5LINUX_EL4
				;;
			2.3.2*)
				SYSTEM=P5LINUX_EL4
				;;
			2.3.3*)
				SYSTEM=P5LINUX_EL4
				;;
			2.3.5*)
				SYSTEM=P5LINUX_EL4
				;;
			2.3.4*)
				SYSTEM=P5LINUX_EL4
				;;
			2.4.*)
				SYSTEM=P5LINUX_EL4
				;;
			2.4*)
				SYSTEM=P5LINUX_EL4
				;;
			2.5*)
				SYSTEM=P5LINUX_EL4
				;;
			esac
			;;                        
		 ia64)
			set `/lib/libc.so.6*`
			case $7 in
			2.3.0*)
				SYSTEM=LINUX_EL4_IA64
				;;
			2.3.1*)
				SYSTEM=LINUX_EL4_IA64
				;;
			2.3.2*)
				SYSTEM=LINUX_EL4_IA64
				;;
			2.3.3*)
				SYSTEM=LINUX_EL4_IA64
				;;
			2.3.4*)
				SYSTEM=LINUX_EL4_IA64
				;;
			2.3.5*)
				SYSTEM=LINUX_EL4_IA64
				;;
			2.4*) 
				SYSTEM=LINUX_EL4_IA64
				;;
			2.5*) 
				SYSTEM=LINUX_EL4_IA64
				;;
			*)
				SYSTEM=LINUX
				;;
			esac
			;;
		x86_64)
			set `/lib/libc.so.6*`
			case $7 in
			2.3.0*)
				SYSTEM=LINUX_EL4_AMD64
				;;
			2.3.1*)
				SYSTEM=LINUX_EL4_AMD64
				;;
			2.3.2*)
				SYSTEM=LINUX_EL4_AMD64
				;;
			2.3.3*)
				SYSTEM=LINUX_EL4_AMD64
				;;
			2.3.4*)
				SYSTEM=LINUX_EL4_AMD64
				;;
			2.3.5*)
				SYSTEM=LINUX_EL4_AMD64
				;;
			2.4*) 
				SYSTEM=LINUX_EL4_AMD64
				;;
			2.5*) 
				SYSTEM=LINUX_EL4_AMD64
				;;
			*)
				SYSTEM=LINUX
				;;
			esac
			;;

		*)
			set `/lib/libc.so.6*`
			case $7 in
			2.3.0*)
				SYSTEM=LINUX
				;;
			2.3.1*)
				SYSTEM=LINUX
				;;
			2.3.2*)
				SYSTEM=LINUX
				;;
			2.3.3*)
				SYSTEM=LINUX
				;;
			2.3.4*)
				SYSTEM=LINUX_EL4
				;;
			2.3.5*)
				SYSTEM=LINUX_EL4
				;;
			2.4.*)
				SYSTEM=LINUX_EL4
				;;
			2.4*)
				SYSTEM=LINUX_EL4
				;;
			2.5*)
				SYSTEM=LINUX_EL4
				;;
			esac
			;;
		esac
		;;
		
		
	SunOS)
		case $3 in
		5.*)
			case $5 in
			i86pc)
				SYSTEM=SOLINT
				;;
			*)
				SYSTEM=SOLARI
				;;
			esac
		;;
		*)
			SYSTEM=SUNOS
			;;
		esac
		;;
	HP-UX)
		SYSTEM=HPUX
		;;
	OSF1)
		SYSTEM=DEC
		;;
	dgux)
		SYSTEM=DGUX
		;;
	SCO_SV)
		SYSTEM=SCO
		;;
	UnixWare)
		SYSTEM=UW2
		;;
	Darwin)
		SYSTEM=MACOSX
		;;
	UNIX_SV)
		if [ -f /etc/issue ]; then
			grep "UnixWare" /etc/issue >/dev/null 2>/dev/null
			if [ $? != 1 ]; then
				SYSTEM=UW2
			else
				SYSTEM=SVR4
			fi
		else
			SYSTEM=SVR4
		fi
		;;
	AIX)
		case $4 in
		3)
			SYSTEM=AIX3
			;;
		4)
			SYSTEM=AIX4
			;;
		5)
			SYSTEM=AIX4
			;;
		esac
		;;
	*)
		if [ -c /dev/tty1A ]; then
			SYSTEM=SCO
		elif [ -c /dev/ttyd0 -a "$1" != "Linux" ]; then
			SYSTEM=IA
		elif [ -c /dev/ttypa -a "$1" != "Linux" ]; then
			SYSTEM=IA
		else
			SYSTEM="Unknown System"
		fi
		;;
	esac
}

compute_system () {
	case $SYSTEM in
	IRIX|IRIX64)
		system=irix
		;;
	LINUX)
		system=linux
		;;
	LINUX_EL4)
		system=linux_el4
		;;
	LINUX_EL4_AMD64)
		system=linux_el4_amd64
		;;
	LINUX_EL4_IA64)
		system=linux_el4_ia64
		;;
	P5LINUX_EL4)
		system=P5linux_el4
		;;
	P5LINUX)
		system=P5linux
		;;
	SOLINT)
		system=solint
		;;
	SOLARI)
		system=solari
		;;
#	SUNOS)
#		system=sunos
#		;;
	HPUX)
		system=hpux
		;;
	MACOSX)
		system=macosx
		;;
#	DEC)
#		system=dec
#		;;
#	DGUX)
#		system=dgux
#		;;
	SCO)
		system=sco
		;;
#	UW2)
#		system=uw2
#		;;
#	SVR4)
#		system=svr4
#		;;
	AIX3)
		system=aix3
		;;
# From LanSafe v5.0.0.0, $system is set to aix for both AIX4 and AIX5.
	AIX4)
		system=aix
		;;
	AIX5)
		system=aix
		;;
#	IA)
#		system=ia
#		;;
#	"Unknown System")
#		system="Unknown System"
#		;;
	*)
		echo
#		echo Unknown System \"$SYSTEM\". LanSafe installation can not continue.
#		echo Please specify your system like, "\"./install.sh <SYSTEM>\""
		lineStr=`head -$ERR_UNKNOWN_SYS_STR1 $INSTALLRES |tail -1`
		lineStr1=`head -$ERR_UNKNOWN_SYS_STR4 $INSTALLRES |tail -1`
		echo "$lineStr \"$SYSTEM\". $lineStr1"
		lineStr=`head -$ERR_UNKNOWN_SYS_STR2 $INSTALLRES |tail -1`
		echo $lineStr		
#		echo Valid systems are LINUX SOLINT SOLARI SUNOS HPUX DEC DGUX SCO UW2 SVR4 AIX3 AIX4 AIX5 IA
#		echo Valid systems are LINUX
		lineStr=`head -$ERR_UNKNOWN_SYS_STR3 $INSTALLRES |tail -1`
		echo $lineStr
		echo
		exit
		;;
	esac
}

compute_disks () {
	case $system in
	irix|irix64)
		echo 1 2
		;;
	linux|linux_el4|P5linux|P5linux_el4|linux_el4_amd64|linux_el4_ia64)
	#	echo 1 2 3 4 5	
		echo 1 2
		;;
	sco|dgux)
	#	echo 1 2 3 4
		echo 1 2
		;;
	ia)
	#	echo 1 2 3
		echo 1 2
		;;
	sunos)
	#	echo 1 2 3 4
		echo 1 2
		;;
	hpux)
	#	echo 1 2 3
		echo 1 2
		;;
	solari)
	#	echo 1 2 3 4
		echo 1 2
		;;
	solint)
	#	echo 1 2 3
		echo 1 2
		;;
	dec)
	#	echo 1 2 3 4
		echo 1 2
		;;
	uw2)
		echo 1 2
		;;
	macosx)
		echo 1 2
		;;
	aix3)
		echo 1 2
		;;
#	aix4)
#		echo 1 2
#		;;
# From LanSafe v 5.0.0.0, $system for aix4 and aix5 will be set to aix    RF 05/07/03
	aix)
		echo 1 2
		;;
	svr4)
	#	echo 1 2 3
		echo 1 2
		;;
	esac
}

compute_tapedirs () {
	for disk in `compute_disks`; do
		case $disk in
		1)
			if [ -n "$cdrom_install" ]; then
				if [ -n "$uppercase_mount" ]; then
					echo_n 1_INSTALL " "
				else
					echo_n 1_install " "
				fi
			else
				echo_n 1_install " "
			fi
			;;
		*)
			if [ -n "$uppercase_mount" ]; then
				echo_n ${disk}_${SYSTEM}_$lang " "
			else
				echo_n ${disk}_${system}_$lang " "
			fi
			;;
		esac
	done
	echo
}

compute_topath () {
	case $1 in
	*.afm|typeface.map)
		echo /usr/lib/Xp/FontMetrics/AFM
		;;
	*.fonts)
		echo /usr/lib/Xp
		;;
	hoh.hlp)
		echo /usr/lib/hyperhelp
		;;
	HyperHelp)
		echo /usr/lib/X11/app-defaults
		;;
	picture.px| s1.objscr)
		echo /usr/lib/X11/XDesktop3/applications/Ls3.obj
		;;
	Ls3.node)
		echo /etc/conf/node.d
		;;
	XKeysymDB)
		echo /usr/lib/X11
		;;
	*.bmp)
		echo $instpath/bitmaps
		;;
	*.cfg)
		echo $instpath/Config
		;;
	*.mfg)
		echo $instpath/Config
		;;
	*.ups)
		echo $instpath/Config
		;;
	*.def)
		echo $instpath/Config
		;;
	*.hlp)
		echo $instpath/Help
		;;
	*.rtf)
		echo $instpath/Help
		;;
	license.txt)
		echo $instpath
		;;
	*)
		echo $instpath/Bin
		;;
	esac
}

compute_toperm () {
	case $1 in
	install.ls |\
	chk4patch.sh |\
	PowerMonitorX |\
	PowerMonitorIcon |\
	ls3conX |\
	PowerMonitorHelp |\
	ls3con)
		echo 0755
		;;
	Ls3s |\
	PowerMonitorM |\
	PowerMonitorC |\
	ls.init | \
	PowerMonitor.email | \
	PowerMonitor.broadcast | \
	PowerMonitor.shutdown | \
	PowerMonitor.unload | \
	PowerMonitor.sh | \
	uninstall.sh)
		echo 0744
		;;
	PowerMonitorEvents.cfg | \
	PowerMonitorEvents.def)
		echo 0600
		;;
	*)
		echo 0444
		;;
	esac
}

compute_uncompress () {
	for subdir in `compute_tapedirs`; do
		if [ -f $subdir/gunzip ]; then
			echo $subdir/gunzip
			return
		fi
	done
	if [ -f gunzip ]; then
		echo gunzip
	fi
	echo uncompress
}

echo_n () {
	if [ $bsdecho ]; then
		echo -n "$*"
	else
		echo "$*\c"
	fi
}

create_path() {
	fullpath=""
	for path in `echo $1 | sed 's/\// /g'`; do
		fullpath=$fullpath/$path
		if [ ! -d $fullpath ]; then
			mkdir $fullpath
			if [ $? != 0 ]; then
				return 1
			fi
			chmod 755 $fullpath



			 #change chown to Daemon for MaxOsx (KB 11/18/03)
			if [ "$system" = sunos -o "$SYSTEM" = SUNOS ]; then
					/usr/etc/chown bin $fullpath
					chgrp bin $fullpath
			elif [ "$system" = macosx -o "$SYSTEM" = MACOSX ]; then
					chown daemon $fullpath
					chgrp daemon $fullpath
			else
					chown bin $fullpath
					chgrp bin $fullpath
			fi

			#chgrp bin $fullpath
			if [ $? != 0 ]; then
				return 1
			fi
		fi
	done
	if [ -d $1 ]; then
		return 0
	fi
	return 1
}

check_fatal () {
	if [ $? != 0 ]; then
		if [ $override ]; then
#			echo "Install failed. Override set."
			lineStr=`head -$ERR_CHECK_FATAL_OVERRIDE $INSTALLRES |tail -1`
			echo $lineStr
			return 0
		fi
#		echo "Install failed. Exiting"
		lineStr=`head -$ERR_CHECK_FATAL_EXIT $INSTALLRES |tail -1`
		echo $lineStr
		exit 1
	fi
}

check_status () {
	if [ $? != 0 ]; then
		if [ $override ]; then
#			echo "Check status failed. Override set."
			lineStr=`head -$ERR_CHECK_STATUS $INSTALLRES |tail -1`
			echo $lineStr
			return 0
		fi
		return 1
	fi
	return 0
}

untar_to () {
	name=$1
	dst=$2
	perm=$3
	prefix=.
	for subdir in `compute_tapedirs`; do
		if [ -f $subdir/$name ]; then
			prefix=$subdir
		fi

		if [ -f $subdir/$name.z ]; then
			prefix=$subdir
		fi

		if [ -f $subdir/$name.Z ]; then
			prefix=$subdir
		fi
	done
	src=$prefix/$name

	create_path $dst
	check_fatal

	if [ ! -f $src ]; then
		if [ -f $src.z ]; then
			$uncompress_cmd $src.z
			check_fatal
		fi
		if [ -f $src.Z ]; then
			$uncompress_cmd $src.Z
			check_fatal
		fi
	fi

	if [ -f $dst/$name ]; then
		mv -f $dst/$name $dst/$name~ > /dev/null 2>&1
	fi

	mv -f $src $dst >/dev/null 2>&1
	if [ $? != 0 ]; then
		cp $src $dst
	check_fatal
	rm -f $src
	fi

	lineStr=`head -$INSTALL_FROM $INSTALLRES |tail -1`
	lineStr1=`head -$INSTALL_TO $INSTALLRES |tail -1`
	lineStr2=`head -$INSTALLED_DONE $INSTALLRES |tail -1`

	chmod $perm $dst/$name
#	(cd $dst; tar -xvf $name |
#	awk '{ print "Installing " $2 " to '$dst' ... done" }' |
#	sed 's/, / /' ) 2>/dev/null
	(cd $dst; tar -xvf $name |
	awk '{ print "$lineStr " $2 " $lineStr1 '$dst' ... $lineStr2" }' |
	sed 's/, / /' ) 2>/dev/null
	check_fatal
	for f in `(cd $dst; tar -tf $name 2>/dev/null)`; do
#		echo "Installed: $dst/$f" >> $instpath/installed
		lineStr=`head -$INSTALLED_STR $INSTALLRES |tail -1`
		echo "$lineStr $dst/$f" >> $instpath/installed
		chmod $perm $dst/$f
		check_fatal

		#changes for mac
		if [ "$system" = sunos -o "$SYSTEM" = SUNOS ]; then
				/usr/etc/chown bin $dst/$f
				chgrp bin $dst/$f
		elif [ "$system" = macosx -o "$SYSTEM" = MACOSX ]; then
				chown daemon  $dst/$f
				chgrp daemon $dst/$f
		else
				chown bin $dst/$f
				chgrp bin $dst/$f
		fi 

		#chown bin $dst/$f
		#chgrp bin $dst/$f

	done
	rm -f $dst/$name
}

install_to () {
	name=$1
	dst=$2
	perm=$3
	prefix=.
	lc_name=$name
	
	#if [ -n "$cdrom_install" ]; then
	#	name=`Convert_Case $name`
	#fi

#	echo_n "Installing $lc_name to $dst ... "
	lineStr=`head -$INSTALL_FROM $INSTALLRES |tail -1`
	lineStr1=`head -$INSTALL_TO $INSTALLRES |tail -1`

	echo_n "$lineStr $lc_name $lineStr1 $dst ..."
	for subdir in `compute_tapedirs`; do
		if [ -f $subdir/$name ]; then
			prefix=$subdir
		fi

		if [ -f $subdir/$name.z ]; then
			prefix=$subdir
		fi

		if [ -f $subdir/$name.Z ]; then
			prefix=$subdir
		fi
	done
	src=$prefix/$name

	create_path $dst
	check_fatal

	if [ ! -f $src ]; then
		if [ -f $src.z ]; then
			$uncompress_cmd $src.z
			check_fatal
		fi
		if [ -f $src.Z ]; then
			if [ -n "$cdrom_install" ]; then
				cp $src.Z /tmp/$name.Z
				$uncompress_cmd /tmp/$name.Z
				src=/tmp/$name
			else
				$uncompress_cmd $src.Z
			fi
			check_fatal
		fi
	fi

	rm -f $dst/$lc_name
	if [ -f $dst/$lc_name ]; then
		mv -f $dst/$lc_name $dst/$lc_name~ > /dev/null 2>&1
	fi


	if [ -n "$cdrom_install" ]; then
#		echo 
#		echo $src
#		echo $dst/$lc_name
		cp $src $dst/$lc_name
		check_fatal
	else
		mv -f $src $dst/$lc_name >/dev/null 2>&1

		if [ $? != "0" ]; then
			cp $src $dst/$lc_name
			check_fatal
			rm -f $src
		fi
	fi

	chmod $perm $dst/$lc_name
	check_fatal
		#Change chown because there is no bin on MacOSx (KB 11/18/03)
		if [ "$system" = sunos -o "$SYSTEM" = SUNOS ]; then
				/usr/etc/chown bin $dst/$lc_name
				chgrp bin $dst/$lc_name
		elif [ "$system" = macosx -o "$SYSTEM" = MACOSX ]; then
				chown daemon $dst/$lc_name
				chgrp daemon $dst/$lc_name
		else
				chown bin $dst/$lc_name
				chgrp bin $dst/$lc_name
		fi


#	chgrp bin $dst/$lc_name
#	echo "Installed: $dst/$lc_name" >> $instpath/installed
	lineStr=`head -$INSTALLED_STR $INSTALLRES |tail -1`
	echo "$lineStr $dst/$lc_name" >> $instpath/installed

	lineStr=`head -$INSTALLED_DONE $INSTALLRES |tail -1`
	echo $lineStr
#	echo "done"

}

read_one () {
	prompt=$1
	default=$2

	echo_n "$prompt"
	stty -icanon min 1
	answer=`/bin/dd count=1 2>/dev/null`
	stty icanon
	echo
}

read_def () {
	prompt=$1
	default=$2

	echo_n "$prompt"
	read answer
	if [ -z "$answer" ]; then
		answer=$default
	fi
}

install_files () {
	echo
	rm -f $instpath/installed
	uncompress_cmd=`compute_uncompress`
	for f in `compute_files`; do
		if [ ! -z "$skip_install" ]; then
			break
		fi

		topath=`compute_topath $f`
		toperm=`compute_toperm $f`
		case $f in
		*.tar)
			untar_to $f $topath $toperm
			tar -xvf $tardev $systemdir/license.txt >/dev/null 2>&1
			;;
		ls3.load)
			install_to $f $topath $toperm
			mv -f $topath/$f $topath/$$
			sed '
/\/usr\/Powerware\/LanSafe\/Bin/c\
instpath='$topath'
' $topath/$$ > $topath/$f
			rm -f $topath/$$
			chmod $toperm $topath/$f
			check_fatal
			;;
		*)
			install_to $f $topath $toperm
			;;
		esac
	done
#	cp $instpath/Config/install.mfg $instpath/Config/PowerMonitorX.mfg
#	cp $instpath/Config/install.mfg $instpath/Config/ls3conX.mfg
#	cp $instpath/Config/install.mfg $instpath/Config/ls3con.mfg
	cp $instpath/Config/PowerMonitorEvents.def $instpath/Config/PowerMonitorEvents.cfg
}

# Set up check condition for tar file install.
get_tardev() {
	tar_install=true
}

# No longer in use.  Tar file name is provided as input argument.
ls3_get_tardev () {
	tardev=""
	while [ -z "$tardev" ]; do
	echo
#	echo "Please enter the name of the device (or tarfile) to install from."
	lineStr=`head -$GET_DEVICE_NAME $INSTALLRES |tail -1`
	echo $lineStr

#	read_def " File name: "
	lineStr=`head -$INSTALL_DEVICE $INSTALLRES |tail -1`
	read_def " $lineStr "

	if [ -z "$answer" ]; then
		continue
	fi

	if [ '(' -c "$answer" ')' -o '(' -b "$answer" ')' ]; then
		tardev=$answer
	elif [ -d $answer ]; then
#		echo "'$answer' is a invalid because it is a directory?"
		lineStr=`head -$ERR_INVALID_DIR $INSTALLRES |tail -1`
		echo "'$answer' $lineStr"
#		elif [ -f $answer ]; then
##			echo "Expecting a device name, but '$answer' is a file?"
#			lineStr=`head -$ERR_INVALID_DEVICE_STR1 $INSTALLRES |tail -1`
#			lineStr1=`head -$ERR_INVALID_DEVICE_STR2 $INSTALLRES |tail -1`
#			echo "$lineStr '$answer' $lineStr1"
#			tardev=$answer
##			read_def " Is this okay? (y/n) [n] " "n"
#			lineStr=`head -$OK_STR $INSTALLRES |tail -1`
#			read_def " $lineStr (y/n) [n] " "n"
#			case $answer in
#			[yY]|[yY][eE][sS])
#				tar_install=true
#				;;
#			*)
#				tardev=""
#				;;
#			esac
#		else
		elif [ ! -f $answer ]; then
#			echo "'$answer' does not exist or is not a device?"
			lineStr=`head -$ERR_NO_DEVICE $INSTALLRES |tail -1`
			echo "'$answer' $lineStr"
			if [ $override ]; then
#   Do not translate the following lines.  
#   It is only for developer and it is not using now. RF 6/19/03
		echo "Override set, using '$answer'."
					tardev=$answer
			else
				continue
			fi
	fi
	done
}

maybe_eject () {
	case $system in
	sunos| solari | solint)
		echo "Ejecting disk ..."
		eject $tardev > /dev/null 2>&1
		;;
	esac
}

extract_files () {
	firsttime=true
	while [ -z "$tardev" -o ! -z "$firsttime" ]; do
	# Prompt for different device name only if extract below fails i.e firsttime=""
	if [ -z "$firsttime" ]; then
		get_tardev
	fi

	firsttime=""
	case $tardev in
	*f0*|*f1*|*fd*|*floppy*|*dsk*)
		media=disk
		# For each disk
		for disk in `compute_disks`; do
			if [ $disk != "1" ]; then
				maybe_eject
				if [ "$system" = "ia" ]; then
					LongName="Interactive"
				else
					LongName="$system"
				fi
				echo
#   Do not translate the following lines.  
#   We no longer using floppy disks.  RF 6/19/03
				echo_n ">>>Insert $LongName disk #"$disk "... press Enter when ready. "
				read x
			fi

			echo ">>>Extracting files ..."
			if [ $disk != 1 ]; then
				tar -xf $tardev ${disk}_${system}_$lang > /dev/null 2>&1
			else
				tar -xf $tardev 1_install > /dev/null 2>&1
			fi

			check_status
			if [ $? != 0 ]; then
				echo ">>>Error extracting files?"
				tardev=
				continue 2
			fi
		done
		maybe_eject
		;;
	*st*|*mt*|*)
		media=tape
		echo
#		echo "Extracting files ..."
		lineStr=`head -$EXTRACTING_FILE $INSTALLRES |tail -1`
		echo $lineStr
		tar -xf $tardev `compute_tapedirs` > /dev/null 2>&1
		check_status
		if [ $? != 0 ]; then
#			echo "Error extracting files?"
			lineStr=`head -$ERR_EXTRACTING_FILE $INSTALLRES |tail -1`
			echo $lineStr
			tardev=
			continue
		fi
		;;
	esac
	done
	# end-of extract_files
}

install_upsdrv() {
#	echo "A special Device Driver is needed to allow the LanSafe"
#	echo "daemon to communicate with your model"
#	echo "This device driver will be installed next."
	lineStr=`head -$UPS_DRIVER_STR1 $INSTALLRES |tail -1`
	echo $lineStr
	lineStr=`head -$UPS_DRIVER_STR2 $INSTALLRES |tail -1`
	echo $lineStr
	lineStr=`head -$UPS_DRIVER_STR3 $INSTALLRES |tail -1`
	echo $lineStr
	echo ""

	if [ ! -d /tmp/ups_drv ]; then
		mkdir /tmp/ups_drv
	fi

	if [ -n "$cdrom_install" ]; then
		if [ -n "$uppercase_mount" ]; then
			cp $SYSTEMDIR/UPS_DRV/DRIVER.O	/tmp/ups_drv/Driver.o
			cp $SYSTEMDIR/UPS_DRV/FILES		/tmp/ups_drv/Files
			cp $SYSTEMDIR/UPS_DRV/INSTALL	/tmp/ups_drv/Install
			cp $SYSTEMDIR/UPS_DRV/MASTER		/tmp/ups_drv/Master
			cp $SYSTEMDIR/UPS_DRV/NAME		/tmp/ups_drv/Name
			cp $SYSTEMDIR/UPS_DRV/NODE		/tmp/ups_drv/Node
			cp $SYSTEMDIR/UPS_DRV/REMOVE		/tmp/ups_drv/Remove
			cp $SYSTEMDIR/UPS_DRV/SIZE		/tmp/ups_drv/Size
			cp $SYSTEMDIR/UPS_DRV/SPACE.C	/tmp/ups_drv/Space.c
			cp $SYSTEMDIR/UPS_DRV/SYSTEM		/tmp/ups_drv/System
			cp $SYSTEMDIR/UPS_DRV/MKDISK		/tmp/ups_drv/mkdisk
			cp $SYSTEMDIR/UPS_DRV/UPS.H		/tmp/ups_drv/ups.h
			if [ $SYSTEM = "SCO" ]; then
				cp $SYSTEMDIR/UPS_DRV/UPS.H	/tmp/ups_drv/upstmp
			fi
		else
			cp $systemdir/ups_drv/driver.o	/tmp/ups_drv/Driver.o
			cp $systemdir/ups_drv/files		/tmp/ups_drv/Files
			cp $systemdir/ups_drv/install	/tmp/ups_drv/Install
			cp $systemdir/ups_drv/master		/tmp/ups_drv/Master
			cp $systemdir/ups_drv/name		/tmp/ups_drv/Name
			cp $systemdir/ups_drv/node		/tmp/ups_drv/Node
			cp $systemdir/ups_drv/remove		/tmp/ups_drv/Remove
			cp $systemdir/ups_drv/size		/tmp/ups_drv/Size
			cp $systemdir/ups_drv/space.c	/tmp/ups_drv/Space.c
			cp $systemdir/ups_drv/system		/tmp/ups_drv/System
			cp $systemdir/ups_drv/mkdist		/tmp/ups_drv/mkdisk
			cp $systemdir/ups_drv/ups.h		/tmp/ups_drv/ups.h
			if [ $SYSTEM = "SCO" ]; then
				cp $systemdir/ups_drv/ups.h	/tmp/ups_drv/upstmp
			fi
		fi
	else
		mv $systemdir/ups_drv/* /tmp/ups_drv
	fi

	if [ $system = "uw1" -o $system = "uw2" ]; then
#		echo "LanSafe: Warning"
#		echo "The asyc device driver controlling the serial port must be disabled."
#		echo "Please edit the /etc/conf/cf.d/sdevice and /etc/conf/sdevice.d/asyc files to"
#		echo "disable the asyc driver on the UPS port. In both files locate the line"
#		echo "specifying that the asyc driver should manage that serial port and"
#		echo "change the Y to an N to disable the asyc driver. To disable the ups device driver"
#		echo "from a port edit the /etc/conf/cf.d/sdevice and /etc/conf/sdevice.d/ups files."
#		echo "You must make these changes before installing the ups device driver."
		lineStr=`head -$UW2_UPS_DRIVER_STR1 $INSTALLRES |tail -1`
		echo $lineStr
		lineStr=`head -$UW2_UPS_DRIVER_STR2 $INSTALLRES |tail -1`
		echo $lineStr
		lineStr=`head -$UW2_UPS_DRIVER_STR3 $INSTALLRES |tail -1`
		echo $lineStr
		lineStr=`head -$UW2_UPS_DRIVER_STR4 $INSTALLRES |tail -1`
		echo $lineStr
		lineStr=`head -$UW2_UPS_DRIVER_STR5 $INSTALLRES |tail -1`
		echo $lineStr
		lineStr=`head -$UW2_UPS_DRIVER_STR6 $INSTALLRES |tail -1`
		echo $lineStr
		lineStr=`head -$UW2_UPS_DRIVER_STR7 $INSTALLRES |tail -1`
		echo $lineStr
		lineStr=`head -$UW2_UPS_DRIVER_STR8 $INSTALLRES |tail -1`
		echo $lineStr
	fi

	if [ $system = "ia" ]; then
#		echo "LanSafe: Warning"
#		echo "The asy device driver controlling the serial port must be disabled."
#		echo "Edit the /etc/conf/cf.d/sdevice and /etc/conf/sdevice.d/asy files to"
#		echo "disable the asy driver on the UPS port. In both files locate the line"
#		echo "specifying that the asyc driver should manage that serial port and"
#		echo "change the Y to an N to disable the asy driver. To disable the ups device driver"
#		echo "from a port edit the /etc/conf/cf.d/sdevice and /etc/conf/sdevice.d/ups files."
#		echo "You must make these changes before installing the ups device driver."
		lineStr=`head -$IA_UPS_DRIVER_STR1 $INSTALLRES |tail -1`
		echo $lineStr
		lineStr=`head -$IA_UPS_DRIVER_STR2 $INSTALLRES |tail -1`
		echo $lineStr
		lineStr=`head -$IA_UPS_DRIVER_STR3 $INSTALLRES |tail -1`
		echo $lineStr
		lineStr=`head -$IA_UPS_DRIVER_STR4 $INSTALLRES |tail -1`
		echo $lineStr
		lineStr=`head -$IA_UPS_DRIVER_STR5 $INSTALLRES |tail -1`
		echo $lineStr
		lineStr=`head -$IA_UPS_DRIVER_STR6 $INSTALLRES |tail -1`
		echo $lineStr
		lineStr=`head -$IA_UPS_DRIVER_STR7 $INSTALLRES |tail -1`
		echo $lineStr
		lineStr=`head -$IA_UPS_DRIVER_STR8 $INSTALLRES |tail -1`
		echo $lineStr
	fi

	echo ""
#	echo "During the driver installation your kernel will be rebuilt to"
#	echo "include this device driver. When the installation is completed"
#	echo "you must reboot your computer to install this new kernel."
	lineStr=`head -$GENERAL_UPS_DRIVER_STR1 $INSTALLRES |tail -1`
	echo $lineStr
	lineStr=`head -$GENERAL_UPS_DRIVER_STR2 $INSTALLRES |tail -1`
	echo $lineStr
	lineStr=`head -$GENERAL_UPS_DRIVER_STR3 $INSTALLRES |tail -1`
	echo $lineStr
	echo ""

#	read_def " Install the device driver? (y/n) [y] " "y"
	lineStr=`head -$ASK_INSTALL_DEVICE_DRV $INSTALLRES |tail -1`
	read_def " $lineStr (y/n) [y] " "y"
	case $answer in
		[yY]|[yY][eE][sS])
			orig_dir=$PWD
			cd /tmp/ups_drv
			./Install
			cd $orig_dir
			;;
		*)
#			echo "The UPS Driver MUST be built into the kernel for LanSafe to work"
#			echo "The files for the driver has been copied to /tmp/ups_drv"
#			echo "To install the driver into the kernel login in as root and type:"
			lineStr=`head -$NO_INSTALL_DRV_STR1 $INSTALLRES |tail -1`
			echo $lineStr
			lineStr=`head -$NO_INSTALL_DRV_STR2 $INSTALLRES |tail -1`
			echo $lineStr
			lineStr=`head -$NO_INSTALL_DRV_STR3 $INSTALLRES |tail -1`
			echo $lineStr
			echo "cd /tmp/ups_drv"
			echo "./Install"
			;;
	esac
}

kill_ls3() {
	pidargs=-ax			# BSD sunos
	ps -ax > /dev/null 2>&1
	if [ $? != "0" ]; then
		pidargs=-e		# svr3 svr4
	fi
	
	if [ "$system" = linux_el4 -o  "$system" = P5linux -o  "$system" = P5linux_el4 -o "$system" = linux -o "$system" = linux_el4_amd64 -o "$system" = linux_el4_ia64 ]; then
		pidargs=ax
	fi
	
	pids=`ps $pidargs | awk '/PowerMonitor/ { print $1 }'`
	kill -9 $pids > /dev/null 2>&1
}

# Not used RF 6/19/03
# Do not need to translate
install_ptf122() {
	echo "A Patch is needed on UnixWare 1.1 to allow the LanSafe"
	echo "daemon to communicate with the Dry Contact UPS."
	echo "This patch will be installed next."
	echo ""
	echo ""
	echo "During the patch installation your kernel will be rebuilt to"
	echo "include this patch. When the installation is completed"
	echo "you must reboot your computer to install a new kernel."
	echo ""
	mv 3_unixware/ptf122.tar /tmp/ptf122.tar
	cd /tmp
	tar xvf ptf122.tar
	read_def " Install the patch? (y/n) [y] " "y"
	case $answer in
	[yY]|[yY][eE][sS])
		pkgadd -d /tmp/ptf122 ptf122
		;;
	*)
		echo "The ptf122 patch MUST be built into the kernel for LanSafe to work"
		echo "The files for the driver has been copied to /tmp"
		echo "To install the driver into the kernel, login as root and type:"
		echo "pkgadd -d /tmp/ptf122 ptf122"
		;;
	esac
}

# Not used RF 6/19/03
# Do not need to translate
streamsmsg() {
	echo
	echo "STREAMS must be installed in the kernel."
	case $system in
	sco)
		echo "Run 'mkdev streams' to install STREAMS into the kernel."
		;;
	ia)
		echo "Run 'kconfig' and add the STREAMS feature to the kernel."
		;;
	*)
		echo "Configure STREAMS into the kernel."
		;;
	esac
	echo
}

# Not used RF 6/19/03
# Do not need to translate
chk4sp() {
	CONF=/etc/conf
	CONFBIN=$CONF/bin
	NODEFILE=$CONF/node.d/Ls3.node

	case $system in
	sco)
		if [ -c /dev/socksys -a -f /etc/services ]; then
			return 0;	# looks like they have tcp skip sp check
		fi
		;;
	ia| uw1| uw2)
		if [ -c /dev/tcp -a -c /dev/udp -a -f /etc/services ]; then
			return 0;	# looks like they have tcp skip sp check
		fi
		;;
	*)
		return 0;	# non error
		;;
	esac

	# must have clone
	$CONFBIN/idcheck -p clone || $CONFBIN/idcheck -y clone
	if [ $? = 0 ]; then
		echo "Module clone is missing from the kernel."
		streamsmsg
		return 1	# error
	fi

	# must have sp
	$CONFBIN/idcheck -p sp || $CONFBIN/idcheck -y sp
	if [ $? = 0 ]; then
		echo "Module sp is missing from the kernel."
		streamsmsg
		return 1	# error
	fi

	if [ $system = "sco" ]; then
		# must have str
		$CONFBIN/idcheck -p str || $CONFBIN/idcheck -y str
		if [ $? = 0 ]; then
			echo "Module str is missing from the kernel."
			streamsmsg
			return 1	# error
		fi
	fi

	if [ ! -c /dev/spx ]; then
		echo "All neccessary STREAMS modules are configured in the kernel."
		echo "But, the node /dev/spx is missing from device directory."
		if [ -f $NODEFILE ]; then
			echo
			echo "Now that $NODEFILE has been installed,"
			echo "rebuild kernel with $CONFBIN/idbuild, reboot and reinstall."
			echo
		else
			echo
		fi
		return 1;
	fi
	return 0;
}


setup_services () {
	# Need to do more for yp servers.
	services=/etc/services

	# Check for existence of services
	if [ ! -f $services ]; then
		echo
#		echo "The file $services does not exist."
#		echo "Skipping modifications to $services."
		lineStr=`head -$ERR_SERVICES_FILE_STR1 $INSTALLRES |tail -1`
		lineStr1=`head -$ERR_SERVICES_FILE_STR2 $INSTALLRES |tail -1`
		echo "$lineStr $services $lineStr1"
		lineStr=`head -$ERR_SERVICES_FILE_STR3 $INSTALLRES |tail -1`
		echo "$lineStr $services."
		echo
		return;
	fi

	# Remove any port for LanSafe service that set in the past
	file=$services
	mv -f $file ${file}.ls
	sed -e '
/PowerMonitor/d
' ${file}.ls > $file
	rm -f ${file}.ls

	# Find an appropriate port for the LanSafe service
	port=`sed -e 's/#.*//' $services | awk '
	NF>0 {
	l = length($2);
	if ($2 ~ /\/tcp$/)
		tcp[substr($2, 1, l - 4)] = $1;
	if ($2 ~ /\/udp$/)
		udp[substr($2, 1, l - 4)] = $1;
	}
	END {
	for (i = 3069; i < 9999; i++) {
		if ((tcp[i] == ""     && udp[i] == "")    || \
			(tcp[i] == ""     && udp[i] == "ls") || \
			(tcp[i] == "PowerMonitor" && udp[i] == "")     || \
			(tcp[i] == "PowerMonitor" && udp[i] == "ls") || \
			(tcp[i] == ""     && udp[i] == "lsii") || \
			(tcp[i] == "lsii" && udp[i] == "")     || \
			(tcp[i] == "lsii" && udp[i] == "lsii")) {
			print i;
			break;
			}
		}
	}
	'`
	check_fatal

#	echo "Adding PowerMonitor services in $services."
	lineStr=`head -$ADDING_LS_SERVICE $INSTALLRES |tail -1`
	echo "$lineStr $services."
	# Backup old services file.
	mv -f $services ${services}.ls
	check_fatal
	# Add new lines using computed port number
	sed -e '
$a\
#Port 3068 is used by PowerMonitor, PowerMonitorAgent to broadcast information.
$a\
PowerMonitor		'$port'/tcp			# LanSafe for Unix
$a\
PowerMonitor		'$port'/udp			# LanSafe for Unix
/lsii.*udp/d
/lsii.*tcp/d
' ${services}.ls > $services	#Removing the older version occurences ls3.udp
	cat $services |grep -v -w "ls3.udp" > ${services}.tmp
	#Renaming the file to /etc/services
	mv -f ${services}.tmp $services	
	#Removing the older version occurences ls3.tcp
	cat $services |grep -v -w "ls3.tcp" > ${services}.tmp
	#Renaming the file to /etc/services
	mv -f ${services}.tmp $services
		check_fatal
	chmod 444 $services
	check_fatal

#	echo "Modified: $services" >> $instpath/installed
	lineStr=`head -$MODIFIED_SERVICES $INSTALLRES |tail -1`
	echo "$lineStr $services" >> $instpath/installed
#	echo "The following lines were removed from $services:"
#	lineStr=`head -$REMOVE_SERVICE_STR $INSTALLRES |tail -1`
#	echo "$lineStr $services:"
#	diff ${services}.ls $services | grep '^<' | sed -e 's/< //'
#	echo "The following lines were added to $services:"
#	lineStr=`head -$ADD_SERVICE_STR $INSTALLRES |tail -1`
#	echo "$lineStr $services:"
#	diff ${services}.ls $services | grep '^>' | sed -e 's/> //'
}

updateInstallPath()
{
# modify PowerMonitor.sh

	InstallFile=$instpath/Bin/ls.tmp
	FinalFile=$instpath/Bin/PowerMonitor.sh
	mv $FinalFile $InstallFile

	sed '/\usr\/Powerware\/LanSafe\/Bin/c\
instpath='$instpath"/Bin"'
' $InstallFile > $FinalFile

	chmod 744 $instpath/Bin/PowerMonitor.sh

# modify uninstall.sh

	InstallFile=$instpath/Bin/uninstall.tmp
	FinalFile=$instpath/Bin/uninstall.sh
	mv $FinalFile $InstallFile

	sed '/\usr\/Powerware\/LanSafe/c\
instpath='$instpath'
' $InstallFile > $FinalFile

	chmod 744 $instpath/Bin/uninstall.sh

}

darwin_startatboot ()
{

pmStartDirName=/System/Library/StartupItems/PowerMonitor
#create Directory
#change later

		mkdir $pmStartDirName

#cpy start script

		cp "2_$system"_$lang/PowerMonitor.startfile $pmStartDirName/PowerMonitor
#cpy StartParams file to destination
		cp "2_$system"_$lang/StartupParameters.plist $pmStartDirName/StartupParameters.plist

		InstallFile=$pmStartDirName/PowerMonitor.tmp
		FinalFile=$pmStartDirName/PowerMonitor
		mv $FinalFile $InstallFile

		sed '/\usr\/Powerware\/LanSafe/c\
instpath='$instpath'
' $InstallFile > $FinalFile
#remove the temp file
rm $pmStartDirName/PowerMonitor.tmp
#set the perms on the startfile
chmod 751 $pmStartDirName/PowerMonitor
#make changes to the host config file
echo "POWERMONITOR=-YES-" >> /etc/hostconfig

}

bsd_startatboot () {
	rcfile=/etc/rc.d/rc.local

	mv -f $rcfile ${rcfile}.ls
	check_fatal

#	Use sed to remove old occurance, both lsii and ls and new occurance (when [ $startatboot = "yes" ]) of lines with the form below:
#	if [ -f $instpath/ls3 ]; then
#		$instpath/ls3 $instpath; echo "PowerMonitor (LanSafe Power Server)"
#	fi

#	echo "PowerMonitor (LanSafe Power Monitor)"   
#	This line is used in the following substitution of rc.local file.
	lineStr=`head -$PM_DESCRIPTION $INSTALLRES |tail -1`

	if [ "$startatboot"  = "yes" ]; then	# replace
		sed -e '
$a\
if [ -f '$instpath'/Bin/PowerMonitor ]; then
$a\
\	'$instpath'/Bin/PowerMonitor&
$a\
\	echo "$lineStr"
$a\
fi
/if.*ls/,/fi/d
/if.*lsiid/,/fi/d
' ${rcfile}.ls > $rcfile
		check_fatal
	else	# remove
		sed -e '
/if.*ls/,/fi/d
/if.*lsiid/,/fi/d
' ${rcfile}.ls > $rcfile
		check_fatal
	fi

	# Fixup perms on rcfile.
	chmod 755 $rcfile
	check_fatal
#	echo "Modified: $rcfile" >> $instpath/installed
	lineStr=`head -$MODIFIED_SERVICES $INSTALLRES |tail -1`
	echo "$lineStr $rcfile" >> $instpath/installed
#	echo "The following lines were removed from $rcfile:"
#	lineStr=`head -$REMOVE_SERVICE_STR $INSTALLRES |tail -1`
#	echo "$lineStr $rcfile:"
#	diff ${rcfile}.ls $rcfile | grep '^<' | sed -e 's/< //'
#	echo "The following lines were added to $rcfile:"
#	lineStr=`head -$ADD_SERVICE_STR $INSTALLRES |tail -1`
#	echo "$lineStr $rcfile:"
#	diff ${rcfile}.ls $rcfile | grep '^>' | sed -e 's/> //'

}

sysv_startatboot_linux () {
	if [ -d /sbin/init.d ]; then
# SuSe?
		initfile=/sbin/init.d/ls.init
		startfile=/sbin/init.d/rc3.d/S89ls.init
		stopfile=/sbin/init.d/rc0.d/K89ls.init
		return
	fi

	if [ -d /etc/rc.d/init.d ]; then
# Most Linuxes ?
		initfile=/etc/rc.d/init.d/ls.init
		startfile=/etc/rc.d/rc3.d/S89ls.init
		startfile2=/etc/rc.d/rc5.d/S89ls.init
		stopfile=/etc/rc.d/rc0.d/K89ls.init
		return
	fi

	if [ -d /etc/init.d ]; then
# TXN-09/09/02: SuSe 7.2 or 8.0
		initfile=/etc/init.d/ls.init
		startfile=/etc/init.d/rc5.d/S89ls.init
		if [ -d /etc/init.d/rc3.d ]; then
			#Suse 9 and 10
			startfile2=/etc/init.d/rc3.d/S89ls.init
		fi
		stopfile=/etc/init.d/rc0.d/K89ls.init
		return
	fi

# Other cases?
	initfile=/sbin/init.d/ls.init
	startfile=/sbin/rc2.d/S515ls.init
	stopfile=/sbin/rc1.d/K485ls.init
}

sysv_startatboot_other () {
	if [ -d /etc/init.d ]; then
		initfile=/etc/init.d/ls.init
		startfile=/etc/rc2.d/S89ls.init
		stopfile=/etc/rc0.d/K99ls.init
		return
	fi

	if [ $system = "dec" ]; then
		initfile=/sbin/init.d/ls.init
		startfile=/sbin/rc3.d/S89ls.init
		stopfile=/sbin/rc0.d/K99ls.init
		return
	fi

	initfile=/sbin/init.d/ls.init
	startfile=/sbin/rc2.d/S515ls.init
	stopfile=/sbin/rc1.d/K485ls.init
}

sysv_startatboot () {
#	Delete lsii stuff, if it exists
	lsii_initfile=/etc/init.d/lsii.init
	lsii_startfile=/etc/rc2.d/S89lsii.init
	lsii_stopfile=/etc/rc0.d/K99lsii.init

	startfile2=

	if [ $system = "linux" -o $system = "linux_el4" -o $system = "P5linux" -o $system = "P5linux_el4" -o $system = "linux_el4_amd64" -o $system = "linux_el4_ia64" ]; then
		sysv_startatboot_linux
	else
		sysv_startatboot_other
	fi

# Cleanup from previous install, okay for these to fail. First delete lsii files
	if [ -f $lsii_initfile ]; then
		rm -f $lsii_initfile
#		echo "Removed: $lsii_initfile" >> $instpath/installed
		lineStr=`head -$REMOVED_STR $INSTALLRES |tail -1`
		echo "$lineStr $lsii_initfile" >> $instpath/installed
	fi

	if [ -f $lsii_startfile ]; then
		rm -f $lsii_startfile
#		echo "Removed: $lsii_startfile" >> $instpath/installed
		lineStr=`head -$REMOVED_STR $INSTALLRES |tail -1`
		echo "$lineStr $lsii_startfile" >> $instpath/installed
	fi

	if [ -f $lsii_stopfile ]; then
		rm -f $lsii_stopfile
#		echo "Removed: $lsii_stopfile" >> $instpath/installed
		lineStr=`head -$REMOVED_STR $INSTALLRES |tail -1`
		echo "$lineStr $lsii_stopfile" >> $instpath/installed
	fi

# Second, Delete ls3 files
	if [ -f $initfile ]; then
		rm -f $initfile
#		echo "Removed: $initfile" >> $instpath/installed
		lineStr=`head -$REMOVED_STR $INSTALLRES |tail -1`
		echo "$lineStr $initfile" >> $instpath/installed
	fi

	if [ -f $startfile ]; then
		rm -f $startfile
#		echo "Removed: $startfile" >> $instpath/installed
		lineStr=`head -$REMOVED_STR $INSTALLRES |tail -1`
		echo "$lineStr $startfile" >> $instpath/installed
	fi

	if [ -f $stopfile ]; then
		rm -f $stopfile
#		echo "Removed: $stopfile" >> $instpath/installed
		lineStr=`head -$REMOVED_STR $INSTALLRES |tail -1`
		echo "$lineStr $stopfile" >> $instpath/installed
	fi

# Copy ls.init while setting install path
#	echo "Ready to copy ls.init to install path"
	lineStr=`head -$COPY_INIT_FILE $INSTALLRES |tail -1`
	echo "$lineStr"
	if [ -n "$cdrom_install" ]; then
		if [ -n "$uppercase_mount" ]; then
			InstallFile=1_INSTALL/LS.INIT
		else
			InstallFile=1_install/ls.init
		fi
	else
		InstallFile=1_install/ls.init
	fi

	tmpinitfile=$initfile".tmp"

	if [ "$startatboot" = "yes" ]; then
#	echo_n "Installing ls.init to init.d ... "
	lineStr=`head -$INSTALLING_INIT_FILE $INSTALLRES |tail -1`
	echo_n "$lineStr"

	lineStr=`head -$LS_VERSION $INSTALLRES |tail -1`

	sed '/5.0/c\
version='$lineStr'
' $InstallFile > $tmpinitfile

	sed '/\usr\/Powerware\/LanSafe\/Bin/c\
instpath='$instpath"/Bin"'
' $tmpinitfile > $initfile
	rm $tmpinitfile
	check_fatal

# Set permissions
	chmod 755 $initfile
	check_fatal
#	echo "Installed: $initfile" >> $instpath/installed
	lineStr=`head -$INSTALLED_STR $INSTALLRES |tail -1`
	echo "$lineStr $initfile" >> $instpath/installed
#	echo "done"
	lineStr=`head -$INSTALLED_DONE $INSTALLRES |tail -1`
	echo "$lineStr"

# Link init file in rc dirs.
	if [ -f "$startfile" ]; then
#		echo "Deleting $startfile"
		lineStr=`head -$DELETING_FILE_STR $INSTALLRES |tail -1`
		echo "$lineStr $startfile"
		rm $startfile
	fi

	if [ -f "$startfile2" ]; then
#		echo "Deleting $startfile2"
		lineStr=`head -$DELETING_FILE_STR $INSTALLRES |tail -1`
		echo "$lineStr $startfile2"
		rm $startfile2
	fi

#	echo_n "Linking $startfile to $initfile ... "		
	lineStr=`head -$LINK_FILE_STR $INSTALLRES |tail -1`
	lineStr1=`head -$INSTALL_TO $INSTALLRES |tail -1`
	echo_n "$lineStr $startfile $lineStr1 $initfile ... "		

	if [ -d /sbin/init.d -o -d /etc/rc.d/init.d -o "$system" = linux -o "$SYSTEM" = LINUX \
		-o "$system" = linux_el4 -o "$SYSTEM" = LINUX_EL4 \
		-o "$system" = P5linux_el4 -o "$SYSTEM" = P5LINUX_EL4 \
		-o "$system" = P5linux -o "$SYSTEM" = P5LINUX \
		-o "$system" = linux_el4_amd64 -o "$SYSTEM" = LINUX_EL4_AMD64 \
		-o "$system" = linux_el4_ia64 -o "$SYSTEM" = LINUX_EL4_IA64 ]; then
		ln -fs $initfile $startfile
	else
		ln $initfile $startfile
		check_fatal
#		echo "Linked: $startfile to $initfile" >> $instpath/installed
		lineStr=`head -$LINKED_STR $INSTALLRES |tail -1`
		lineStr1=`head -$INSTALL_TO $INSTALLRES |tail -1`
		echo "$lineStr: $startfile $lineStr1 $initfile" >> $instpath/installed
	fi

	# make sure startfile2 is not null before linking it.
	if [ -n "$startfile2" ]; then
		echo
#		echo_n "Linking $startfile2 to $initfile ... "		
		lineStr=`head -$LINK_FILE_STR $INSTALLRES |tail -1`
		lineStr1=`head -$INSTALL_TO $INSTALLRES |tail -1`
		echo_n "$lineStr $startfile2 $lineStr1 $initfile ... "		
		ln -fs $initfile $startfile2
		check_fatal
#		echo "Linked: $startfile2 to $initfile" >> $instpath/installed
		lineStr=`head -$LINKED_STR $INSTALLRES |tail -1`
		lineStr1=`head -$INSTALL_TO $INSTALLRES |tail -1`
		echo "$lineStr: $startfile2 $lineStr1 $initfile" >> $instpath/installed
#		echo "done"
		lineStr=`head -$INSTALLED_DONE $INSTALLRES |tail -1`
		echo $lineStr
	fi

	if [ -f "$stopfile" ]; then
		echo "Deleting $stopfile"
		rm $stopfile
	fi

#	echo_n "Linking $stopfile to $initfile ... "
	lineStr=`head -$LINK_FILE_STR $INSTALLRES |tail -1`
	lineStr1=`head -$INSTALL_TO $INSTALLRES |tail -1`
	echo_n "$lineStr $stopfile $lineStr1 $initfile ... "		
	if [ -d /sbin/init.d -o -d /etc/rc.d/init.d -o "$system" = linux -o "$SYSTEM" = LINUX \
		-o "$system" = linux_el4 -o "$SYSTEM" = LINUX_EL4 \
		-o "$system" = linux_el4_amd64 -o "$SYSTEM" = LINUX_EL4_AMD64 \
		-o "$system" = linux_el4_ia64 -o "$SYSTEM" = LINUX_EL4_IA64 \
		-o "$system" = P5linux -o "$SYSTEM" = P5LINUX \
		-o "$system" = P5linux_el4 -o "$SYSTEM" = P5LINUX_EL4 ]; then
		ln -fs $initfile $stopfile
	else
		ln $initfile $stopfile
	fi
	check_fatal

#	echo "Linked: $stopfile to $initfile" >> $instpath/installed
	lineStr=`head -$LINKED_STR $INSTALLRES |tail -1`
	lineStr1=`head -$INSTALL_TO $INSTALLRES |tail -1`
	echo "$lineStr: $stopfile $lineStr1 $initfile" >> $instpath/installed
#	echo "done"
	lineStr=`head -$INSTALLED_DONE $INSTALLRES |tail -1`
	echo $lineStr
	fi
}

inittab_startatboot () {
	inittab=/etc/inittab
# Backup old inittab
	mv -f $inittab ${inittab}.ls
	check_fatal
# Use sed to remove old occurance of form below and add new lines of the form below
#	ls3:2345:once:$instpath/ls3

	if [ $startatboot = "yes" ]; then
		sed -e '
$a\
PM:2345:once:'$instpath'/Bin/PowerMonitor.sh&
/^PM:2345:once:/d
/^PM:234:once:/d
/^lsii:23:once:/d
' ${inittab}.ls > $inittab
		check_fatal
	else
		sed -e '
/^PM:2345:once:/d
/^PM:234:once:/d
/^lsii:23:once:/d
' ${inittab}.ls > $inittab
		check_fatal
	fi
# Fixup perms on inittab.
	chmod 444 $inittab
	check_fatal

# Report differences
#	echo "Modified: $inittab" >> $instpath/installed
#	echo "The following lines were removed from $inittab:"
#	diff ${inittab}.ls $inittab | grep '^<' | sed -e 's/< //'
#	echo "The following lines were added to $inittab:"
#	diff ${inittab}.ls $inittab | grep '^>' | sed -e 's/> //'

	lineStr=`head -$MODIFIED_SERVICES $INSTALLRES |tail -1`
	echo "$lineStr $inittab" >> $instpath/installed
#	lineStr=`head -$REMOVE_SERVICE_STR $INSTALLRES |tail -1`
#	echo "$lineStr $inittab:"
#	diff ${inittab}.ls $inittab | grep '^<' | sed -e 's/< //'
#	lineStr=`head -$ADD_SERVICE_STR $INSTALLRES |tail -1`
#	echo "$lineStr $inittab:"
#	diff ${inittab}.ls $inittab | grep '^>' | sed -e 's/> //'

}

FixScoFile () {
#	Put the the correct path into s1.objscr
	File2Fix=/usr/lib/X11/XDesktop3/applications/Ls3.obj/s1.objscr
	mv -f $File2Fix $File2Fix.ls
	sed '/\usr\/Powerware\/LanSafe\/Bin/c\
instpath='$instpath"/Bin"'
'   $File2Fix.ls > $File2Fix
}

#Function no longer used RF 6/20/03
DisableInsight() {
	InsightFile=/usr/bin/compaq/ups/ups.cfg
	if [ $system = "uw2" ]; then
		cpqups_stopper="/etc/init.d/cpqups"
	else
		cpqups_stopper="/etc/cpqups"
	fi

	if [ -f $InsightFile -a -f $cpqups_stopper ]; then
		echo
		echo "Compaq Insight Manager UPS management functions must be"
		echo "disabled to install LanSafe UPS management."
		read_def "Do you want them disabled? (y/n) [y] " "y"
		case $answer in
		[yY]|[yY][eE][sS])	#/etc/cpqups stop
			if [ $system = "uw2" ]; then
				sh /etc/init.d/cpqups stop
			else
				$cpqups_stopper stop
			fi
			mv -f $InsightFile $InsightFile.ls
			sed '/SERIAL_PORT/c\
SERIAL_PORT=""
' $InsightFile.ls > $InsightFile
			;;
		*)
			exit 0
			;;
		esac
	fi
}

main () {
# override=true
# global bsdecho
# global system
# global uncompress_cmd has to be set after extract
# skip_extract=true
# skip_install=true
# skip_chk4sp=true
# skip_services=true
# skip_config=true
# skip_cleanup=true
# Setup some globals
	ret=TRUE;
	bsdecho=`compute_echo`

# Must check parameters
	SYSTEM=""
	lang=""
	tardev=""
	if [ "$1" != "" ] ; then
		get_parameters $1
	fi

	if [ "$2" != "" ] ; then
		get_parameters $2
	fi

	if [ "$3" != "" ] ; then
		get_parameters $3
	fi

# Must set system and SYSTEM prior prompting generic AT&T SVR4 if system is undetermined.
#	if [ "$1" = "" ] ; then
	if [ "$SYSTEM" = "" ] ; then
		compute_SYSTEM

# Need to know if we are on sco3 or sco5 at this point.
		if [ "$system" = sco -o "$SYSTEM" = SCO ]; then
			sco_system=`compute_sco_system`
		fi

# Need to know if we are running at least DG/UX 4.20MU01 or above.
		if [ "$system" = dgux -o "$SYSTEM" = DGUX ]; then
			compute_dgux_system
		fi
#	else
#		SYSTEM=$1
	fi

# now convert uppercase into lower and check validity at the same time
	compute_system




#	Is the installation from a cd-rom?
#	USED TO BE: if the name of this file is in CAPITAL letters then it is on a CD-ROM.
#	NOW: if lansafe or LANSAFE dir exists -> CDROM: Andrei 4.10

	if [ -d "./1_INSTALL" -o -d "./1_install" ]; then
#	if [ -d "./1_INSTALL" ]; then
		cdrom_install=true
		skip_extract=true
		skip_gettardev=tar
		skip_cleanup=true
		tardev=CD_ROM
	elif [ "$tardev" = "" ]; then
		# Cannot translate this line.  No information to find where is install.res file.
		# Must present to user as English
		echo "Usage: ./install.sh [Language] [tarfile name] [SYSTEM]"
#		lineStr=`head -$USAGE_STR $INSTALLRES |tail -1`
#		echo "$lineStr"
		exit 0
	fi

  if [ -f ./INSTALL.SH ]; then
	if [ "$system" != macosx -o "$SYSTEM" != MACOSX ]; then
				uppercase_mount=true
		fi
  fi

# Get language locale 
	if [ "$lang" = "" ]; then
		check_locale_language
		if [ -z "$lang" ]; then
			lang=EN
		fi
	fi 

#  Initialize resource strings.
	systemdir="2_$system"_$lang
	SYSTEMDIR="2_$SYSTEM"_$lang
	INSTALLRES="2_$system"_$lang/install.res
	if [ "$tardev" != "" ]; then
		tar -xf $tardev $systemdir/install.res >/dev/null 2>&1
	elif [ ! -d "./1_INSTALL" ]; then
		# Cannot translate this line.  No information to find where is install.res file.
		# Must present to user as English
		echo "Usage: ./install.sh [Language] [tarfile name] [SYSTEM]"
		exit 0
	fi
	initDefines


# Add code to find the language code of the OS.


# Say hello
#	if system is aix3, dec, ia, linux, sunos, svr4 or sco3
#		then we'll install just vanilla ls3 unix
#	else
#		we'll install vanilla ls3 unix and prompt for ls3 snmp agent installation.
	clear
	echo
	echo 
	echo "-----------------------------------------------------------------"
	echo
	
	#MANTIS-2088
	echo "                      EATON | Powerware"
	echo
#	echo "Welcome to LanSafe!"
	lineStr=`head -$WELCOME_STR1 $INSTALLRES |tail -1`
	echo "                   $lineStr"

	if [ "$system" = ia -o "$SYSTEM" = IA ]; then
#		echo "                Version 5.0.0"
		lineStr=`head -$AGENT_INSTALL_INTRO_STR2 $INSTALLRES |tail -1`
		lineStr1=`head -$LS_VERSION $INSTALLRES |tail -1`
		echo "                $lineStr $lineStr1"
	else
#		echo "         `pwd`/$0 Version 5.0.0"
		lineStr=`head -$AGENT_INSTALL_INTRO_STR2 $INSTALLRES |tail -1`
		lineStr1=`head -$LS_VERSION $INSTALLRES |tail -1`
		#iecho "         `pwd`/$0 $lineStr $lineStr1"
		echo "                       $lineStr $lineStr1"
	fi
	echo
#	echo "           To install LanSafe for UNIX, select (y)"
#	echo "and fill in the configuration items as they are presented to you."
	lineStr=`head -$WELCOME_STR2 $INSTALLRES |tail -1`
	echo "$lineStr"
	lineStr=`head -$WELCOME_STR3 $INSTALLRES |tail -1`
	echo "$lineStr"
	echo
	echo "-----------------------------------------------------------------"
	echo
###############################################################
#	if [ '(' "$system" = aix3 ')' -o '(' "$system" = dec ')' -o '(' "$system" = ia ')' -o '(' "$system" = linux ')' \
#		-o '(' "$system" = sunos ')' -o '(' "$system" = svr4 ')' -o '(' "$SYSTEM" = AIX3 ')' -o '(' "$SYSTEM" = DEC ')' \
#		-o '(' "$SYSTEM" = IA ')' -o '(' "$SYSTEM" = LINUX ')' -o '(' "$SYSTEM" = SUNOS ')' -o '(' "$SYSTEM" = SVR4 ')' \
#		-o '(' x$sco_system = xsco3 ')' -o '(' "$system" = dgux ')' -o '(' "$SYSTEM" = DGUX ')' ];
################################################################
#	then
#		read_def "  Continue installation? (y/n) [y] " "y"
################################################################

system_list="aix3 dec ia irix linux linux_el4 linux_el4_amd64 linux_el4_ia64 P5linux P5linux_el4 sunos svr4 sco3 dgux "
setFlag=0

for tmp in $system_list ; 
do 
if [ $system = $tmp ]
then
	setFlag=1 
	break
fi
done

	if [ $setFlag = 1 ]
	then
#		read_def "  Continue installation? (y/n) [y] " "y"
		echo
		lineStr=`head -$CONTINUE_INSTALLATION $INSTALLRES |tail -1`
		read_def "		$lineStr (y/n) [y] " "y"
		case $answer in
		[yY]|[yY][eE][sS])
			;;
		*)
			exit 0
			;;
		esac
	else
#		echo "The installation process is divided as follows:"
#		echo
#		echo "   LanSafe for Unix will be installed first."
#		echo "   LanSafe SNMP agent will be installed next."
#		echo
#		echo "NOTE: If you already have LanSafe for Unix installed and you"
#		echo "      do not wish to re-install it, select (N)o to stop"
#		echo "      LanSafe for Unix installation. You will be then prompted"
#		echo "      to install LanSafe SNMP agent."


		lineStr=`head -$INSTALL_INTRO_STR1 $INSTALLRES |tail -1`
		echo "	$lineStr"
		echo
		lineStr=`head -$INSTALL_INTRO_STR2 $INSTALLRES |tail -1`
		echo "         1. $lineStr"
		lineStr=`head -$INSTALL_INTRO_STR3 $INSTALLRES |tail -1`
		echo "         2. $lineStr"
		echo
		echo
		lineStr=`head -$INSTALL_INTRO_STR4 $INSTALLRES |tail -1`
		echo "      $lineStr"
		lineStr=`head -$INSTALL_INTRO_STR5 $INSTALLRES |tail -1`
		echo "      $lineStr"
		lineStr=`head -$INSTALL_INTRO_STR6 $INSTALLRES |tail -1`
		echo "      $lineStr"
		lineStr=`head -$INSTALL_INTRO_STR7 $INSTALLRES |tail -1`
		echo "      $lineStr"
		echo
		echo

#		read_def "  Continue LanSafe for Unix installation? (y/n) [y] " "y"
		lineStr=`head -$INSTALL_INTRO_STR8 $INSTALLRES |tail -1`
		read_def "         $lineStr (y/n) [y] " "y"
		case $answer in
		[yY]|[yY][eE][sS])
			;;
		*)
			echo
#			echo "           LanSafe for SNMP installation"
#			echo "                   Version 5.0.0"
#			echo
#			echo "LanSafe SNMP agent gives your SNMP manageable network node the"
#			echo "capability to manage UPS information."
#			echo
#			echo "In order to manage SNMP information, a node must have SNMP"
#			echo "daemon installed and running."
#			echo
#			read_def " Do you want to install LanSafe SNMP agent? (y/n) [y] " "y"

			lineStr=`head -$AGENT_INSTALL_INTRO_STR1 $INSTALLRES |tail -1`
			echo "-------------------------------------------------------------------------------"
			echo "                          $lineStr"
			lineStr=`head -$AGENT_INSTALL_INTRO_STR2 $INSTALLRES |tail -1`
			lineStr1=`head -$LS_VERSION $INSTALLRES |tail -1`
			echo "                            $lineStr $lineStr1"
			echo "-------------------------------------------------------------------------------"
			echo
			lineStr=`head -$AGENT_INSTALL_INTRO_STR3 $INSTALLRES |tail -1`
			echo "$lineStr"
			lineStr=`head -$AGENT_INSTALL_INTRO_STR4 $INSTALLRES |tail -1`
			echo "$lineStr"
			lineStr=`head -$AGENT_INSTALL_INTRO_STR5 $INSTALLRES |tail -1`
			echo "$lineStr"
#			lineStr=`head -$AGENT_INSTALL_INTRO_STR6 $INSTALLRES |tail -1`
#			echo "$lineStr"
			echo
			lineStr=`head -$AGENT_INSTALL_INTRO_STR7 $INSTALLRES |tail -1`
			read_def "      $lineStr (y/n) [y] " "y"

			case $answer in
			[yY]|[yY][eE][sS])
				if [ -n "$skip_gettardev" ]; then
					get_tardev
				fi

# Different cases for dat, cdrom and floppy media.
				if [ -n "$cdrom_install" ]; then
					tardev=CD_ROM
					echo tardev
					echo $tardev
					echo instpath
					echo $instpath
					exec sh ./AGENT.SH $tardev $instpath $installUPSType
				else
					echo

# agent.sh will be generic for all platforms
					if [ -z "$tardev" ]; then
						get_tardev
					fi
					tar -xf $tardev agent.sh >/dev/null 2>&1
					check_status
					if [ $? != 0 ]; then
#						echo "Error extracting files?"
						lineStr=`head -$ERR_EXTRACTING_FILE $INSTALLRES |tail -1`
						echo $lineStr
						exit 0
					fi

					exec sh ./agent.sh $tardev $instpath
#					exec sh -x ./agent.sh $tardev
				fi
				;;
			*)	#default for "Do you want to install ls3 snmp agent?"
				exit 0
				;;
			esac
			;;
		esac
	fi	# end-of big "if system aix3 -o system -o dec.. "

	if [ x"$system" = x"Unknown System" ]
	then
		echo
#		echo "  Unable to determine your system."
		lineStr=`head -$ERR_UNKNOWN_SYSTEM $INSTALLRES |tail -1`
		echo "  $lineStr"
		answer=""
		while [ -z "$answer" ]; do
			echo
#			echo "Answering (N)o to this question will exit install.sh without installing LanSafe."
#			echo
#			read_def "  Do you want to install LanSafe for AT&T SVR4 derivative? (y/n) "

			lineStr=`head -$SVR4_AGENT_INSTALL_STR1 $INSTALLRES |tail -1`
			echo $lineStr
			echo
			lineStr=`head -$SVR4_AGENT_INSTALL_STR2 $INSTALLRES |tail -1`
			read_def "  $lineStr (y/n) "

			case $answer in
				[yY]|[yY][eE][sS])
					system=svr4
					SYSTEM=SVR4
					;;
				[nN]|[nN][Oo])
					exit 0
					;;
				*)
					answer=""
					;;
			esac
		done
	fi	# end-of "if system = Unknown system"

	echo
	echo
	if [ -n "$cdrom_install" ]; then
#		read_def "Are you installing from a CD-ROM? (y/n) [y] " "y"
#		echo "Installing from CD-ROM"
		lineStr=`head -$INSTALL_SOURCE_CDROM $INSTALLRES |tail -1`
		echo "                    $lineStr"
		echo
	else
#		read_def "Are you installing from a CD-ROM? (y/n) [n] " "n"
#		echo "Installing from tarfile"
		lineStr=`head -$INSTALL_SOURCE_TARFILE $INSTALLRES |tail -1`
		echo "$lineStr"
		echo
	fi

#		case $answer in
#		[yY]|[yY][eE][sS])
#			cdrom_install=true
#			skip_extract=true
#			skip_gettardev=tar
#			skip_cleanup=true
#			tardev=CD_ROM
#			uppercase_mount=true
#			;;
#		esac

# Prompt for answers to all questions, with verify.
	userverified=""
	while [ -z "$userverified" ]; do
# Get device for file extraction.
		if [ -z "$skip_gettardev" ]; then
			get_tardev
		fi

# Get install path
		defpath=/usr/Powerware/LanSafe
		instpath=
		newpath=
		while [ -z "$instpath" ]; do
			newpath=$defpath
				echo
#				echo "The default install path name for this software is:  $defpath"
				lineStr=`head -$DEFAULT_PATH_STR $INSTALLRES |tail -1`
				echo "   $lineStr"
				echo "   $defpath"
				echo
#				read_def '   Do you want to continue with this install path? (y/n) [n] ' "n"
				lineStr=`head -$ASK_CHANGE_INSTALL_PATH $INSTALLRES |tail -1`
				read_def "   $lineStr (y/n) [y] " "y"
			case $answer in
			[nN]|[nN][oO])
#				read_def "   Enter absolute install path: "
				lineStr=`head -$ENTER_INSTALL_PATH $INSTALLRES |tail -1`
				read_def "   $lineStr "
				newpath=$answer
				case $newpath in
				/)      echo  
								lineStr=`head -$ERR_INSTALL_ROOT_PATH $INSTALLRES |tail -1`
					echo $lineStr
					newpath=
					;;
				/*)
					echo
#					echo "New install path is:  $answer"
					lineStr=`head -$NEW_PATH $INSTALLRES |tail -1`
					echo "   $lineStr $answer"
#					read_def '   Is this OK? (y/n) [y] ' "y"
					lineStr=`head -$OK_STR $INSTALLRES |tail -1`
					read_def "      $lineStr (y/n) [y] " "y"
					case $answer in
						[yY]|[yY][eE][sS])
							;;
						*)
							newpath=
							;;
					esac
					;;
				*)
					echo
#					echo "   Warning:  You must enter absolute path to install directory.  e.g. $defpath"
					lineStr=`head -$ERR_INSTALL_PATH $INSTALLRES |tail -1`
					echo "   $lineStr"
					echo "   $defpath"
					newpath=
				esac
			esac

			if [ ! -z "$newpath" ]; then
				create_path $newpath
				if [ $? = 0 ]; then
					instpath=$newpath
				else
#					echo "Unable to install to $newpath.  Choose another directory."
					lineStr=`head -$ERR_AGENT_INSTALL_PATH_STR1 $INSTALLRES |tail -1`
					lineStr1=`head -$ERR_AGENT_INSTALL_PATH_STR2 $INSTALLRES |tail -1`
					echo "$lineStr $newpath. $lineStr1"
				fi
#				bitmapdir=$newpath"/bitmaps"
#				create_path $bitmapdir
#				if [ $? != 0 ]; then
#					echo "Unable to create bitmaps directory"
#				fi
			fi
		done	# end-of while $instpath

		if [ "$system" = linux -o "$SYSTEM" = LINUX \
		  -o "$system" = linux_el4 -o "$SYSTEM" = LINUX_EL4 \
	         -o "$system" = linux_el4_amd64 -o "$SYSTEM" = LINUX_EL4_AMD64 \
		-o "$system" = linux_el4_ia64 -o "$SYSTEM" = LINUX_EL4_IA64 \
		-o "$system" = P5linux -o "$SYSTEM" = P5LINUX \
		  -o "$system" = P5linux_el4 -o "$SYSTEM" = P5LINUX_EL4 ]; then
			fixup_linux_system
		fi

# Get start at boot flag
#		echo "Automatic Startup"
#		echo "To automatically run LanSafe upon startup on the computer"
#		echo "being installed, enter (y)es, otherwise enter (n)o."
#		echo "NOTE: It is strongly recommended that you select Yes for this option"
#		echo "in order to provide full protection from multiple power outages."
#		echo
#		read_def "   Automatically run LanSafe power monitor daemon on startup? (y/n) [y] " "y"

		echo
#		lineStr=`head -$AUTO_START_STR1 $INSTALLRES |tail -1`
#		echo $lineStr
#		lineStr=`head -$AUTO_START_STR2 $INSTALLRES |tail -1`
#		echo $lineStr
#		lineStr=`head -$AUTO_START_STR3 $INSTALLRES |tail -1`
#		echo $lineStr
#		lineStr=`head -$AUTO_START_STR4 $INSTALLRES |tail -1`
#		echo $lineStr
#		lineStr=`head -$AUTO_START_STR5 $INSTALLRES |tail -1`
#		echo $lineStr
#		echo

#       PowerMonitor always start at reboot.  No need to ask user.  3/11/04

#        lineStr=`head -$AUTO_START_STR6 $INSTALLRES |tail -1`
#		read_def "   $lineStr (y/n) [y] " "y"

#		case $answer in
#		[yY]|[yY][eE][sS])
#			startatboot="yes"
#			;;
#		*)
#			startatboot="no"
#			;;
#		esac
		startatboot="yes"

		echo
		echo "---------------------------------------------------------------"
#		echo "LanSafe Installation Parameters:"
#		echo
#		echo "   Device or tarfile to install from is :  $tardev"
#		echo "              Directory to install to is:  $instpath"
#		echo "    Automatically run LanSafe on startup:  $startatboot"

		lineStr=`head -$CONFIRM_INSTALL_PARAMS_STR1 $INSTALLRES |tail -1`
		echo "                   $lineStr"
		echo
		lineStr=`head -$CONFIRM_INSTALL_PARAMS_STR2 $INSTALLRES |tail -1`
		echo "   $lineStr  $tardev"
		lineStr=`head -$CONFIRM_INSTALL_PARAMS_STR3 $INSTALLRES |tail -1`
		echo "   $lineStr  $instpath"
#		lineStr=`head -$CONFIRM_INSTALL_PARAMS_STR4 $INSTALLRES |tail -1`
#		echo "   $lineStr  $startatboot"

		echo "---------------------------------------------------------------"
		echo
		answer=""
		while [ -z "$answer" ]; do
			echo
#			read_def "  Are these installation parameters acceptable? (y/n) "
			lineStr=`head -$CONFIRM_INSTALL_PARAMS_STR5 $INSTALLRES |tail -1`
			read_def "  $lineStr (y/n) "
		done

		case $answer in
		[yY]|[yY][eE][sS])
			userverified=true
			;;
		esac
	done

# Create Flag and Export directory.
	if [ ! -z "$newpath" ]; then

		bitmapdir=$newpath"/Flag"
		create_path $bitmapdir
		bitmapdir=$newpath"/Export"
		create_path $bitmapdir
		bitmapdir=$newpath"/Log"
		create_path $bitmapdir
	fi

# Modify how to extract license.txt file.  Doesn't need to copy out from 2_$system for language support.
# Extract files
#	tardev="", tardev set above!
	if [ -z "$skip_extract" ]; then
		extract_files
		tar -xvf $tardev $systemdir/license.txt >/dev/null 2>&1
		echo "Extracting files completed"
		echo " "
	fi

# License Agreement
	echo " "
#	echo "License Agreement: "
	lineStr=`head -$LICENSE_AGREEMENT $INSTALLRES |tail -1`
	echo "$lineStr"
	echo

	if [ -z "$skip_config" ]; then
		if [ -f ./$systemdir/readLic ]; then
			cd $systemdir
			./readLic
			AgreedLicense=$?
		elif [ -f ./"2_$system"_$lang/readlic ]; then
			cd "2_$system"_$lang
			./readlic
			AgreedLicense=$?
		elif [ -f ./$SYSTEMDIR/READLIC ]; then
			cd $SYSTEMDIR
			./READLIC
			AgreedLicense=$?
		fi
		cd ..

		if [ $AgreedLicense != "1" ]; then
			echo " "
#			echo "Install failed!"
			lineStr=`head -$ERR_LIC_AGREE $INSTALLRES |tail -1`
			echo "$lineStr"
			exit 1
		fi
	fi


	# Install files
	if [ -z "$skip_install" ]; then
		install_files
	fi

# Not used RF 6/19/03
# Do not need to translate
# Check for stream pipes in kernel
	if [ -z "$skip_chk4sp" ]; then
		chk4sp
		check_fatal
	fi

# Setup /etc/services
	if [ -z "$skip_services" ]; then
		setup_services
	fi

# Setup auto start on boot
	editAutoFile="false"

	if [ "$system" = macosx -o "$SYSTEM" = MACOSX ]; then
			echo " darwin_startatboot "
			darwin_startatboot
			editAutoFile="true"
	fi

		
	initd_tmp=""
	if [ -d /etc/init.d -o -d /sbin/init.d -o -d /etc/rc.d/init.d ]; then
		initd_tmp=true
	else
		initd_tmp=false
	fi
	if [ "$initd_tmp" = true -a  "$system" != aix -a "$SYSTEM" != AIX4 ]; then
			echo "sysv_startatboot"
			sysv_startatboot
			editAutoFile="true"
	elif [ -f /etc/inittab ]; then
			echo "inittab_startatboot"
			inittab_startatboot
			editAutoFile="true"
	elif [ -f /etc/rc.d/rc.local ]; then
			echo " bsd_startatboot "
			bsd_startatboot
			editAutoFile="true"
	fi

# Update Install Path in PowerMonitor.sh and uninstall.sh
	updateInstallPath
	
	if [ $editAutoFile = "false" ]; then
		echo " UNDETERMINE "
		if [ $startatboot = "yes" ]; then
			echo
			echo
			echo "-------------------------------------------------------"
#			echo "     Unable to determine how to make your system       "
#			echo "     automatically load the Power Monitor at boot time. "
#			echo "     Consult the manual for your system.               "
			lineStr=`head -$ERR_AUTO_LOAD_STR1 $INSTALLRES |tail -1`
			echo "     $lineStr"
			lineStr=`head -$ERR_AUTO_LOAD_STR2 $INSTALLRES |tail -1`
			echo "     $lineStr"
			lineStr=`head -$ERR_AUTO_LOAD_STR3 $INSTALLRES |tail -1`
			echo "     $lineStr"
			echo "-------------------------------------------------------"
			echo
			echo
#			read_def "  Okay? (y) [y] "
			lineStr=`head -$CONFIRM_OK $INSTALLRES |tail -1`
			read_def "  $lineStr (y) [y] "
		fi
	fi

# Disable the Insight UPS device driver
	DisableInsight

# Move the bitmap files to the bitmaps directory
#	bitmaps=$instpath"/*.bmp"
#	bitmapdir=$instpath"/bitmaps"
#	mv $bitmaps $bitmapdir

# RF - 03/12/03
# No need to fix this file since we are not using cosole
#	If on SCO - Change the s1.objscr file to point to install directory
#	if [ $system = "sco" ]; then
#		FixScoFile
#	fi

# Kill the ls3 daemon if it is running so the copy during installation will run OK
	kill_ls3

# Run install.ls to build initial ls3.cfg
# If an old ls3.cfg exits then values in it are used for defaults.

	echo
	echo
	if [ -z "$skip_config" ]; then
		orig_dir=`pwd`
		cd $instpath/Bin
		./install.ls
		InstallNUM="$?"
		cd $orig_dir
		if [ $? = 456 ]; then
			installUPSType="Network"
		else
			installUPSType="Serial"
		fi
	fi

#  LS v5 no longer support UW2.  3/10/04
# Install the UPS device driver.

# RF   4/9/04
# Dry contact ups is not tested in SCO.
# There is no need to install dry contact driver
  skip_upsdrv=true

	if [ -z "$skip_upsdrv" ]; then
			if [ $system = "uw2" ]; then
#				echo "LanSafe does not support UnixWare 2.x with a Dry Contact UPS"
				lineStr=`head -$ERR_UW2_DRY_CONTACT_UPS $INSTALLRES |tail -1`
				echo "$lineStr"
				ret=FALSE
			elif [ "$sco_system" = sco5 ]; then
				install_upsdrv
			fi
	fi

# Start PowerMonitor
	if [ "$startatboot"  = "yes" ]; then
		$instpath/Bin/PowerMonitor.sh
	fi

# PowerMonitorAgent available for aix, hp9, hp10, solaris intel, solaris sparc, uw2 and sco5
	if [ '(' "$system" = aix ')' -o '(' "$system" = solint ')' -o '(' "$system" = solari ')' -o '(' "$system" = uw2 ')'  \
	-o '(' "$SYSTEM" = AIX4 ')' -o '(' "$SYSTEM" = AIX5 ')' -o '(' "$system" = SOLINT ')' -o '(' "$SYSTEM" = SOLARI ')'  \
	-o '(' "$SYSTEM" = UW2 ')' -o '(' "$SYSTEM" = HPUX ')' -o '(' "$system" = hpux ')' -o '(' x"$sco_system" = xsco5 ')' ];
	then

		echo
#		echo "LanSafe for SNMP installation"
#		echo "-----------------------------"
#		echo
#		echo "LanSafe SNMP gives your SNMP manageable network node the"
#		echo "capability to manage UPS information."
#		echo
#		echo "In order to manage SNMP information, a node must have SNMP"
#		echo "daemon installed and running."
#		echo
#		read_def " Do you want to install LanSafe SNMP agent? (y/n) [y] " "y"

		lineStr=`head -$AGENT_INSTALL_INTRO_STR1 $INSTALLRES |tail -1`
		echo "           $lineStr"
		lineStr=`head -$AGENT_INSTALL_INTRO_STR2 $INSTALLRES |tail -1`
		lineStr1=`head -$LS_VERSION $INSTALLRES |tail -1`
		echo "           $lineStr $lineStr1"
		echo
		lineStr=`head -$AGENT_INSTALL_INTRO_STR3 $INSTALLRES |tail -1`
		echo "$lineStr"
		lineStr=`head -$AGENT_INSTALL_INTRO_STR4 $INSTALLRES |tail -1`
		echo "$lineStr"
		lineStr=`head -$AGENT_INSTALL_INTRO_STR5 $INSTALLRES |tail -1`
		echo "$lineStr"
#		lineStr=`head -$AGENT_INSTALL_INTRO_STR6 $INSTALLRES |tail -1`
#		echo "$lineStr"
		echo
		lineStr=`head -$AGENT_INSTALL_INTRO_STR7 $INSTALLRES |tail -1`
		read_def " $lineStr (y/n) [y] " "y"

		case $answer in
		[yY]|[yY][eE][sS])
			if [ -z "skip_gettardev" ]; then
				get_tardev
			fi
# Different cases for dat, cdrom and floppy media.
			if [ -n "$cdrom_install" ]; then
				if [ -n "$uppercase_mount" ]; then
					exec sh ./AGENT.SH $tardev $instpath
				else
					exec sh ./agent.sh $tardev $instpath
				fi
			fi

			if [ -z "$tar_install" ]; then
				echo
				echo_n "Insert $system disk # 1... press Enter when ready. ."
				read x
			fi

			echo
#			echo "Now extracting LanSafe SNMP agent installation script. Please wait..."
			lineStr=`head -$EXTRACT_AGENT_WAIT $INSTALLRES |tail -1`
			echo "$lineStr"
			tar -xf $tardev agent.sh >/dev/null 2>&1
			check_status
			if [ $? != 0 ]; then
#				echo "Error extracting files?"
				lineStr=`head -$ERR_EXTRACT_AGENT $INSTALLRES |tail -1`
				echo "$lineStr"
				exit 0
			fi
			exec sh ./agent.sh $tardev $instpath
			;;
		*)
# Clean up
#			if [ -z "$skip_cleanup" ]; then
#				rm -rf `compute_tapedirs`
#				rm -f install.sh
#				rm -f agent.sh
#				rm -f readLic
#				rm -f license.txt
#			fi
			;;
		esac
#	else	# This is else for if [ "$system" != aix3 -o "$system" != dec -o "$system" != ia ..."
# Clean up
#		if [ -z "$skip_cleanup" ]; then
#			rm -rf `compute_tapedirs`
#			rm -f install.sh
#			rm -f agent.sh
#			rm -f readLic
#			rm -f license.txt
#		fi
	fi

# If HP-UX 10.0, check for transition links.
	if [ $system = "hpux" ]; then
		set `uname -a`
		if [ $3 = "B.10.00" ]; then
			set `swlist -l fileset Upgrade.UPG-TLINK | grep B.10.00 | wc -l`
			if [ $1 != 1 ]; then
				echo
				echo "---------------------------------------------------------------"
#				echo "     LanSafe Notification:"
#				echo "     LanSafe requires HP-UX 10.0 transition links which"
#				echo "     may not be installed on your system. See Installing"
#				echo "     HP-UX 10.0 and the swinstall manpage for further"
#				echo "     information."

				lineStr=`head -$ERR_LINK_HPUX_STR1 $INSTALLRES |tail -1`
				echo "     $lineStr"
				lineStr=`head -$ERR_LINK_HPUX_STR2 $INSTALLRES |tail -1`
				echo "     $lineStr"
				lineStr=`head -$ERR_LINK_HPUX_STR3 $INSTALLRES |tail -1`
				echo "     $lineStr"
				lineStr=`head -$ERR_LINK_HPUX_STR4 $INSTALLRES |tail -1`
				echo "     $lineStr"
				lineStr=`head -$ERR_LINK_HPUX_STR5 $INSTALLRES |tail -1`
				echo "     $lineStr"

				echo "---------------------------------------------------------------"
				echo
#				read_one "Press ENTER to continue: "
				lineStr=`head -$PRESS_CONTINUE $INSTALLRES |tail -1`
				read_one "$lineStr "
				echo
			fi
		fi
	fi

# If SunOS, check for Motif patch and notify installer if they need it. Also, let them know about the -nosunview switch for xnews.
	if [ $system = "sunos" ]; then
		$instpath/chk4patch.sh
		if [ $? != 0 ]; then
			echo
			echo "---------------------------------------------------------------"
			echo "     LanSafe Notification:"
			echo "     SunOS 4.1.3 requires a patch to run Motif applications."
			echo "     LanSafe may require the patch in order to run the"
			echo "     ls3X and ls3conX applications while using the xnews X"
			echo "     server. The patch is not required to run the ls3 and"
			echo "     ls3con applications (Power Monitor and the character"
			echo "     based LanSafe Console). Contact Sun Microsystems"
			echo "     for patch number 100444-66."

			lineStr=`head -$ERR_LINK_SUNOS_STR1 $INSTALLRES |tail -1`
			echo "     $lineStr"
			lineStr=`head -$ERR_LINK_SUNOS_STR2 $INSTALLRES |tail -1`
			echo "     $lineStr"
			lineStr=`head -$ERR_LINK_SUNOS_STR3 $INSTALLRES |tail -1`
			echo "     $lineStr"
			lineStr=`head -$ERR_LINK_SUNOS_STR4 $INSTALLRES |tail -1`
			echo "     $lineStr"
			lineStr=`head -$ERR_LINK_SUNOS_STR5 $INSTALLRES |tail -1`
			echo "     $lineStr"
			lineStr=`head -$ERR_LINK_SUNOS_STR6 $INSTALLRES |tail -1`
			echo "     $lineStr"
			lineStr=`head -$ERR_LINK_SUNOS_STR7 $INSTALLRES |tail -1`
			echo "     $lineStr"
			lineStr=`head -$ERR_LINK_SUNOS_STR8 $INSTALLRES |tail -1`
			echo "     $lineStr"

			echo "---------------------------------------------------------------"
			echo
		fi

#		echo
#		echo "---------------------------------------------------------------"
#		echo "     LanSafe Notification:"
#		echo "     If the openwin script is used to start the Open Look Window"
#		echo "     Manager (olwm) and the xnews X server, it will need to be"
#		echo "     started with the -nosunview switch in order for context"
#		echo "     senstive help to be enabled in the ls3X and ls3conX"
#		echo "     applications."
#		echo "---------------------------------------------------------------"
#		echo
#		read_one "Press ENTER to continue: "
#		echo
	fi

# Say goodbye
	if [ $ret = "TRUE" ]; then
		echo "---------------------------------------------------------------"
#		echo "     LanSafe was successfully installed on your system.     "
		lineStr=`head -$SUCCESS_INSTALLED_LS $INSTALLRES |tail -1`
		echo "     $lineStr"
		echo "---------------------------------------------------------------"
		echo
		echo
#		echo "Registration:"
		lineStr=`head -$REGISTRATION_STR1 $INSTALLRES |tail -1`
		echo "$lineStr"
		echo 
#		read_def "Would you like to register LanSafe now? (y/n) [y]" "y"
		lineStr=`head -$REGISTRATION_STR2 $INSTALLRES |tail -1`
		#MANTIS -2088
		#read_def "$lineStr (y/n) [y]" "y"

		case $answer in
		[yY]|[yY][eE][sS])
#			echo "Web browser may take a few seconds to start."
			#lineStr=`head -$WARN_WEB_BROWSER $INSTALLRES |tail -1`
			#echo "$lineStr"
			#exec netscape "http://www.powerware.com/Products/Software/reg_form.asp" &
			#echo
			lineStr=`head -$REGISTER_WEBSITE $INSTALLRES |tail -1`
			echo "$lineStr"
			;;
		*)
			lineStr=`head -$REGISTER_WEBSITE $INSTALLRES |tail -1`
			echo "$lineStr"
			;;
		esac
		
	else
		echo "-----------------------------------------------------------------------------"
#		echo "     WARNING: LanSafe was NOT successfully installed on your system.     "
		lineStr=`head -$UNSUCCESS_INSTALLED_LS $INSTALLRES |tail -1`
		echo "     $lineStr"
		echo "-----------------------------------------------------------------------------"
		echo
	fi

# Clean up
			if [ -z "$skip_cleanup" ]; then
				rm -rf `compute_tapedirs`
				rm -f install.sh
				rm -f agent.sh
#				rm -f picture.px
#				rm -f s1.objscr
				rm -f readLic
				rm -f license.txt
			fi

	if [ -f "$instpath"/Bin/Network.txt ]; then
		rm -f "$instpath"/Bin/Network.txt
	fi

}

main $1 $2 $3