- 论坛徽章:
- 0
|
各路大哥,
帮小弟看一下这个安装shell,现在的平台是aix的希望将它转成sco,谢谢.
#! /bin/sh # Set the default shell executable
:
init_shell=`echo $SHELL`
SHELL=/bin/sh
###############################################################################
#
# FILE : install
#
# INPUT : flags, install type
#
# OUTPUT : Installation directory, environment file
#
# DESCRIPTION : Install the specified product
# Be sure to have $INFORMIXDIR variable already set
# before calling this program.
#
# All required files are self extracted
# DATE : 01/03/98
# UPDATE :
# E.S :
###############################################################################
COPYRIGHT=""
SOCIETY="INFORMIX"
PRODNAME=" Informix Dynamic 4GL"
VERSION="3.00.1g"
SCRIPTVERSION="2.05.4h"
######################################################
# GLOBAL VARIABLE
######################################################
gbl_runner_created="FALSE" # global variable used to determine if the runner
# has been created
gbl_beta_flag_findlib=""
gbl_create_directory_ret="" # global variables used in create_directory function
gbl_backup_prod_flag="" # global variables used in backup_prod function
gbl_backup_prod_directory=""
gbl_backup_prod_file_name=""
gbl_backup_prod_save_directory=""
gbl_ask_ret="" # global variables used in ask function
gbl_create_menu_item_ret="" # global variables used in create_menu function
gbl_fmt_str_ret="" # global variables used in format_string function
gbl_echo_inline_beg_interp="" # global variables used in echo_inline
gbl_echo_inline_beg_inline=""
gbl_echo_inline_end_inline=""
gbl_echo_inline_flag_beg_inline=""
gbl_get_os_unix="" # global variable used in get_os function
gbl_get_os_unixver=""
gbl_get_os_unixcpu=""
gbl_get_os_esql_name=""
gbl_find_tar_file_tarFile="" # global variables used in find_tar_file
# function.
gbl_find_gzip_file_gpth="" # global variable used in find_gzip_file
# function.
gbl_lstFiles="" # global variables used for store path
gbl_majlstFiles=""
gbl_cdfile=""
gbl_majcdfile=""
gbl_majcdpth="OS/UNIX"
gbl_filetype=""
gbl_majfiletype=""
gbl_syspth=""
gbl_majsyspth=""
gbl_installpth="`dirname $0`" # global variables used to store the
# behind install.sh
gbl_initinstallpth="" # global variable
gbl_initpth="`pwd`" # global variable used to store the
# current directory when the install
# begin
gbl_instype="" # global variables used to store installation type
gbl_flg_df="" # global variables used with df command
gbl_flg_nodf=""
gbl_flg_nouname="" # global variable define to don't use uname
gbl_install_dir="" # global variables used for installation path
gbl_new_install_dir=""
gbl_comp="" # global variable used to store size to test on hdd
gbl_current_user=`id` # global variables used to store User ID
gbl_current_user1=`expr "$gbl_current_user" : "\(.*\) gid.*$"`
gbl_current_user_id=`expr "$gbl_current_user1" : ".*=\(.*\)(.*$"`
gbl_informixdir="" # global variable which store informixdir
gbl_flag_shell_debug="" # global variable used for shell debug
gbl_flg_debug=""
gbl_flg_breaking_the_wave="n" # global variable used for status of breaking_the_wave
gbl_flg_force_system="" # global variable used to force the system
gbl_find_cmd_flg_exist_cp="y" # global variables used in find_cmd
gbl_find_cmd_flg_exist_echo="y"
gbl_find_cmd_flg_exist_mv="y"
gbl_find_cmd_flg_exist_rm="y"
gbl_find_cmd_flg_exist_rmdir="y"
gbl_search_tty_the_thetty="" # global variables used in the function search_tty
gbl_search_tty_null=""
gbl_flg_tarFile="" # global variable specify if user insert tarFile
# name in the command line
gbl_giv_temp_dir="" # global variable to store the path to the
# temporary directory
gbl_flg_install="" # global variable specify if product can be
# installed or not
gbl_flg_findlib_stop="n" # global variable
gbl_read_get_space_drive_size_dir="" # global variable used in function read_get_space_drive
gbl_get_space_drive_value_test=""
gbl_test_ln_flg_exist_ln="" # global variable used in function test_ln
gbl_term_effect_bold="" # global variable used in the function bold_term
gbl_term_effect_reset=""
gbl_term_effect_underline=""
gbl_term_effect_used="FALSE"
gbl_envfile=""
gbl_envfile_shell=""
gbl_change_owner_test_owner_flag="FALSE" # global variable used in the function change_owner_test
gbl_change_owner_test_name_owner=""
gbl_change_owner_test_group_flag="FALSE"
gbl_change_owner_test_name_group=""
gbl_change_owner_test_chmod_flag="FALSE"
######################################################
# FUNCTION: echo_inline
#
# Parameters: none
#
# Returnings: none
#
# Comments : echo -n allow to put an echo in the same
# on the current and not on the newest.
# But on several UNIX this option is not
# available.
#
# Calling syntax: echo_inline
#
# Needed functions: none
#
# Variables: echo_inline
######################################################
echo_inline() {
echo_inline_a=""
gbl_echo_inline_beg_interp=""
gbl_echo_inline_beg_inline=""
gbl_echo_inline_end_inline=""
gbl_echo_inline_flag_beg_inline=""
echo_inline_a=`echo -n inline`
if [ "$echo_inline_a" = "-n inline" ]
then
gbl_echo_inline_beg_inline=""
gbl_echo_inline_end_inline="\\c"
gbl_echo_inline_flag_beg_inline=n
else
gbl_echo_inline_flag_beg_inline=y
gbl_echo_inline_beg_inline="-n"
gbl_echo_inline_end_inline=""
fi
echo_inline_a=`echo -e inline`
if [ "$echo_inline_a" = "-e inline" ]
then
gbl_echo_inline_beg_interp=""
else
gbl_echo_inline_beg_interp="-e"
fi
}
######################################################
# FUNCTION: search_tty
#
# Parameters: none
#
# Returnings: none
#
# Comments:
# When you have a file in entry in a shell. You
# can't use the same entry for input datas. This
# function search in the /dev/ the first tty.
# After that search, the null device, if not exist
# is created in $tmpdir
#
# Calling syntax: find_tty
#
# Needed functions: none
#
# Variable search_tty
#
# Modif:
#--------
#
# ES To support the go executable of
# 31/03/99 Autotest. I musn't redirect information
# from the tty.
######################################################
search_tty() {
search_tty_i=-1
gbl_search_tty_the_tty="/dev/tty"
while [ ! -c "$gbl_search_tty_the_tty" ]
do
search_tty_i=`expr $i + 1`
gbl_search_tty_the_tty=/dev/tty$i
done
if [ -c /dev/null -a -w /dev/null ]
then
gbl_search_tty_null=/dev/null
else
gbl_search_tty_null=$tmpdir/null
gbl_search_tty_flg_exist_null="n"
fi
if [ -n "$QAINSTALLGO" ]
then
gbl_redirect_read=""
else
gbl_redirect_read=" < $gbl_search_tty_the_tty"
fi
}
######################################################
# FUNCTION: term_effect
#
# Parameters: none
#
# Returnings: none
#
# Comments:
# This function can find if for the current
# term the bold argument can work
#
# Calling syntax: term_effect
#
# Needed functions: none
#
# Variable term_effect
######################################################
term_effect() {
if [ "$gbl_term_effect_used" = TRUE ]
then
case $TERM in
vt*|ansi*|con*|xterm*|linux*|screen*)
gbl_term_effect_bold="[1m"
gbl_term_effect_reset="[m"
gbl_term_effect_underline="[4m"
;;
*)
gbl_term_effect_bold=""
gbl_term_effect_reset=""
gbl_term_effect_underline=""
;;
esac
else
gbl_term_effect_bold=""
gbl_term_effect_reset=""
gbl_term_effect_underline=""
fi
}
###############################################################
# FUNCTION: strlen
#
# Parameters: string
#
# returnings: The length of the sent string
#
# Calling syntaxes: length=`strlen $STRING`
#
# Needed functions:
# - echo_inline : To define several variables
#
# Variable: strlen
################################################################
strlen(){
strlen_a=0
strlen_mess=""
strlen_a=`echo "$gbl_echo_inline_beg_inline" "$*" "$gbl_echo_inline_end_inline"|wc -c`
echo $strlen_a
}
######################################################
# FUNCTION: verify_file
#
# Parameters: $1 path or file to verify
# $2 verifcation type
# ISDIR | ISFILE |
# ISBLOCKDEVICE |
# ISCHARACTERDEVICE |
# ISREAD | ISWRITE | ISEXEC |ISALL
#
# Returnings: none
#
# Comments: verify a specified file
######################################################
verify_file() {
analyse_file="$1"
analyse_flag="test"
shift
while [ $# != 0 ]
do
case "$1" in
ISDIR)
analyse_flag="${analyse_flag} -d $analyse_file"
;;
ISFILE|ISNOFILE)
analyse_flag="${analyse_flag} -f $analyse_file"
;;
ISBLOCKDEVICE)
analyse_flag="${analyse_flag} -b $analyse_file"
;;
ISCHARACTERDEVICE)
analyse_flag="${analyse_flag} -c $analyse_file"
;;
ISREAD)
analyse_flag="${analyse_flag} -r $analyse_file"
;;
ISWRITE)
analyse_flag="${analyse_flag} -w $analyse_file"
;;
ISEXEC)
analyse_flag="${analyse_flag} -x $analyse_file"
;;
ISALL)
analyse_flag="${analyse_flag} -r $analyse_file -a -w $analyse_file -a -x $analyse_file"
;;
OR)
analyse_flag="${analyse_flag} -o"
;;
AND)
analyse_flag="${analyse_flag} -a"
;;
NO)
analyse_flag="${analyse_flag} !"
;;
*)
echo "Error: Unknown flag, $1"
;;
esac
shift
done
eval "$analyse_flag"
if [ $? = 0 ]
then
echo "TRUE"
else
echo "FALSE"
fi
}
#########################################################################
# FUNCTION Format string
#
# Parameters: Data type name [path|string]
#
# Returnings: The variable gbl_fmt_str_ret which contain the value
# of the formated strings.
#
# Comments: This function format a string to 74 characters max per
# display line.
#
# Variable: fmt_str
#
# Modif:
#---------
#
# ES The old long path display was made as follow:
# 19/12/98 /usr/var/bin/sbin/1/2/inst~
# Now the new display of the long path name is made as
# follow:
# ~/sbin/1/2/install.sh
#
# ES Instead to find \n using the "expr" statement, I use a local
# 21/12/98 variable with two values (TRUE \n is set, FALSE no \n).
# When I try put a ~ for the long path. The string length is
# is calculate automatically using "expr" statement, but I can
# receive a negative value. In this case, I use the "expr" statement
# to make an abs() on the length.
#
# ES If you have a string containing a big path and additional datas
# 01/04/99 sometimes there's a '\n' although the final data contains less
# than 80 characters.
# To correct this:
# if the string is less than 80 characters, I make a sed
# to replace '\n' by ' '.
#########################################################################
format_string() {
fmt_str_type="$1"
fmt_str_strlst="$2"
gbl_fmt_str_ret=""
fmt_str_flag="n"
fmt_str_bldstr=""
fmt_str_back_n="FALSE"
fmt_str_ret_with_return="FALSE"
for fmt_str_incr in $fmt_str_strlst
do
fmt_str_length1=`strlen "$fmt_str_bldstr"`
fmt_str_length2=`strlen "$fmt_str_incr"`
if [ `expr $fmt_str_length1 + $fmt_str_length2` -lt 74 ]
then
if [ -z "$fmt_str_bldstr" ]
then
fmt_str_bldstr="$fmt_str_incr"
else
if [ "$fmt_str_ret_with_return" = "TRUE" ]
then
fmt_str_ret_with_return="FALSE"
fmt_str_bldstr="${fmt_str_bldstr}$fmt_str_incr"
else
fmt_str_ret_with_return="FALSE"
fmt_str_bldstr="${fmt_str_bldstr} $fmt_str_incr"
fi
fi
else
fmt_str_flag="TRUE"
fi
if [ "$fmt_str_flag" = "TRUE" ]
then
if [ ! -z "$fmt_str_bldstr" ]
then
gbl_fmt_str_ret="${gbl_fmt_str_ret}$fmt_str_bldstr\\n "
fmt_str_ret_with_return="TRUE"
fi
fmt_str_bldstr="$fmt_str_incr"
fmt_str_flag="FALSE"
fi
done
gbl_fmt_str_ret="${gbl_fmt_str_ret} $fmt_str_bldstr"
fmt_str_gbl_fmt_str_ret_length=`strlen $gbl_fmt_str_ret`
fmt_str_item1=""
fmt_str_item2=""
fmt_str_item=""
for fmt_str_item in $gbl_fmt_str_ret
do
if [ `expr "$fmt_str_item" : "\(.\).*$"` = "/" ]
then
fmt_str_item1_length=`strlen $fmt_str_item1`
fmt_str_item_res=`expr 45 - $fmt_str_item1_length`
if [ $fmt_str_item_res -lt 0 ]
then
fmt_str_item_res=`expr $fmt_str_item_res \* -1`
fi
if [ $fmt_str_item_res -gt 1 ]
then
fmt_str_to_sed="s/^.*\("
fmt_str_count=0
while [ $fmt_str_count -lt $fmt_str_item_res ]
do
fmt_str_to_sed=${fmt_str_to_sed}"."
fmt_str_count=`expr $fmt_str_count + 1`
done
fmt_str_to_sed=${fmt_str_to_sed}"\)/~\1/"
fmt_str_item2=`echo "$fmt_str_item"|sed $fmt_str_to_sed`
fmt_str_item1=${fmt_str_item1}"$fmt_str_item2"
else
fmt_str_item1=${fmt_str_item1}"$fmt_str_item"" "
fi
else
fmt_str_item1=${fmt_str_item1}"$fmt_str_item"" "
fi
done
gbl_fmt_str_ret="$fmt_str_item1"
if [ `strlen "$gbl_fmt_str_ret"` -lt 51 ]
then
fmt_str_trans="$gbl_fmt_str_ret"
gbl_fmt_str_ret=`echo $fmt_str_trans | sed -e "s/\\\\\\n/ /g"`
fi
}
#########################################################################
# FUNCTION: display_data
#
# Parameters:
#
# Returnings:
#
# Comments:
#
# Variables: dsp_msg
#
# Modif:
# -------
#
# ES : On several Unix system the following statement doesn't
# 21/12/98 work:
# sed -e "s/\$VAR/$VAR1/g"
# To correct it use:
# sed -e 's/\$VAR/$VAR1/g'
########################################################################
display_data () {
FRISE=#######################################################################
TERROR="${gbl_term_effect_bold}ERROR ------------------------------------------------------------------${gbl_term_effect_reset}"
TWARNING="${gbl_term_effect_bold}WARNING ----------------------------------------------------------------${gbl_term_effect_reset}"
THELP="${gbl_term_effect_bold}HELP -------------------------------------------------------------------${gbl_term_effect_reset}"
TEND="${gbl_term_effect_bold}------------------------------------------------------------------------${gbl_term_effect_reset}"
dsp_msg_points=".........................................................."
dsp_msg_opt="$1"
if [ "$dsp_msg_opt" = error -o "$dsp_msg_opt" = warning ]
then
shift
else
dsp_msg_msg="$2"
fi
dsp_msg_incr=1
case "$dsp_msg_opt" in
inln)
##########################
# Calling example:
# ----------------
# dsp_dsp_msg_msg inln "dsp_msg_msgage"
##########################
# Set the length of the string and display it.
# --------------------------------------------
if [ "$gbl_echo_inline_flag_beg_inline" = y ]
then
echo "$gbl_echo_inline_beg_inline" $dsp_msg_entry_bldstr
else
echo $dsp_msg_entry_bldstr "$gbl_echo_inline_end_inline"
fi
;;
intrp)
##########################
# Calling example:
# ----------------
# dsp_dsp_msg_msg intrp "dsp_msg_msgage"
##########################
echo "${gbl_echo_inline_beg_interp}" $dsp_msg_msg
;;
normal)
############################
# Calling example:
# ----------------
# dsp_dsp_msg_msg normal "dsp_msg_msgage"
############################
# This a simple display (dummy)
# -----------------------------
echo $dsp_msg_msg
;;
entry)
###############################################################################################
# Calling example:
# ----------------
# dsp_dsp_msg_msg entry "dsp_msg_msgage" [skip|noskip|syes|yes] [cancel|no_canel] [inln|intrp] [help|nohelp]
###############################################################################################
# Variable allocation
#---------------------
dsp_msg_entry_type="$3" # Answer type like y, n, s
dsp_msg_cancel="$4" # Flag cancel set cancel or no_cancel
dsp_msg_entry_help="$5" # This variable is set to help to display "help" for an help
# dsp_msg_msgage or no_help
# DEBUG MESSAGE
# -------------
#echo "dsp_msg_entry_type: $dsp_msg_entry_type"
#echo "dsp_msg_cancel: $dsp_msg_cancel"
#echo "dsp_msg_entry_help: $dsp_msg_entry_help"
# Work on the string containing the value "(y|n|c|s|?)"
# -----------------------------------------------------
dsp_msg_entry_skip_flag="y"
# Firstly, i set the "(" at the beginning of the string
# -----------------------------------------------------
# if [ `expr "$dsp_msg_msg" : "\(.\).*$"` = "\/" ]
if [ `strlen "$dsp_msg_msg"` -gt 44 ]
then
format_string path "$dsp_msg_msg"
dsp_msg_entry_bldstr="Options: ($gbl_fmt_str_ret"
else
dsp_msg_entry_bldstr="Options: ("
fi
# Secondly, I set the different possible answer in my string.
# -----------------------------------------------------------
case "$dsp_msg_entry_type" in
skip)
dsp_msg_entry_bldstr="$dsp_msg_entry_bldstr"
;;
noskip)
dsp_msg_entry_skip_flag="n"
;;
syes|yes)
if [ "$dsp_msg_entry_type" = yes ]
then
dsp_msg_entry_skip_flag="n"
fi
dsp_msg_entry_bldstr="$dsp_msg_entry_bldstr"" [Y]es | [N]o"
;;
esac
# The character "c" is set only if the user can abort the installation,
# for this question.
# ---------------------------------------------------------------------
if [ "$dsp_msg_entry_cancel_flag" = n -o "$dsp_msg_cancel" != no_cancel ]
then
if [ ! -z "$dsp_msg_entry_bldstr" -a "$dsp_msg_entry_bldstr" != "Options: (" ]
then
dsp_msg_entry_bldstr=$dsp_msg_entry_bldstr" | [C]ancel"
else
dsp_msg_entry_bldstr=$dsp_msg_entry_bldstr" VALUE | [C]ancel"
fi
fi
# The character "s" is set only if the user can skip this part.
# -------------------------------------------------------------
if [ "$dsp_msg_entry_skip_flag" = y ]
then
dsp_msg_entry_bldstr="$dsp_msg_entry_bldstr | [S]kip"
fi
# The character "?" is set only if the user can have an help.
# -----------------------------------------------------------
if [ "$dsp_msg_entry_help" = help ]
then
dsp_msg_entry_bldstr=$dsp_msg_entry_bldstr" | ?) "
#dsp_msg_entry_bldstr=$dsp_msg_entry_bldstr" "
else
dsp_msg_entry_bldstr=$dsp_msg_entry_bldstr" "
fi
# In the last step, I set the default value sending to the function.
# ------------------------------------------------------------------
if [ ! -z "$dsp_msg_msg" ]
then
if [ `strlen "$dsp_msg_msg"` -gt 44 ]
then
if [ `expr "$dsp_msg_msg" : "\(.\).*$"` = "/" ]
then
dsp_msg_param="path"
else
dsp_msg_param="string"
fi
format_string $dsp_msg_param "$dsp_msg_msg"
dsp_msg_msg="$gbl_fmt_str_ret"
fi
dsp_msg_entry_bldstr="$dsp_msg_entry_bldstr\n""Default: [$dsp_msg_msg]\t "
else
dsp_msg_entry_bldstr="$dsp_msg_entry_bldstr\n""Default: [no default]\t "
fi
# Display section of the string.
# ------------------------------
if [ "$gbl_echo_inline_flag_beg_inline" = y ]
then
if [ ! -z "$gbl_echo_inline_beg_interp" ]
then
echo $gbl_echo_inline_beg_interp $gbl_echo_inline_beg_inline $dsp_msg_entry_bldstr
else
echo "$gbl_echo_inline_beg_inline" $dsp_msg_entry_bldstr
fi
else
if [ ! -z "$gbl_echo_inline_beg_interp" ]
then
echo "$gbl_echo_inline_beg_interp" $dsp_msg_entry_bldstr "$gbl_echo_inline_end_inline"
else
echo $dsp_msg_entry_bldstr "$gbl_echo_inline_end_inline"
fi
fi
;;
error|warning)
echo
if [ "$dsp_msg_opt" = error ]
then
cat << EOF
$TERROR
$*
$TEND
EOF
else
cat << EOF
$TWARNING
$*
$TEND
EOF
fi
;;
error1|warning1)
#####################################
# Calling example:
# ----------------
# dsp_dsp_msg_msg [error|warning] "dsp_msg_msgage"
#####################################
# Firstly, a beep is made.
# ------------------------
echo
format_string string "$dsp_msg_msg"
# I made the display. Two types of display can be created an error box or
# a warning box.
# -----------------------------------------------------------------------
if [ "$dsp_msg_opt" = error ]
then
echo $TERROR
else
echo $TWARNING
fi
# The string is displayed.
# ------------------------
if [ -z "$gbl_echo_inline_beg_interp" ]
then
echo "$gbl_fmt_str_ret"
echo $TEND
else
echo "$gbl_echo_inline_beg_interp" "$gbl_fmt_str_ret"
echo "$gbl_echo_inline_beg_interp" $TEND \\n
fi
;;
help)
case "$dsp_msg_msg" in
noskip_insert)
cat << EOF
HELP - MSG001 -
------------------
The installation procedure is asking to insert a value. You can choose
to answer "c" if you want to abort the installation procedure.
To see this help answer "?".
EOF
;;
noskip_cancel)
cat << EOF
HELP - MSG002 -
---------------
The installation procedure is asking you to answer by "y" (Yes) or "n" (No)
to the question specify in the text below. You can choose to answer "c" if
you want to abort the installation procedure.
To see this help answer "?".
EOF
;;
esac
;;
res)
#########################
# Calling example:
# ----------------
# dsp_dsp_msg_msg res "dsp_msg_msgage"
#########################
# Display a dsp_msg_msgage and the result of the action.
# -----------------------------------------------
# Add the point to the dsp_msg_msgage
# -----------------------------
if [ `strlen "$dsp_msg_msg"` -gt 44 ]
then
format_string path "$dsp_msg_msg"
dsp_msg_msg="$gbl_fmt_str_ret"
dsp_msg_res_preresline=`expr "$gbl_fmt_str_ret" : ".*\\\\\n\(.*\)$"`
if [ ! -z "$dsp_msg_res_preresline" ]
then
if [ "$dsp_msg_res_preresline" != 0 ]
then
dsp_msg_res_str="$dsp_msg_res_preresline$dsp_msg_points"
else
dsp_msg_res_preresline=""
dsp_msg_res_str="$dsp_msg_msg$dsp_msg_points"
fi
else
dsp_msg_res_str="$dsp_msg_msg$dsp_msg_points"
fi
else
dsp_msg_res_preresline=""
dsp_msg_res_str="$dsp_msg_msg$dsp_msg_points"
fi
# Substract the point to the string.
# ----------------------------------
dsp_msg_res_resline=`expr "$dsp_msg_res_str" : "\(..................................................\).*"`
if [ ! -z "$dsp_msg_res_preresline" ]
then
dsp_msg_res_resline1=`echo "$gbl_fmt_str_ret"|sed -e 's/\$dsp_msg_res_preresline/$dsp_msg_res_resline/g'`
dsp_msg_res_resline="$dsp_msg_res_resline1"
fi
# Set the diffrent flag needed to display the dsp_msg_msgage
# ---------------------------------------------------
if [ -z "$gbl_echo_inline_beg_interp" ]
then
if [ "$gbl_echo_inline_flag_beg_inline" = y ]
then
echo "$gbl_echo_inline_beg_inline" "$dsp_msg_res_resline "
else
echo "$dsp_msg_res_resline " "$gbl_echo_inline_end_inline"
fi
else
if [ "$gbl_echo_inline_flag_beg_inline" = y ]
then
echo "$gbl_echo_inline_beg_interp" "$gbl_echo_inline_beg_inline" "$dsp_msg_res_resline "
else
echo "$gbl_echo_inline_beg_interp" "$dsp_msg_res_resline " "$gbl_echo_inline_end_inline"
fi
fi
# Reset the variable points
# -------------------------
dsp_msg_points=""
;;
title)
############################
# Calling example:
# ----------------
# display_data title "dsp_msg_msg"
###########################
# Display a title display_data.
# -------------------------
# Display a line a special characters before the string.
# ------------------------------------------------------
echo $FRISE
# The string is centered to the screen.
# -------------------------------------
dsp_msg_title_incr=0
dsp_msg_title_line=""
lgth=`strlen $dsp_msg_msg`
if [ $lgth -lt 72 ]
then
flength=`expr 72 - $lgth`
flength=`expr $flength / 2`
while [ $dsp_msg_title_incr != $flength ]
do
dsp_msg_title_line=" "$dsp_msg_title_line
dsp_msg_title_incr=`expr $dsp_msg_title_incr + 1`
done
dsp_msg_title_line=$dsp_msg_title_line$dsp_msg_msg
else
format_string string "$dsp_msg_msg"
dsp_msg_title_line="$gbl_fmt_str_ret"
fi
# Display the title using the specified option.
# ---------------------------------------------
if [ ! -z "$gbl_echo_inline_beg_interp" ]
then
echo "$gbl_echo_inline_beg_interp" "$dsp_msg_title_line"
echo "$gbl_echo_inline_beg_interp" $FRISE \\n
else
echo "$dsp_msg_title_line"
echo $FRISE \\n
fi
;;
*)
####################
# Calling example:
# ----------------
# display_data
####################
# make an echo without value
# ---------------------------
echo ""
;;
esac
dsp_msg_opt=""
dsp_msg_msg=""
dsp_msg_entry_bldstr=""
}
##############################################################################
# FUNCTION: ask
#
# Parameters: $1 Question type [field|yes_no]
# $2 Message
# $3 Default value
# $4 inln, intrp or normal
# $5 cancel specify the calling function
# $6 NULL or no_help specify if help is needed for this
# entry
# Returnings: none
#
# Comments: Ask something to user
#
# Variable: ask
#
# Modif:
# -------
# ES New flag $6 (ask_no_help_needed), this flag specify if the
# ASK00 entry can be used with a help file or no.
#
# ES Vicious BUG:
# 01/04/99 ------------
# In several cases user could answer "Abort" in this case the
# ASK01 the same function is called within it self. But at this time
# user could answer that he don't want to cancel, so the abort
# function should be ended and go back in the previous question.
# But the function go back in the previous question but after
# return in the abort function and close the installation.
# To correct this bug, I add an additional test which specify
# to quit the ask function if the user do not want to quit
# "abort" installation procedure.
#
# ES
# 06/04/99 Vicious BUG:
# ------------
# One line steel already exist and bug the previous correction.
# ASK02 To correct this I should remove the line.
#
##############################################################################
ask () {
ask_flag="FALSE" # User must input an answer
ask_type="$1" # This is the type of question
ask_mess="$2" # Message for the question
ask_def_val="$3" # Default value
ask_flag_mess="$4"
ask_calling_function_name="$5"
# ASK00
ask_no_help_needed="$6"
# End ASK00
# DEBUG MESSAGE:
# --------------
#echo "ask_flag: $ask_flag"
#echo "ask_type: $ask_type"
#echo "ask_mess: $ask_mess"
#echo "ask_def_val: $ask_def_val"
#echo "ask_flag_mess: $ask_flag_mess"
#echo "ask_calling_function_name: $ask_calling_function_name"
#echo "ask_no_help_needed: $ask_no_help_needed"
if [ -z "$ask_calling_function_name" ]
then
ask_save_type="$ask_type"
ask_save_mess="$ask_mess"
ask_save_def_val="$ask_def_val"
ask_save_flag_mess="$ask_flag_mess"
ask_save_cancel_installation_function="$ask_calling_function_name"
ask_save_no_help_needed="$ask_no_help_needed"
fi
while [ "$ask_flag" = "FALSE" ] # User must input an answer
do
display_data # Display a blank line before question
display_data $ask_flag_mess "$ask_mess" # Message is displayed
if [ "$ask_type" = field ] # If user shouldnt input boolean (Y|N|C)
then
if [ ! -z "$ask_no_help_needed" ]
then
display_data entry "$ask_def_val" noskip cancel nohelp # Display the second part of the message
else
display_data entry "$ask_def_val" noskip cancel help # Display the second part of the message
fi
eval "read gbl_ask_ret $gbl_redirect_read" # read the input from tty
case "$gbl_ask_ret" in # Analyse the answer
"?"|h|H) # User want see help
if [ ! -z "$ask_no_help_needed" ]
then
ask_flag="TRUE"
else
display_data help noskip_insert
ask_flag="FALSE"
gbl_ask_ret=""
fi
;;
C|c) # User want cancel the application
cancel_installation
ask_flag="FALSE"
;;
`[ -z "$gbl_ask_ret" ]`) # User want the default value
gbl_ask_ret="$ask_def_val"
ask_flag="TRUE"
;;
*) # Answer of user
ask_flag="TRUE"
;;
esac
else
case "$ask_calling_function_name" in
cancel_installation)
display_data entry "$ask_def_val" yes no_cancel nohelp
;;
*)
if [ ! -z "$ask_no_help_needed" ]
then
display_data entry "$ask_def_val" yes cancel nohelp
else
display_data entry "$ask_def_val" yes cancel help
fi
;;
esac
eval "read gbl_ask_ret $gbl_redirect_read" # Read the answer
case "$gbl_ask_ret" in # Analyse the answer
Y|y) # User said yes
ask_flag="TRUE"
gbl_ask_ret="Y"
;;
`[ -z "$gbl_ask_ret" ]`) # User hit enter and
# by this way want the default value
gbl_ask_ret="$ask_def_val"
ask_flag="TRUE"
;;
N|n) # User said no
ask_flag="TRUE"
gbl_ask_ret="N"
;;
"?"|h|H) # User want to see help
if [ ! -z "$ask_no_help_needed" ]
then
display_data error "Invalid answer"
ask_flag="FALSE"
else
display_data help noskip_cancel
ask_flag="FALSE"
fi
;;
C|c)
cancel_installation # User want cancel the application
ask_flag="FALSE"
;;
*) # User said an invalid answer
display_data error "Invalid answer"
ask_flag="FALSE"
;;
esac
fi
if [ ! -z "$ask_calling_function_name" -a ! -z "$ask_save_type" ]
then
if [ "$ask_calling_function_name" = "cancel_installation" -a "$gbl_ask_ret" = "Y" ]
then
ask_flag="TRUE"
ask_type=""
ask_mess=""
ask_def_val=""
ask_flag_mess=""
ask_calling_function_name=""
ask_no_help_needed=""
ask_save_type=""
ask_save_mess=""
ask_save_def_val=""
ask_save_flag_mess=""
ask_save_cancel_installation_function=""
ask_save_no_help_needed=""
else
# ASK01
if [ "$ask_calling_function_name" = "cancel_installation" ]
then
ask_flag="TRUE"
else
ask_flag="FALSE"
fi
# End ASK01
ask_type="$ask_save_type"
ask_mess="$ask_save_mess"
ask_def_val="$ask_save_def_val"
ask_flag_mess="$ask_save_flag_mess"
ask_calling_function_name=""
# ASK02
# ask_flag="FALSE"
# End ASK02
ask_no_help_needed="$ask_save_no_help_needed"
fi
else
if [ "$ask_flag" = FALSE ]
then
ask_type="$ask_save_type"
ask_mess="$ask_save_mess"
ask_def_val="$ask_save_def_val"
ask_flag_mess="$ask_save_flag_mess"
ask_calling_function_name=""
ask_flag="FALSE"
ask_no_help_needed="$ask_save_no_help_needed"
else
if [ "$ask_flag" = "TRUE" ]
then
ask_flag="TRUE"
ask_type=""
ask_mess=""
ask_def_val=""
ask_flag_mess=""
ask_calling_function_name=""
ask_no_help_needed=""
ask_save_type=""
ask_save_mess=""
ask_save_def_val=""
ask_save_flag_mess=""
ask_save_cancel_installation_function=""
ask_save_no_help_needed=""
fi
fi
fi
done
}
######################################################
# FUNCTION: create_menu
#
# Parameters: use_separator flag (allows to use white space in menu)
# return_item_number | return_item_name
# Menu title (default value: MENU TITLE)
# Answer comment (default value: Input something)
# List to make a menu from
#
# Returnings: none
#
# Comments: Create a menu from a list
#
# Variable: create_menu
#
#
# Modif:
#---------
#
# ES On HPUX, if you make en expr and this does not
# 20/02/99 evaluate the regular expression instead of
# returning NULL value 0 is returned.
# To correct this bug I change the line
# with:
# if [ ! -z "$a" ]
# by
# if [ ! -z "$a" -a "$a" != 0 ]
#
# ES change the simple read by an eval of the
# 31/03/99 read statement.
######################################################
create_menu() {
create_menu_separator="$1" # Specify if the white space is in the menu name or not
shift
create_menu_return_type="$1" # Specify the return type, item number or item name
shift
create_menu_title="$1" # The first argument is always the menu title
shift
if [ "$create_menu_title" = "#" -o -z "$create_menu_title" ] # If the first argument is NULL or '#' set the default
then # value
create_menu_title="MENU TITLE"
fi
create_menu_answer_comments="$1" # This label before the answer field
shift
if [ "$create_menu_answer_comments" = "#" -o -z "$create_menu_answer_comments" ] # Same way that the menu title
then
create_menu_answer_comments="Input something"
fi
create_menu_item_flag="FALSE" # First while flag: FALSE User must insert a value
gbl_create_menu_item_ret="" # Variable in which the value is stored after input
create_menu_counter=0 # Loop create_menu_counter
create_menu_itemlst="" # Variable use only in the for loop
create_menu_item_counter="" # Variable in which the user answer is stored
create_menu_construct=""
while [ $# != 0 ]
do
create_menu_itemlst="$1"
create_menu_counter=`expr $create_menu_counter + 1`
if [ "$create_menu_separator" = use_separator ]
then
create_menu_new_itemlst1="`echo $create_menu_itemlst|sed -e 's/_SPACE_/ /g'`"
create_menu_new_itemlst="`echo $create_menu_new_itemlst1|sed -e 's/_TAB_/\\\t/g'`"
create_menu_itemlst="$create_menu_new_itemlst"
fi
create_menu_construct="$create_menu_construct""\n""$create_menu_counter --- $create_menu_itemlst"
shift
done
create_menu_item_counter=1
while [ "$create_menu_item_flag" = FALSE ] # User must answer something
do
display_data "" # Display a blank line before the menu
display_data title "$create_menu_title" # Display the menu title
display_data intrp "$create_menu_construct" # Display the different item
display_data normal ""
display_data inln "Choose one type" # Text display to screen before user input
display_data entry "1" noskip cancel inln help # Several user key activated.
eval "read create_menu_item_counter $gbl_redirect_read"
case $create_menu_item_counter in
"?"|h|H) # User hit h for more help
display_data help noskip_insert
create_menu_item_flag="FALSE"
create_menu_item_counter=""
;;
C|c) # User want to cancel
cancel_installation
create_menu_item_flag=FALSE
create_menu_item_counter=""
;;
`[ -z "$create_menu_item_counter" ]`) # User hit enter key
create_menu_item_counter=1
create_menu_item_flag=TRUE
;;
*) # Something has been entered
a=`expr $create_menu_item_counter : ".*\([a-zA-Z]\).*"` 2>;$gbl_search_tty_null # Regular expression used to find Letter in strings
if [ ! -z "$a" -a "$a" != "0" ]
then
display_data error "Invalid answer: Answer must be only a numric character"
create_menu_item_flag="FALSE"
create_menu_item_counter=""
else
b=`expr $create_menu_item_counter - $create_menu_counter` 2>;$gbl_search_tty_null # Regular expression used to see if user hit a value
# bigger than the last item raw
if [ $b -gt 0 ]
then
display_data error "Invalid answer: Anwer should be between 1 and $create_menu_counter"
create_menu_item_flag="FALSE"
create_menu_item_counter=""
else
create_menu_item_flag="TRUE"
fi
fi
;;
esac
if [ "$create_menu_item_flag" != "FALSE" ] # if the previous control is ok
then
gbl_create_menu_item_ret=""
if [ "$create_menu_return_type" = "return_item_number" ] # Return only the item raw number
then
gbl_create_menu_item_ret="$create_menu_item_counter"
else # Return the item name
for create_menu_itemlst in $create_menu_item_list
do
create_menu_counter=`expr $create_menu_counter + 1`
if [ $create_menu_item_counter = $create_menu_counter ]
then
gbl_create_menu_item_ret="$create_menu_itemlst"
fi
break
done
fi
if [ ! -z "$gbl_create_menu_item_ret" ] # If the variable gbl_create_menu_item_ret is NULL
then # in this case the program cannot exit from the
create_menu_item_flag="TRUE" # while loop
else
create_menu_item_flag="FALSE"
fi
fi
done
}
######################################################
# FUNCTION: check_user_name
#
# Parameters: none
#
# Returnings: none
#
# Comments: Check the user id
#
# Variable: check_user_name
######################################################
check_user_name(){
if [ "$gbl_current_user_id" != 0 ]
then
check_user_name_rep_flag="FALSE"
display_data res "Current user is "
display_data intrp "Not SUPERUSER"
while [ "$check_user_name_rep_flag" = FALSE ]
do
display_data warning "With this user some administration operations will be skipped."
ask "yes_no" "Do you want to continue to install the product?" "Y" normal
check_user_name_rep="$gbl_ask_ret"
if [ "$check_user_name_rep" != Y ]
then
cancel_installation
check_user_name_rep_flag="FALSE"
else
check_user_name_rep_flag="TRUE"
fi
done
else
display_data res "Current user is"
display_data intrp "SUPERUSER"
fi
display_data
}
######################################################
# FUNCTION: change_owner_test
#
# Parameters: none
#
# Returnings: none
#
# Comments: Check the user id
#
# Variable: change_owner_test
#
# MODIF:
# ------
#
# ES Now chgrp and chown can be made only
# 24/02/1999 by a user an id of 0 ( normally root )
######################################################
change_owner_test () {
cd $tmpdir
mkdir $tmpdir/ownertest
echo "test" >; $tmpdir/ownertest/zz
if [ "$gbl_current_user_id" = 0 ]
then
display_data res "Checking command chown for this user"
if [ "$SOCIETY" = "Four J's Development Tools" -o -z "$SOCIETY" ]
then
chown -R fourjs $tmpdir/ownertest/zz 1>;$gbl_search_tty_null 2>;$gbl_search_tty_null
if [ $? != 0 ]
then
chown -R informix $tmpdir/ownertest/zz 1>;$gbl_search_tty_null 2>;$gbl_search_tty_null
if [ $? != 0 ]
then
gbl_change_owner_test_owner_flag="FALSE"
gbl_change_owner_test_name_owner=""
display_data intrp "Not available"
else
gbl_change_owner_test_name_owner="informix"
gbl_change_owner_test_owner_flag="TRUE"
display_data intrp "Ok"
fi
else
gbl_change_owner_test_name_owner="fourjs"
gbl_change_owner_test_owner_flag="TRUE"
display_data intrp "Ok"
fi
else
chown -R informix $tmpdir/ownertest/zz 1>;$gbl_search_tty_null 2>;$gbl_search_tty_null
if [ $? != 0 ]
then
gbl_change_owner_test_name_owner=""
gbl_change_owner_test_owner_flag="FALSE"
display_data intrp "Not available"
else
gbl_change_owner_test_name_owner="informix"
gbl_change_owner_test_owner_flag="TRUE"
display_data intrp "Ok"
fi
fi
display_data res "Checking chgrp command for this user"
chgrp -R informix $tmpdir/ownertest 1>;$gbl_search_tty_null 2>;$gbl_search_tty_null
if [ $? != 0 ]
then
gbl_change_owner_test_name_group=""
gbl_change_owner_test_group_flag="FALSE"
display_data intrp "Not available"
else
gbl_change_owner_test_name_group="informix"
gbl_change_owner_test_group_flag="TRUE"
display_data intrp "Ok"
fi
else
gbl_change_owner_test_owner_flag="FALSE"
gbl_change_owner_test_group_flag="FALSE"
fi
display_data res "Checking command chmod for this user"
chmod -R 0777 $tmpdir/ownertest 1>;$gbl_search_tty_null 2>;$gbl_search_tty_null
if [ $? != 0 ]
then
gbl_change_owner_test_chmod_flag="FALSE"
display_data intrp "Not available"
else
gbl_change_owner_test_chmod_flag="TRUE"
display_data intrp "Ok"
fi
}
######################################################
# FUNCTION: change_owner
#
# Parameters: none
#
# Returnings: none
#
# Comments: Change the owner on the distribution
#
# Variable: change_owner
# Modif:
# -------
# ES On several system if you change owner and right on the
# 23/04/1999 Directory $FGLDIR/lock the licence could not work
# properly.
# MAIN000 To resolv this problem I should delete the lock directory
# before call the function change_owner.
# ES
# 28/05/1999 Instead of delete the directory $FGLDIR/lock, I give the
# MAIN001 0777 to correct bug of licence
######################################################
change_owner () {
if [ "$gbl_change_owner_test_chmod_flag" = "TRUE" ]
then
cd $gbl_install_dir
display_data res "Setting permissions on \$FGLDIR"
chmod -R 0755 $gbl_install_dir 1>;$gbl_search_tty_null 2>;$gbl_search_tty_null
if [ $? != 0 ]
then
display_data intrp "Not changed"
else
display_data intrp "Changed"
fi
# BEGIN -- MAIN000
if [ `verify_file $gbl_install_dir/lock ISDIR` = TRUE ]
then
display_data res "Changing right for lock directory"
# BEGIN -- MAIN001
chmod -R 0777 $gbl_install_dir/lock 2>;$gbl_search_tty_null 1>;$gbl_search_tty_null
if [ $? = 0 ]
then
display_data intrp "Right changed"
else
display_data intrp "Right cannot be changed"
display_data warning " lease give the right 0777 manually to the directory \$FGLDIR/lock"
fi
# END -- MAIN001
fi
# END -- MAIN000
fi
if [ "$gbl_change_owner_test_owner_flag" = "TRUE" ]
then
cd $gbl_install_dir
display_data res "Applying owner $gbl_change_owner_test_name_owner for FGLDIR"
chown -R "$gbl_change_owner_test_name_owner" $gbl_install_dir 1>;$gbl_search_tty_null 2>;$gbl_search_tty_null
if [ $? != 0 ]
then
display_data intrp "Not changed"
else
display_data intrp "Changed"
fi
fi
if [ "$gbl_change_owner_test_group_flag" = "TRUE" ]
then
cd $gbl_install_dir
display_data res "Applying group $gbl_change_owner_test_name_group for FGLDIR"
chgrp -R "$gbl_change_owner_test_name_group" $gbl_install_dir 1>;$gbl_search_tty_null 2>;$gbl_search_tty_null
if [ $? != 0 ]
then
display_data intrp "Not changed"
else
display_data intrp "Changed"
fi
fi
}
#########################################################################
# FUNCTION: manage_file_or directory
#
# Parameters: $1 ->; type of command cp, mv, rm
# $2 ->; File or directory name
# $3 ->; Destination, if necessary
# Returnings: none
#
# Comments : Manage three operations on manage_file_or_directory_file or
# directory.
#
# Calling syntax:
# manage_file_direcrtory [copy|create|delete|move] file_name manage_file_or_directory_destination
#
# Needed functions:
# - display_data: For the display
# - find_cmd: To fix several variables.
#
# Variable: manage_file_or_directory
#########################################################################
manage_file_or_directory(){
manage_file_or_directory_operation=$1
manage_file_or_directory_file=$2
manage_file_or_directory_destination=$3
manage_file_or_directory_rmfile_dir=""
manage_file_or_directory_RM="rm"
case "$manage_file_or_directory_operation" in
copy)
if [ "$gbl_find_cmd_flg_exist_cp" = y ]
then
cp $manage_file_or_directory_file $manage_file_or_directory_destination 1>;$gbl_search_tty_null 2>;$gbl_search_tty_null
if [ $? != 0 ]
then
display_data error "Unable to copy $manage_file_or_directory_file into\n$manage_file_or_directory_destination"
manage_file_or_directory_flg_status="n"
fi
else
if [ "$gbl_find_cmd_flg_exist_mv" = y ]
then
mv $manage_file_or_directory_file $manage_file_or_directory_destination 1>;$gbl_search_tty_null 2>;$gbl_search_tty_null
if [ $? != 0 ]
then
display_data error "Unable to copy $manage_file_or_directory_file into $manage_file_or_directory_destination"
manage_file_or_directory_flg_status="n"
fi
else
display_data error "Unable to copy $manage_file_or_directory_file into $manage_file_or_directory_destination: System command is missing"
manage_file_or_directory_flg_status="n"
fi
fi
;;
create)
mkdir $manage_file_or_directory_file 1>;$gbl_search_tty_null 2>;$gbl_search_tty_null
if [ $? != 0 ]
then
display_data error "Unable to create $manage_file_or_directory_file\nMkdir: command is missing or permission denied."
breaking_the_wave
else
display_data res $manage_file_or_directory_file
display_data intrp "Successfully Created"
fi
;;
link)
if [ "$gbl_test_ln_flg_exist_ln" = y ]
then
ln -s $manage_file_or_directory_file $manage_file_or_directory_destination
if [ $? != 0 ]
then
manage_file_or_directory_flg_link="n"
else
manage_file_or_directory_flg_link="y"
fi
fi
if [ $manage_file_or_directory_flg_link = "n" ]
then
display_data error "Unable to execute \"ln -s $manage_file_or_directory_file $manage_file_or_directory_destination\""
cp $manage_file_or_directory_file $manage_file_or_directory_destination
if [ $? != 0 ]
then
display_data error "Unable to execute \"cp $manage_file_or_directory_file $manage_file_or_directory_destination\""
display_data normal "After installation, please type \"cp $manage_file_or_directory_file $manage_file_or_directory_destination\""
fi
fi
;;
move)
if [ "$gbl_find_cmd_flg_exist_mv" = y ]
then
mv $manage_file_or_directory_file $manage_file_or_directory_destination 1>;$gbl_search_tty_null 2>;$gbl_search_tty_null
if [ $? != 0 ]
then
display_data error "Unable to move $manage_file_or_directory_file into $manage_file_or_directory_destination"
manage_file_or_directory_flg_status="n"
fi
else
if [ "$gbl_find_cmd_flg_exist_cp" = y ]
then
cp $manage_file_or_directory_file $manage_file_or_directory_destination 1>;$gbl_search_tty_null 2>;$gbl_search_tty_null
if [ $? != 0 ]
then
display_data error "Unable to copy $manage_file_or_directory_file into $manage_file_or_directory_destination"
manage_file_or_directory_flg_status="n"
fi
else
display_data error "Unable to move $manage_file_or_directory_file into $manage_file_or_directory_destination: System command is missing."
manage_file_or_directory_flg_status="n"
fi
fi
;;
delete|delete_directory)
if [ -z "$manage_file_or_directory_RM" ]
then
if [ "$gbl_find_cmd_flg_exist_rmdir" = y -a "$manage_file_or_directory_operation" = delete_directory ]
then
manage_file_or_directory_RM="rmdir"
else
manage_file_or_directory_RM="rm"
fi
fi
if [ "$manage_file_or_directory_operation" = delete_directory -a "$manage_file_or_directory_RM" = rm ]
then
manage_file_or_directory_flag_rm="-rf"
else
if [ "$manage_file_or_directory_RM" = rm ]
then
manage_file_or_directory_flag_rm="-f"
else
manage_file_or_directory_flag_rm=""
fi
fi
manage_file_or_directory_rmfile_dir="$manage_file_or_directory_file"
if [ "$gbl_find_cmd_flg_exist_rm" = y ]
then
$manage_file_or_directory_RM $manage_file_or_directory_flag_rm $manage_file_or_directory_rmfile_dir 1>;$gbl_search_tty_null 2>;$gbl_search_tty_null
if [ $? != 0 ]
then
display_data intrp "Unable to delete"
manage_file_or_directory_flg="n"
while [ "$manage_file_or_directory_flg" = n ]
do
ask "field" " erhaps, you have a modified rm command.\nPlease give the complete path to real rm command." "`type rm`" intrp
manage_file_or_directory_RM="$gbl_ask_ret"
if [ `verify_file "$manage_file_or_directory_RM" NO ISFILE` = TRUE ]
then
manage_file_or_directory_flg="n"
display_data error "Unable to find $manage_file_or_directory_RM in PATH environment variable."
else
manage_file_or_directory_flg="y"
fi
done
if [ `expr "$manage_file_or_directory_RM" : "\(.\).*$` = / -o `expr "$RM" : "\(.\).*$` = . ]
then
if [ `basename $manage_file_or_directory_RM` != rmdir ]
then
if [ "$manage_file_or_directory_operation" = delete_directory ]
then
manage_file_or_directory_flag_rm="-rf"
else
manage_file_or_directory_flag_rm="-f"
fi
else
manage_file_or_directory_flag_rm=""
fi
else
if [ "$manage_file_or_directory_RM" != rmdir ]
then
if [ "$manage_file_or_directory_operation" = delete_directory ]
then
manage_file_or_directory_flag_rm="-rf"
else
manage_file_or_directory_flag_rm="-f"
fi
else
manage_file_or_directory_flag_rm=""
fi
fi
display_data res "$manage_file_or_directory_rmfile_dir"
$manage_file_or_directory_RM $manage_file_or_directory_flag_rm $manage_file_or_directory_rmfile_dir 1>;$gbl_search_tty_null 2>;$gbl_search_tty_null
if [ $? != 0 ]
then
display_data intrp "Unable to delete"
display_data res "Moving $manage_file_or_directory_rmfile_dir in $gbl_search_tty_null"
if [ "$gbl_find_cmd_flg_exist_mv" = y -a "$gbl_search_tty_flg_exist_null" = y ]
then
mv $manage_file_or_directory_rmfile_dir $gbl_search_tty_null 2>;$gbl_search_tty_null
if [ $? != 0 ]
then
display_data intrp "Unable to move"
display_data error "Unable to delete manage_file_or_directory_file from $manage_file_or_directory_rmfile_dir"
manage_file_or_directory_flg_status="n"
else
display_data intrp "Successfully Moved"
fi
else
display_data intrp "Unable to move"
fi
else
display_data intrp "Successfully Deleted"
fi
else
display_data intrp "Successfully Deleted"
fi
else
if [ "$gbl_find_cmd_flg_exist_mv" = y -a "$gbl_search_tty_flg_exist_null" = y ]
then
mv $manage_file_or_directory_rmfile_dir $gbl_search_tty_null 1>;$gbl_search_tty_null
if [ $? != 0 ]
then
display_data intrp "Unable to move"
display_data error "Unable to delete manage_file_or_directory_file from $manage_file_or_directory_rmfile_dir"
manage_file_or_directory_flg_status="n"
else
display_data intrp "Successfully Deleted"
fi
else
display_data intrp "Unable to delete"
display_data error "Unable to delete $manage_file_or_directory_rmfile_dir: System command is missing"
manage_file_or_directory_flg_status="n"
fi
fi
;;
esac
}
############################################################################
# FUNCTION: manage_tmpdir
#
# Parameters:
# create_tmpdir -->; to create a temporary directory
# clean_tmpdir -->; to delete a temporary directory
#
# cp_file_into_tmpdir -->; to copy a file into the directory
# ex: manage_tmpdir cp_file_into_tmpdir /mypath/myfile
#
# rm_file_into_tmpdir -->; to delete a file into the directory
# ex: manage_tmpdir rm_file_into_tmpdir /mypath/myfile
#
# Returnings: none
#
# Comments:
# In this function, there's all management
# of the tmp directory
#
# Calling syntax:
# manage_tmpdir PARAMETERS [ file_name ]
#
# Needed functions:
# - manage_file_or_directory : To used cp, mv, rm commands
# - display_data : To display message
#
# Variables: manage_tmpdir
############################################################################
manage_tmpdir(){
manage_tmpdir_i=-1
case $1 in
create_tmpdir)
if [ -z "$gbl_giv_temp_dir" ]
then
if [ ! -z "$DBTEMP" ]
then
manage_tmpdir_pretmpdir="$DBTEMP"
else
manage_tmpdir_pretmpdir="/tmp"
fi
else
manage_tmpdir_pretmpdir="$gbl_giv_temp_dir"
fi
tmpdir="$manage_tmpdir_pretmpdir/install"
while [ `verify_file $tmpdir ISDIR OR ISFILE` = TRUE ]
do
manage_tmpdir_i=`expr $manage_tmpdir_i + 1`
tmpdir="$manage_tmpdir_pretmpdir/install$manage_tmpdir_i"
done
mkdir $tmpdir
display_data res "Creating $tmpdir"
if [ $? != 0 ]
then
display_data intrp "Unable to create"
exit 1
else
display_data intrp "Ok"
fi
chmod 0755 $tmpdir
if [ $? != 0 ]
then
display_data
display_data error "Unable to change permissions to $tmpdir"
exit 1
fi
;;
cp_file_into_tmpdir)
if [ -z "$3" ]
then
manage_tmpdir_cp_file_destination="$tmpdir"
else
manage_tmpdir_cp_file_destination="$3"
fi
manage_file_or_directory "copy" $2 $manage_tmpdir_cp_file_destination
;;
rm_file_into_tmpdir)
manage_file_or_directory "delete" $2 $tmpdir
;;
clean_tmpdir)
if [ `verify_file "$tmpdir" ISDIR` = TRUE ]
then
cd $tmpdir
cd ..
for i in $tmpdir/*
do
display_data res "Deleting $i"
if [ `verify_file "$i" ISDIR` = TRUE ]
then
manage_file_or_directory "delete_directory" $i
else
manage_file_or_directory "delete" $i
fi
done
display_data res "Deleting temporaries files"
manage_file_or_directory "delete_directory" $tmpdir
fi
;;
esac
}
######################################################
# FUNCTION: cancel_installation
#
# Parameters: none
#
# Returnings: none
#
# Comments: This function is called when an exit
#
# Calling syntax: cancel_installation
#
# Needed functions: ask
# breaking_the_wave
# Variables: cancel_installation
######################################################
cancel_installation() {
ask "yes_no" "Aborting installation program. Do you really want to abort? " "N" normal cancel_installation no_help
cancel_installation_answer="$gbl_ask_ret"
if [ "$cancel_installation_answer" = Y ]
then
breaking_the_wave
exit 1
fi
}
############################################################################
# FUNCTION: breaking_the_wave
#
# Parameters: none
#
# Returnings: none
#
# Comments: This function is called when an exit
# is made or ctrl-c
#
# Calling syntax: breaking_the_wave
#
# Needed functions:
# - display_data : To display messages.
# - manage_tmpdir: To delete several files
# Variable: breaking_the_wave
#############################################################################
breaking_the_wave() {
trap '' 1 2 3 5 15
breaking_the_wave_line=""
display_data
display_data
if [ "$gbl_flg_end_install" = n ]
then
if [ "$gbl_flg_end_install" = n -a ! -z "$gbl_install_dir" ]
then
if [ `verify_file "$gbl_install_dir" ISDIR` = TRUE -a `verify_file "$gbl_install_dir" ISFILE` = FALSE ]
then
cd $gbl_install_dir
cd ..
breaking_the_wave_line=""
if [ ! -z "$tmpdir" -a `verify_file "$tmpdir/cpfiles" ISFILE` = TRUE ]
then
while read breaking_the_wave_line
do
if [ `verify_file "$breaking_the_wave_line" ISFILE` = TRUE -a ! -z "$breaking_the_wave_line" ]
then
display_data res "Deleting $breaking_the_wave_line"
manage_file_or_directory "delete" $breaking_the_wave_line
fi
breaking_the_wave_line=""
done < $tmpdir/cpfiles
fi
breaking_the_wave_line=""
if [ ! -z "$tmpdir" -a `verify_file "$tmpdir"/dirfiles ISFILE` = TRUE ]
then
while read breaking_the_wave_line
do
display_data normal ""
if [ `verify_file "$breaking_the_wave_line" ISDIR` = TRUE -a ! -z "$breaking_the_wave_line" ]
then
display_data res "Deleting $breaking_the_wave_line"
manage_file_or_directory "delete_directory" $breaking_the_wave_line
fi
done < $tmpdir/dirfiles
fi
if [ "$gbl_new_install_dir" = true -a `verify_file "$tmpdir"/already_created ISFILE` = TRUE -a `verify_file "$tmpdir"/firstone ISFILE` = TRUE -a ! -z "$tmpdir" ]
then
read togo < $tmpdir/already_created
read firstone < $tmpdir/firstone
cd $togo
todelete=$togo/$firstone
if [ `verify_file "$todelete" ISDIR` = TRUE -a ! -z "$todelete" ]
then
display_data res $todelete
manage_file_or_directory "delete_directory" $todelete
else
display_data error "Unable to delete $todelete"
fi
else
if [ "$gbl_new_install_dir" = true ]
then
display_data res "Deleting $gbl_install_dir"
rm -rf $gbl_install_dir 1>;$gbl_search_tty_null 2>;$gbl_search_tty_null
if [ $? = 0 ]
then
display_data intrp "Successfully Deleted"
else
display_data intrp "Unable to delete"
fi
fi
fi
fi
fi
fi
if [ ! -z "$gbl_backup_prod_flag" -a "$gbl_flg_end_install" = n -a "$gbl_backup_prod_flag" = Y -o "$gbl_backup_prod_flag" = y ]
then
if [ -d "$gbl_backup_prod_directory"/"$gbl_backup_prod_save_directory" -a ! -z "$gbl_backup_prod_directory" -a ! -z "$gbl_backup_prod_save_directory" ]
then
if [ ! -z "$gbl_backup_prod_file_name" ]
then
cd /
tar xvf $gbl_backup_prod_directory/$gbl_backup_prod_save_directory/$gbl_backup_prod_file_name 2>;$gbl_search_tty_null 1>;$gbl_search_tty_null
if [ $? != 0 ]
then
display_data
display_data error " roblem during file extraction procedure"
display_data
else
display_data res "Old version"
display_data intrp "Successfully Backed up"
fi
fi
fi
fi
flg_breaking_the_wave="y"
rm -f $tmpdir/size 1>;$gbl_search_tty_null 2>;$gbl_search_tty_null
if [ ! -z "$tmpdir" ]
then
if [ `verify_file "$tmpdir" ISDIR` = TRUE ]
then
cd $tmpdir
cd ..
manage_tmpdir clean_tmpdir
fi
fi
if [ "$gbl_flg_end_install" = n -o -z "$gbl_flg_end_install" ]
then
if [ -z "$gbl_umask_var" ]
then
umask $gbl_umask_var 1>;$gbl_search_tty_null 2>;$gbl_search_tty_null
fi
exit 1
fi
}
trap 'breaking_the_wave' 1 2 3 15
######################################################
# FUNCTION: read_get_space_drive
#
# Parameters: none
#
# Returnings: none
#
# Comments: Search for available space on drive
#
# Variable: read_get_space_drive
######################################################
read_get_space_drive () {
read_get_space_drive_cpt=1
# Some Os like HP-UX or dgux display the result of the df command
# at the first line.
if [ "$gbl_get_os_unix" = HP-UX -o "$gbl_get_os_unix" = dgux ]
then
read_get_space_drive_first="n"
else
read_get_space_drive_first="y"
fi
while read $readline read_get_space_drive_line
do
if [ "$read_get_space_drive_first" = n ]
then
for read_get_space_drive_i in $read_get_space_drive_line
do
if [ $read_get_space_drive_cpt = $gbl_get_space_drive_value_test ]
then
read_get_space_drive_test=`expr "$read_get_space_drive_i" : "\(.\)*$"`
if [ "$read_get_space_drive_test" != ":" ]
then
gbl_read_get_space_drive_size_dir=$read_get_space_drive_i
else
gbl_get_space_drive_value_test=`expr $gbl_get_space_drive_value_test + 1`
fi
fi
read_get_space_drive_cpt=`expr $read_get_space_drive_cpt + 1`
done
else
read_get_space_drive_first="n"
fi
done
}
#Debug-4js-11
##############################################################################
# FUNCTION: get_space_drive
#
# Parameters: string which contain the name of directory
#
# Returnings: none
#
# Comments: Search for available space on drive
#
# Calling Syntax:
# get_space_drive $DIRECTORY
#
# Needed function:
# - display_data : To display several messages
# - read_get_space_drive: To analyse the size
#
# Modif:
#--------
#
# Modif by E.S: - Adding support of UnixWare 7
# 15/05/1999
######### |
|