#!/bin/sh
CMDNAME=`basename $0`
p1=$1
p2=$2
allps=$@
usage()
{
echo "Usage: `basename $0` <options>"
echo "<options> may be:"
echo " --help show this help, then exit"
echo " -i [ swing | console ] specify the user interface mode for the installer"
echo " -D<name>=<value> specify installer properties"
exit 0
}
setup_chooser()
{
if [ x"$p1" = x"--help" ];then
usage
elif [ x"$p2" = x"console" ];then
unset DISPLAY
setup_graphic
else
setup_graphic
fi
}
setup_graphic()
{
echo "Now launch installer..."
work_horse="setup/install.bin"
if [ ! -x "$work_horse" ];then
chmod u+x "$work_horse"
fi
IFCN=`echo $LANG | grep CN`
if [ x"$IFCN" != x"" ];then
lang="-l zh_CN"
else
lang="-l en"
fi
if [ x"$allps" = x"" ];then
"$work_horse" $lang | tee .installer.log
else
"$work_horse" $lang $allps |tee .installer.log
fi
retvalue=$?
result=`cat .installer.log | grep "JRE libraries are missing or not compatible" | wc -l`
if [ $retvalue -eq 232 ];then
echo Installation is canceled .
else
if [ $result != "0" ];then
echo "This installer is not compatible with the CPU's architecture."
fi
if [ $retvalue -eq 0 -o $retvalue -eq 1 ];then
echo Complete.
else
echo Installation failed .
fi
fi
rm -rf .installer.log
exit $retvalue
}
# check user
check_user(){
user_id=`id -u`
if [ $user_id -eq 0 ];then
echo "Current user is ROOT."
echo "Please re-run the installer as Non-Root user."
exit 10
fi
}
# check integrity of installer
check_integrity(){
setup_home="`dirname $0`/setup"
cd $setup_home
if [ ! -f install.bin ];then
exit 11
fi
if [ ! -f MD5 ];then
exit 12
fi
md5sum -c MD5 >/dev/null 2>&1
if [ "$?" -eq 0 ];then
cd ..
else
echo "Current installer has been damaged."
echo "Integrity check failed,the installer was damaged,please get an integrated copy of the product!"
cd ..
exit 13
fi
}
# check whether current user has installed KingbaseEM product
current_installer_version=V3
check_installed(){
if [ -s /etc/kingbaseem ];then
install_dir=`awk -F: {'print $1'} /etc/kingbaseem | head -n1`
install_version=`awk -F: {'print $2'} /etc/kingbaseem | head -n1`
install_type=`awk -F: {'print $3'} /etc/kingbaseem | head -n1`
if [ x"$current_installer_version" = x"$install_version" ];then
echo "KingbaseEM V$current_installer_version has been installed already."
echo "Install Path is $install_dir."
echo "Install Type is $install_type."
echo "Type Ctrl-C to exit, and Enter to continue!"
read hello
else
if [ x"$install_dir" != x"" ];then
installed_user=$(ls -dl $install_dir|awk -F" " '{print $3}')
current_user=$(id -un)
if [ x"$installed_user" = x"$current_user" ];then
echo "An another version of KingbaseEM has been installed already."
echo "Install Path is $install_dir."
echo "Type Ctrl-C to exit, and Enter to continue!"
read hello
fi
fi
fi
fi
}
check_encoding()
{
old_lang="$LANG"
$country
echo "$old_lang" |grep "\." >/dev/null
if [ $? -eq 0 ];then
country=`echo $old_lang | awk -F . '{print $1}'`
fi
new_lang="UTF-8"
echo $LANG |grep "$new_lang" >/dev/null
if [ $? -ne 0 ];then
if [ x"$country" = x"" ];then
LANG="UTF-8"
else
LANG="${country}.UTF-8"
fi
export LANG
if [ $? -ne 0 ];then
echo "The linux system does not support UTF-8 encoding,installation can not proceed."
exit 15
fi
fi
}
check_os()
{
os_name=`lsb_release -i`
os_ver=`lsb_release -r | awk '{print $2}' | awk -F. '{print $1}'`
if ! echo $os_name | grep -qi 'RedHat'; then
echo "This package only support RHEL 6.x"
exit 1
fi
if [ "x$os_ver" != "x6" ]; then
echo "This package only support RHEL 6.x"
exit 1
fi
}
#check_os
check_user
check_integrity
#check_encoding
#check_installed
setup_chooser
# That's the end.
评论5