#!/bin/sh

test `uname -s` = Linux && echocmd="echo -e" || echocmd="echo"

yorn ()
{
        YN=b
        while [ "$YN" != "n" -a "$YN" != "no" -a \
                "$YN" != "N" -a "$YN" != "NO" -a \
                "$YN" != "y" -a "$YN" != "yes" -a \
                "$YN" != "Y" -a "$YN" != "YES" -a \
                "$YN" != "Yes" -a "$YN" != "No" ]; do
                $echocmd $1
                read YN
                if [ "$YN" = "y" -o "$YN" = "yes" -o "$YN" = "Yes" -o \
                     "$YN" = "Y" -o "$YN" = "YES" ]; then
                        return 1
                fi
                if [ "$YN" = "n" -o "$YN" = "no" -o "$YN" = "No" -o \
                     "$YN" = "N" -o "$YN" = "NO" ]; then
                        return 0
                fi
                $echocmd "y または n を入力してください"
        done
}

#
# Detect if we have been called from a Fixpack installation.
#
FIXPACK_INSTALL=n
if [ "$1" = "Fixpack_Install" ]; then
	FIXPACK_INSTALL=y
fi

if test ! -w /etc/passwd
then
	$echocmd "root でなければこのスクリプトは実行できません"
        exit 1
fi

if [ ".$COBDIR" = "." ]; then
	$echocmd "正しい製品のディレクトリを指す COBDIR の設定が必要です。"
        $echocmd "終了します..."
        exit 1
fi


umask 000

#default PATH for BIN
DEFBIN=/usr/bin

BINFILES="cas3270 casdump casdup casfile casinfo cassi casstart casstop"
cd $COBDIR
BASE=`pwd`/etc/cas
TXDIR=$BASE


if [ "$FIXPACK_INSTALL" = "n" ]; then
$echocmd "続行する前に、Enterprise Server のシステム管理者用の英数字のユーザー ID を"
$echocmd "手元に準備しているか確認してください。"

$echocmd "詳細は、マニュアル「構成と管理」に記述されています。\n"
$echocmd "終了するには、'q' を、続行するには、改行を押してください。: \c"
read cont
if test "$cont" = "q"
then
    exit 2
fi


#
# Setup the defaults and store in the global config file - $TXDIR/cas.cfg
#

$echocmd "\n\n次に続く質問に答えながら、グローバルトランザクションシステム"
$echocmd "構成ファイル(cas.cfg)を構築します。- 詳細はマニュアル"
$echocmd "「構成と管理」を参照してください。\n"

cd $BASE
yorn "エラーや警告メッセージを syslog デーモンから表示しますか? \n(y/n): \c"
res=$?
$echocmd "###########################################################" > .defts
$echocmd "### Transaction System Global/Region Configuration File ###" >> .defts
$echocmd "###########################################################" >> .defts
$echocmd "###              global only directives                 ###" >> .defts
case "$res" in
        1)  $echocmd "USESYSCON=Y" >> .defts
        ;;
        0)      $echocmd "USESYSCON=N" >> .defts
        ;;
esac

#
# Ask for the System Administrator user id
#

t=1
until test $t = 0
do
    $echocmd "\nEnterprise Server のシステム管理者用の英数字のユーザー ID を\n入力してください。: \c"
    read SYSADMIN
        if [ "$SYSADMIN" = "" ]; then
        SYSADMIN=baduser
        fi
	id $SYSADMIN >/dev/null 2>/dev/null
	t=$?
        if test $t -ne 0
        then
            $echocmd "\n指定された Enterprise Server のシステム管理者用のユーザー ID は"
            $echocmd "割当てられていないか、英数字ではありません。UNIX システム管理者に"
            $echocmd "割当ててもらうか、別のユーザー ID を指定してください。\n"
        fi
done
else
#
# Determine the System Administrator user id
#
SYSADMIN=`ls -l $TXDIR/cas.cfg | awk '{print $3}'`
if [ "x$SYSADMIN" = "x" ]; then
  $echocmd "$0: エラー: システム管理者用のユーザー ID を確定できませんでした。"
  $echocmd "\n**** 警告 Enterprise Server の構成は完了していません。\n"
  $echocmd "Enterprise Server の構成を完了するには、このエラーを修正し"
  $echocmd "'cd $COBDIR; sh ./bin/casperm’と入力して実行してください。"
  exit 1
fi
fi

ID=id
GID=`$ID -g $SYSADMIN`

DEFUSER=$GID
DEFDEV=$GID
DEFADMIN=$GID
DEFOPER=$GID

if [ "$FIXPACK_INSTALL" = "n" ]; then
cd $BASE
$echocmd "AUTHPGMS=" >> .defts

$echocmd "\nEnterprise Server 実行時システムファイルをコピーするディレクトリを"
$echocmd "絶対パス名で入力してください。環境変数は使用できません。"
$echocmd "/var/mfcobol/es にコピーする場合は、RETURN キーを押してください。"
read casrtdir
if [ "x$casrtdir" = "x" ]; then
casrtdir=/var/mfcobol/es
fi

$echocmd "CASROOT=$casrtdir" >> .defts

$echocmd "###              other directives                       ###" >> .defts

$echocmd "###########################################################" >> .defts
mv .defts cas.cfg
chown $SYSADMIN cas.cfg
fi

if [ "$FIXPACK_INSTALL" = "n" ]; then
grep '^SX/5.0/COBOL/5.0/Install/WORK$' $COBDIR/etc/mfreg.dat 1>/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
cat >>$COBDIR/etc/mfreg.dat <<EOF
SX/5.0/COBOL

SX/5.0/COBOL/Version
5.0
SX/5.0/COBOL/5.0/Install

SX/5.0/COBOL/5.0/Install/WORK
$casrtdir
EOF
fi
fi

cd $COBDIR
#cp files/sys/dfhrdef.cfg files/sys/dfhdev.cfg files/sys/dfhpcbon.cfg files/sys/dfhpcrem.cfg files/sys/dfhmon.cfg files/sys/advscrns.cfg $COBDIR
#cp files/sys/wbcob370.dir files/sys/wbdosvs.dir files/sys/wbosvs.dir files/sys/wbvsc21.dir files/sys/wbvsc22.dir files/sys/wbvsc23.dir files/sys/wbvsc24.dir $COBDIR

#
# Set correct group ownership
#
$echocmd "\nファイルパーミッションを設定中です。お待ちください..."

# TOP -- Moved from bottom -- 2006/09/26 ck
for i in cas3270 cascnvim casrdtex imtkmake mfcs casfile casstart cobimtk mfdepinst casmq casrdtup eslm casdump casstop mfds casinfo cassi casdup
do
if [ -f "$COBDIR/bin/.$i" ]; then
rm $COBDIR/bin/$i
mv $COBDIR/bin/.$i $COBDIR/bin/$i
fi
done
# END -- Moved from bottom -- 2006/09/26 ck

if [ -f $COBDIR/lib/cascfg.so ]; then
chgrp $DEFADMIN $COBDIR/lib/cascfg.so
chmod 755  $COBDIR/lib/cascfg.so
chown $SYSADMIN $COBDIR/lib/cascfg.so
else
$echocmd $COBDIR/lib/cascfg.so - not found.
fi
if [ -f $COBDIR/lib/dfhextfh.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhextfh.so
chmod 755  $COBDIR/lib/dfhextfh.so
chown $SYSADMIN $COBDIR/lib/dfhextfh.so
else
$echocmd $COBDIR/lib/dfhextfh.so - not found.
fi
if [ -f $COBDIR/lib/dfherdio.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfherdio.so
chmod 755  $COBDIR/lib/dfherdio.so
chown $SYSADMIN $COBDIR/lib/dfherdio.so
else
$echocmd $COBDIR/lib/dfherdio.so - not found.
fi
if [ -f $COBDIR/lib/dfhff.so ]; then
chgrp $DEFADMIN $COBDIR/lib/dfhff.so
chmod 755  $COBDIR/lib/dfhff.so
chown $SYSADMIN $COBDIR/lib/dfhff.so
else
$echocmd $COBDIR/lib/dfhff.so - not found.
fi
if [ -f $COBDIR/lib/dfhpmgen.so ]; then
chgrp $DEFADMIN $COBDIR/lib/dfhpmgen.so
chmod 755  $COBDIR/lib/dfhpmgen.so
chown $SYSADMIN $COBDIR/lib/dfhpmgen.so
else
$echocmd $COBDIR/lib/dfhpmgen.so - not found.
fi
if [ -f $COBDIR/lib/dfhpcgen.so ]; then
chgrp $DEFADMIN $COBDIR/lib/dfhpcgen.so
chmod 755  $COBDIR/lib/dfhpcgen.so
chown $SYSADMIN $COBDIR/lib/dfhpcgen.so
else
$echocmd $COBDIR/lib/dfhpcgen.so - not found.
fi
if [ -f $COBDIR/lib/dfhppgen.so ]; then
chgrp $DEFADMIN $COBDIR/lib/dfhppgen.so
chmod 755  $COBDIR/lib/dfhppgen.so
chown $SYSADMIN $COBDIR/lib/dfhppgen.so
else
$echocmd $COBDIR/lib/dfhppgen.so - not found.
fi
if [ -f $COBDIR/lib/dfherdcv.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfherdcv.so
chmod 755  $COBDIR/lib/dfherdcv.so
chown $SYSADMIN $COBDIR/lib/dfherdcv.so
else
$echocmd $COBDIR/lib/dfherdcv.so - not found.
fi
if [ -f $COBDIR/lib/dfhregns.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhregns.so
chmod 755  $COBDIR/lib/dfhregns.so
chown $SYSADMIN $COBDIR/lib/dfhregns.so
else
$echocmd $COBDIR/lib/dfhregns.so - not found.
fi
if [ -f $COBDIR/lib/dfhpmfio.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhpmfio.so
chmod 755  $COBDIR/lib/dfhpmfio.so
chown $SYSADMIN $COBDIR/lib/dfhpmfio.so
else
$echocmd $COBDIR/lib/dfhpmfio.so - not found.
fi
if [ -f $COBDIR/lib/dfhxinit.so ]; then
chgrp $DEFADMIN $COBDIR/lib/dfhxinit.so
chmod 755  $COBDIR/lib/dfhxinit.so
chown $SYSADMIN $COBDIR/lib/dfhxinit.so
else
$echocmd $COBDIR/lib/dfhxinit.so - not found.
fi
if [ -f $COBDIR/lib/cicsecm.so ]; then
chgrp $DEFADMIN $COBDIR/lib/cicsecm.so
chmod 755  $COBDIR/lib/cicsecm.so
chown $SYSADMIN $COBDIR/lib/cicsecm.so
fi
if [ -f $COBDIR/lib/dfhmon.so ]; then
chgrp $DEFADMIN $COBDIR/lib/dfhmon.so
chmod 755  $COBDIR/lib/dfhmon.so
chown $SYSADMIN $COBDIR/lib/dfhmon.so
else
$echocmd $COBDIR/lib/dfhmon.so - not found.
fi
if [ -f $COBDIR/lib/_mfpreld.so ]; then
chown $SYSADMIN $COBDIR/lib/_mfpreld.so
else
$echocmd $COBDIR/lib/_mfpreld.so - not found.
fi
if [ -f $COBDIR/lib/dfhmoclr.so ]; then
chgrp $DEFADMIN $COBDIR/lib/dfhmoclr.so
chmod 755  $COBDIR/lib/dfhmoclr.so
chown $SYSADMIN $COBDIR/lib/dfhmoclr.so
else
$echocmd $COBDIR/lib/dfhmoclr.so - not found.
fi
if [ -f $COBDIR/bin/casdup32 ]; then
chgrp $DEFOPER  $COBDIR/bin/casdup32
chmod 750 $COBDIR/bin/casdup32
chown $SYSADMIN $COBDIR/bin/casdup32
else
$echocmd $COBDIR/bin/casdup32 - not found.
fi
if [ -f $COBDIR/bin/casdup ]; then
chgrp $DEFOPER  $COBDIR/bin/casdup
chmod 750 $COBDIR/bin/casdup
chown $SYSADMIN $COBDIR/bin/casdup
else
$echocmd $COBDIR/bin/casdup - not found.
fi
if [ -f $COBDIR/bin/casinfo32 ]; then
chgrp $DEFOPER  $COBDIR/bin/casinfo32
chmod 750 $COBDIR/bin/casinfo32
chown $SYSADMIN $COBDIR/bin/casinfo32
else
$echocmd $COBDIR/bin/casinfo32 - not found.
fi
if [ -f $COBDIR/bin/casinfo ]; then
chgrp $DEFOPER  $COBDIR/bin/casinfo
chmod 750 $COBDIR/bin/casinfo
chown $SYSADMIN $COBDIR/bin/casinfo
else
$echocmd $COBDIR/bin/casinfo - not found.
fi
if [ -f $COBDIR/bin/cassrvtm32 ]; then
chgrp $DEFOPER  $COBDIR/bin/cassrvtm32
chmod 750 $COBDIR/bin/cassrvtm32
chown $SYSADMIN $COBDIR/bin/cassrvtm32
else
$echocmd $COBDIR/bin/cassrvtm32 - not found.
fi
if [ -f $COBDIR/bin/caspdied32 ]; then
chgrp $DEFOPER  $COBDIR/bin/caspdied32
chmod 750 $COBDIR/bin/caspdied32
chown $SYSADMIN $COBDIR/bin/caspdied32
else
$echocmd $COBDIR/bin/caspdied32 - not found.
fi
if [ -f $COBDIR/bin/cascd32 ]; then
chgrp $DEFOPER  $COBDIR/bin/cascd32
chmod 750 $COBDIR/bin/cascd32
chown $SYSADMIN $COBDIR/bin/cascd32
else
$echocmd $COBDIR/bin/cascd32 - not found.
fi
if [ -f $COBDIR/bin/casmgr32 ]; then
chgrp $DEFOPER  $COBDIR/bin/casmgr32
chmod 750 $COBDIR/bin/casmgr32
chown $SYSADMIN $COBDIR/bin/casmgr32
else
$echocmd $COBDIR/bin/casmgr32 - not found.
fi
if [ -f $COBDIR/bin/casfile32 ]; then
chgrp $DEFOPER  $COBDIR/bin/casfile32
chmod 750 $COBDIR/bin/casfile32
chown $SYSADMIN $COBDIR/bin/casfile32
else
$echocmd $COBDIR/bin/casfile32 - not found.
fi
if [ -f $COBDIR/bin/casfile ]; then
chgrp $DEFOPER  $COBDIR/bin/casfile
chmod 750 $COBDIR/bin/casfile
chown $SYSADMIN $COBDIR/bin/casfile
else
$echocmd $COBDIR/bin/casfile - not found.
fi
if [ -f $COBDIR/bin/casstart32 ]; then
chgrp $DEFOPER  $COBDIR/bin/casstart32
chmod 750 $COBDIR/bin/casstart32
chown $SYSADMIN $COBDIR/bin/casstart32
else
$echocmd $COBDIR/bin/casstart32 - not found.
fi
if [ -f $COBDIR/bin/casstart ]; then
chgrp $DEFOPER  $COBDIR/bin/casstart
chmod 750 $COBDIR/bin/casstart
chown $SYSADMIN $COBDIR/bin/casstart
else
$echocmd $COBDIR/bin/casstart - not found.
fi
if [ -f $COBDIR/bin/casstop32 ]; then
chgrp $DEFOPER  $COBDIR/bin/casstop32
chmod 750 $COBDIR/bin/casstop32
chown $SYSADMIN $COBDIR/bin/casstop32
else
$echocmd $COBDIR/bin/casstop32 - not found.
fi
if [ -f $COBDIR/bin/casstop ]; then
chgrp $DEFOPER  $COBDIR/bin/casstop
chmod 750 $COBDIR/bin/casstop
chown $SYSADMIN $COBDIR/bin/casstop
else
$echocmd $COBDIR/bin/casstop - not found.
fi
if [ -f $COBDIR/lib/dfheappc.so ]; then
chgrp $DEFADMIN $COBDIR/lib/dfheappc.so
chmod 755  $COBDIR/lib/dfheappc.so
chown $SYSADMIN $COBDIR/lib/dfheappc.so
else
$echocmd $COBDIR/lib/dfheappc.so - not found.
fi
if [ -f $COBDIR/lib/dfhgerr.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhgerr.so
chmod 755  $COBDIR/lib/dfhgerr.so
chown $SYSADMIN $COBDIR/lib/dfhgerr.so
else
$echocmd $COBDIR/lib/dfhgerr.so - not found.
fi
if [ -f $COBDIR/lib/dfhgreq.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhgreq.so
chmod 755  $COBDIR/lib/dfhgreq.so
chown $SYSADMIN $COBDIR/lib/dfhgreq.so
else
$echocmd $COBDIR/lib/dfhgreq.so - not found.
fi
if [ -f $COBDIR/lib/casgreqt.so ]; then
chgrp $DEFOPER  $COBDIR/lib/casgreqt.so
chmod 755  $COBDIR/lib/casgreqt.so
chown $SYSADMIN $COBDIR/lib/casgreqt.so
else
$echocmd $COBDIR/lib/casgreqt.so - not found.
fi
if [ -f $COBDIR/lib/casgate.so ]; then
chgrp $DEFOPER  $COBDIR/lib/casgate.so
chmod 755  $COBDIR/lib/casgate.so
chown $SYSADMIN $COBDIR/lib/casgate.so
else
$echocmd $COBDIR/lib/casgate.so - not found.
fi
if [ -f $COBDIR/bin/casdump32 ]; then
chgrp $DEFADMIN $COBDIR/bin/casdump32
chmod 750 $COBDIR/bin/casdump32
chown $SYSADMIN $COBDIR/bin/casdump32
else
$echocmd $COBDIR/bin/casdump32 - not found.
fi
if [ -f $COBDIR/bin/casdump ]; then
chgrp $DEFADMIN $COBDIR/bin/casdump
chmod 750 $COBDIR/bin/casdump
chown $SYSADMIN $COBDIR/bin/casdump
else
$echocmd $COBDIR/bin/casdump - not found.
fi
if [ -f $COBDIR/lib/dfhgerr2.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhgerr2.so
chmod 755  $COBDIR/lib/dfhgerr2.so
chown $SYSADMIN $COBDIR/lib/dfhgerr2.so
else
$echocmd $COBDIR/lib/dfhgerr2.so - not found.
fi
if [ -f $COBDIR/lib/dfhgini2.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhgini2.so
chmod 755  $COBDIR/lib/dfhgini2.so
chown $SYSADMIN $COBDIR/lib/dfhgini2.so
else
$echocmd $COBDIR/lib/dfhgini2.so - not found.
fi
if [ -f $COBDIR/bin/casmq32 ]; then
chgrp $DEFADMIN $COBDIR/bin/casmq32
chmod 750 $COBDIR/bin/casmq32
chown $SYSADMIN $COBDIR/bin/casmq32
else
$echocmd $COBDIR/bin/casmq32 - not found.
fi
if [ -f $COBDIR/bin/cas327032 ]; then
chgrp $DEFADMIN $COBDIR/bin/cas327032
chmod 750 $COBDIR/bin/cas327032
chown $SYSADMIN $COBDIR/bin/cas327032
else
$echocmd $COBDIR/bin/cas327032 - not found.
fi
if [ -f $COBDIR/bin/cas3270 ]; then
chgrp $DEFADMIN $COBDIR/bin/cas3270
chmod 750 $COBDIR/bin/cas3270
chown $SYSADMIN $COBDIR/bin/cas3270
else
$echocmd $COBDIR/bin/cas3270 - not found.
fi
if [ -f $COBDIR/bin/casfshr32 ]; then
chgrp $DEFOPER  $COBDIR/bin/casfshr32
chmod 750 $COBDIR/bin/casfshr32
chown $SYSADMIN $COBDIR/bin/casfshr32
else
$echocmd $COBDIR/bin/casfshr32 - not found.
fi
if [ -f $COBDIR/bin/casjcp32 ]; then
chgrp $DEFOPER  $COBDIR/bin/casjcp32
chmod 750 $COBDIR/bin/casjcp32
chown $SYSADMIN $COBDIR/bin/casjcp32
else
$echocmd $COBDIR/bin/casjcp32 - not found.
fi
if [ -f $COBDIR/bin/cascci32 ]; then
chgrp $DEFADMIN $COBDIR/bin/cascci32
chmod 750 $COBDIR/bin/cascci32
chown $SYSADMIN $COBDIR/bin/cascci32
else
$echocmd $COBDIR/bin/cascci32 - not found.
fi
if [ -f $COBDIR/bin/cas32prt32 ]; then
chgrp $DEFADMIN $COBDIR/bin/cas32prt32
chmod 750 $COBDIR/bin/cas32prt32
chown $SYSADMIN $COBDIR/bin/cas32prt32
else
$echocmd $COBDIR/bin/cas32prt32 - not found.
fi
if [ -f $COBDIR/bin/cascrd32 ]; then
chgrp $DEFADMIN $COBDIR/bin/cascrd32
chmod 750 $COBDIR/bin/cascrd32
chown $SYSADMIN $COBDIR/bin/cascrd32
else
$echocmd $COBDIR/bin/cascrd32 - not found.
fi
if [ -f $COBDIR/bin/casatch32 ]; then
chgrp $DEFOPER  $COBDIR/bin/casatch32
chmod 750 $COBDIR/bin/casatch32
chown $SYSADMIN $COBDIR/bin/casatch32
else
$echocmd $COBDIR/bin/casatch32 - not found.
fi
if [ -f $COBDIR/lib/dfhgfshi.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhgfshi.so
chmod 755  $COBDIR/lib/dfhgfshi.so
chown $SYSADMIN $COBDIR/lib/dfhgfshi.so
else
$echocmd $COBDIR/lib/dfhgfshi.so - not found.
fi
if [ -f $COBDIR/lib/dfhginit.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhginit.so
chmod 755  $COBDIR/lib/dfhginit.so
chown $SYSADMIN $COBDIR/lib/dfhginit.so
else
$echocmd $COBDIR/lib/dfhginit.so - not found.
fi
if [ -f $COBDIR/lib/dfhgjcpi.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhgjcpi.so
chmod 755  $COBDIR/lib/dfhgjcpi.so
chown $SYSADMIN $COBDIR/lib/dfhgjcpi.so
else
$echocmd $COBDIR/lib/dfhgjcpi.so - not found.
fi
if [ -f $COBDIR/lib/dfhgpca.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhgpca.so
chmod 755  $COBDIR/lib/dfhgpca.so
chown $SYSADMIN $COBDIR/lib/dfhgpca.so
else
$echocmd $COBDIR/lib/dfhgpca.so - not found.
fi
if [ -f $COBDIR/lib/dfhgpcam.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhgpcam.so
chmod 755  $COBDIR/lib/dfhgpcam.so
chown $SYSADMIN $COBDIR/lib/dfhgpcam.so
else
$echocmd $COBDIR/lib/dfhgpcam.so - not found.
fi
if [ -f $COBDIR/lib/dfht32db.so ]; then
chgrp $DEFADMIN $COBDIR/lib/dfht32db.so
chmod 755  $COBDIR/lib/dfht32db.so
chown $SYSADMIN $COBDIR/lib/dfht32db.so
else
$echocmd $COBDIR/lib/dfht32db.so - not found.
fi
if [ -f $COBDIR/lib/dfht32sb.so ]; then
chgrp $DEFADMIN $COBDIR/lib/dfht32sb.so
chmod 755  $COBDIR/lib/dfht32sb.so
chown $SYSADMIN $COBDIR/lib/dfht32sb.so
else
$echocmd $COBDIR/lib/dfht32sb.so - not found.
fi
if [ -f $COBDIR/lib/dfhe3270.so ]; then
chgrp $DEFADMIN $COBDIR/lib/dfhe3270.so
chmod 755  $COBDIR/lib/dfhe3270.so
chown $SYSADMIN $COBDIR/lib/dfhe3270.so
else
$echocmd $COBDIR/lib/dfhe3270.so - not found.
fi
if [ -f $COBDIR/lib/dfhe32db.so ]; then
chgrp $DEFADMIN $COBDIR/lib/dfhe32db.so
chmod 755  $COBDIR/lib/dfhe32db.so
chown $SYSADMIN $COBDIR/lib/dfhe32db.so
else
$echocmd $COBDIR/lib/dfhe32db.so - not found.
fi
if [ -f $COBDIR/lib/dfhecci1.so ]; then
chgrp $DEFADMIN $COBDIR/lib/dfhecci1.so
chmod 755  $COBDIR/lib/dfhecci1.so
chown $SYSADMIN $COBDIR/lib/dfhecci1.so
else
$echocmd $COBDIR/lib/dfhecci1.so - not found.
fi
if [ -f $COBDIR/lib/dfhecnv.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhecnv.so
chmod 755  $COBDIR/lib/dfhecnv.so
chown $SYSADMIN $COBDIR/lib/dfhecnv.so
else
$echocmd $COBDIR/lib/dfhecnv.so - not found.
fi
if [ -f $COBDIR/lib/dfheexin.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfheexin.so
chmod 755  $COBDIR/lib/dfheexin.so
chown $SYSADMIN $COBDIR/lib/dfheexin.so
else
$echocmd $COBDIR/lib/dfheexin.so - not found.
fi
if [ -f $COBDIR/lib/dfhefctl.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhefctl.so
chmod 755  $COBDIR/lib/dfhefctl.so
chown $SYSADMIN $COBDIR/lib/dfhefctl.so
else
$echocmd $COBDIR/lib/dfhefctl.so - not found.
fi
if [ -f $COBDIR/lib/dfheibmq.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfheibmq.so
chmod 755  $COBDIR/lib/dfheibmq.so
chown $SYSADMIN $COBDIR/lib/dfheibmq.so
else
$echocmd $COBDIR/lib/dfheibmq.so - not found.
fi
if [ -f $COBDIR/lib/dfhemesg.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhemesg.so
chmod 755  $COBDIR/lib/dfhemesg.so
chown $SYSADMIN $COBDIR/lib/dfhemesg.so
else
$echocmd $COBDIR/lib/dfhemesg.so - not found.
fi
if [ -f $COBDIR/lib/dfhepctc.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhepctc.so
chmod 755  $COBDIR/lib/dfhepctc.so
chown $SYSADMIN $COBDIR/lib/dfhepctc.so
else
$echocmd $COBDIR/lib/dfhepctc.so - not found.
fi
if [ -f $COBDIR/lib/dfhesche.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhesche.so
chmod 755  $COBDIR/lib/dfhesche.so
chown $SYSADMIN $COBDIR/lib/dfhesche.so
else
$echocmd $COBDIR/lib/dfhesche.so - not found.
fi
if [ -f $COBDIR/lib/dfheserv.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfheserv.so
chmod 755  $COBDIR/lib/dfheserv.so
chown $SYSADMIN $COBDIR/lib/dfheserv.so
else
$echocmd $COBDIR/lib/dfheserv.so - not found.
fi
if [ -f $COBDIR/lib/casadmin.so ]; then
chgrp $DEFOPER  $COBDIR/lib/casadmin.so
chmod 755  $COBDIR/lib/casadmin.so
chown $SYSADMIN $COBDIR/lib/casadmin.so
else
$echocmd $COBDIR/lib/casadmin.so - not found.
fi
if [ -f $COBDIR/lib/casmqsrv.so ]; then
chgrp $DEFOPER  $COBDIR/lib/casmqsrv.so
chmod 755  $COBDIR/lib/casmqsrv.so
chown $SYSADMIN $COBDIR/lib/casmqsrv.so
else
$echocmd $COBDIR/lib/casmqsrv.so - not found.
fi
if [ -f $COBDIR/lib/cashtsrv.so ]; then
chgrp $DEFOPER  $COBDIR/lib/cashtsrv.so
chmod 755  $COBDIR/lib/cashtsrv.so
chown $SYSADMIN $COBDIR/lib/cashtsrv.so
else
$echocmd $COBDIR/lib/cashtsrv.so - not found.
fi
if [ -f $COBDIR/lib/casbnsrv.so ]; then
chgrp $DEFOPER  $COBDIR/lib/casbnsrv.so
chmod 755  $COBDIR/lib/casbnsrv.so
chown $SYSADMIN $COBDIR/lib/casbnsrv.so
else
$echocmd $COBDIR/lib/casbnsrv.so - not found.
fi
if [ -f $COBDIR/bin/cassi32 ]; then
chgrp $DEFOPER  $COBDIR/bin/cassi32
chmod 750 $COBDIR/bin/cassi32
chown $SYSADMIN $COBDIR/bin/cassi32
else
$echocmd $COBDIR/bin/cassi32 - not found.
fi
if [ -f $COBDIR/bin/cassi ]; then
chgrp $DEFOPER  $COBDIR/bin/cassi
chmod 750 $COBDIR/bin/cassi
chown $SYSADMIN $COBDIR/bin/cassi
else
$echocmd $COBDIR/bin/cassi - not found.
fi
if [ -f $COBDIR/lib/cas0supp.so ]; then
chgrp $DEFOPER  $COBDIR/lib/cas0supp.so
chmod 755  $COBDIR/lib/cas0supp.so
chown $SYSADMIN $COBDIR/lib/cas0supp.so
else
$echocmd $COBDIR/lib/cas0supp.so - not found.
fi
if [ -f $COBDIR/lib/dfhesysp.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhesysp.so
chmod 755  $COBDIR/lib/dfhesysp.so
chown $SYSADMIN $COBDIR/lib/dfhesysp.so
else
$echocmd $COBDIR/lib/dfhesysp.so - not found.
fi
if [ -f $COBDIR/lib/dfhetstd.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhetstd.so
chmod 755  $COBDIR/lib/dfhetstd.so
chown $SYSADMIN $COBDIR/lib/dfhetstd.so
else
$echocmd $COBDIR/lib/dfhetstd.so - not found.
fi
if [ -f $COBDIR/lib/dfheuser.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfheuser.so
chmod 755  $COBDIR/lib/dfheuser.so
chown $SYSADMIN $COBDIR/lib/dfheuser.so
else
$echocmd $COBDIR/lib/dfheuser.so - not found.
fi
if [ -f $COBDIR/lib/dfhexfpf.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhexfpf.so
chmod 755  $COBDIR/lib/dfhexfpf.so
chown $SYSADMIN $COBDIR/lib/dfhexfpf.so
else
$echocmd $COBDIR/lib/dfhexfpf.so - not found.
fi
if [ -f $COBDIR/lib/dfhgdump.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfhgdump.so
chmod 755  $COBDIR/lib/dfhgdump.so
chown $SYSADMIN $COBDIR/lib/dfhgdump.so
else
$echocmd $COBDIR/lib/dfhgdump.so - not found.
fi
if [ -f $COBDIR/lib/dfhebms.so ]; then
chgrp $DEFADMIN $COBDIR/lib/dfhebms.so
chmod 755  $COBDIR/lib/dfhebms.so
chown $SYSADMIN $COBDIR/lib/dfhebms.so
else
$echocmd $COBDIR/lib/dfhebms.so - not found.
fi
if [ -f $COBDIR/lib/cascgirh.so ]; then
chgrp $DEFOPER  $COBDIR/lib/cascgirh.so
chmod 755  $COBDIR/lib/cascgirh.so
chown $SYSADMIN $COBDIR/lib/cascgirh.so
else
$echocmd $COBDIR/lib/cascgirh.so - not found.
fi
if [ -f $COBDIR/lib/MFRHCGI.so ]; then
chgrp $DEFOPER  $COBDIR/lib/MFRHCGI.so
chmod 755  $COBDIR/lib/MFRHCGI.so
chown $SYSADMIN $COBDIR/lib/MFRHCGI.so
else
$echocmd $COBDIR/lib/MFRHCGI.so - not found.
fi
if [ -f $COBDIR/lib/valerorh.so ]; then
chgrp $DEFOPER  $COBDIR/lib/valerorh.so
chmod 755  $COBDIR/lib/valerorh.so
chown $SYSADMIN $COBDIR/lib/valerorh.so
else
$echocmd $COBDIR/lib/valerorh.so - not found.
fi
if [ -f $COBDIR/lib/SRVRH.so ]; then
chgrp $DEFOPER  $COBDIR/lib/SRVRH.so
chmod 755  $COBDIR/lib/SRVRH.so
chown $SYSADMIN $COBDIR/lib/SRVRH.so
else
$echocmd $COBDIR/lib/SRVRH.so - not found.
fi
if [ -f $COBDIR/lib/dfheini1.so ]; then
chgrp $DEFOPER  $COBDIR/lib/dfheini1.so
chmod 755  $COBDIR/lib/dfheini1.so
chown $SYSADMIN $COBDIR/lib/dfheini1.so
else
$echocmd $COBDIR/lib/dfheini1.so - not found.
fi
if [ -f $COBDIR/lib/dfhgreqc.so ]; then
chgrp $DEFUSER  $COBDIR/lib/dfhgreqc.so
chmod 755  $COBDIR/lib/dfhgreqc.so
chown $SYSADMIN $COBDIR/lib/dfhgreqc.so
else
$echocmd $COBDIR/lib/dfhgreqc.so - not found.
fi
if [ -f $COBDIR/lib/dfhtex32.so ]; then
chgrp $DEFUSER  $COBDIR/lib/dfhtex32.so
chmod 755  $COBDIR/lib/dfhtex32.so
chown $SYSADMIN $COBDIR/lib/dfhtex32.so
else
$echocmd $COBDIR/lib/dfhtex32.so - not found.
fi
if [ -f $COBDIR/lib/dfhtinit.so ]; then
chgrp $DEFADMIN $COBDIR/lib/dfhtinit.so
chmod 755  $COBDIR/lib/dfhtinit.so
chown $SYSADMIN $COBDIR/lib/dfhtinit.so
else
$echocmd $COBDIR/lib/dfhtinit.so - not found.
fi
if [ -f $COBDIR/lib/dfhrapi.so ]; then
chgrp $DEFADMIN $COBDIR/lib/dfhrapi.so
chmod 755  $COBDIR/lib/dfhrapi.so
chown $SYSADMIN $COBDIR/lib/dfhrapi.so
else
$echocmd $COBDIR/lib/dfhrapi.so - not found.
fi
if [ -f $COBDIR/lib/dfhrval.so ]; then
chgrp $DEFADMIN $COBDIR/lib/dfhrval.so
chmod 755  $COBDIR/lib/dfhrval.so
chown $SYSADMIN $COBDIR/lib/dfhrval.so
else
$echocmd $COBDIR/lib/dfhrval.so - not found.
fi
if [ -f $COBDIR/lib/dfhrmsg.so ]; then
chgrp $DEFADMIN $COBDIR/lib/dfhrmsg.so
chmod 755  $COBDIR/lib/dfhrmsg.so
chown $SYSADMIN $COBDIR/lib/dfhrmsg.so
else
$echocmd $COBDIR/lib/dfhrmsg.so - not found.
fi
cd $COBDIR/bin; chmod o+rx $BINFILES ; 
cd $BASE

chmod 664 $BASE/cas.cfg
chgrp $DEFOPER $BASE/cas.cfg

find $BASE -print | xargs chown $SYSADMIN
cd $COBDIR/bin
find $BINFILES -print | xargs chown $SYSADMIN
find $COBDIR/etc/cas -type f -print| xargs chown $SYSADMIN
find $COBDIR/etc/cas -type f -print| xargs chgrp $DEFOPER
find $COBDIR/lib -name dfh\*.so -print| xargs chown $SYSADMIN
find $COBDIR/lib -name dfh\*.so -print| xargs chgrp $DEFOPER
find $COBDIR/lib -name cas\*.so -print| xargs chown $SYSADMIN
find $COBDIR/lib -name cas\*.so -print| xargs chgrp $DEFOPER
find $COBDIR/es/esmac -type f -print| xargs chown $SYSADMIN
find $COBDIR/es/esmac -type f -print| xargs chgrp $DEFOPER

if [ "$FIXPACK_INSTALL" = "n" ]; then
if [ ! -d "$casrtdir" ]; then
mkdir -p $casrtdir
fi
chgrp $DEFUSER $casrtdir
chmod g+w $casrtdir

$COBDIR/bin/mfds -f $SYSADMIN
RES=$?
if test $RES -ne 0
then
  $echocmd "$0: エラー $RES : $COBDIR/bin/mfds -f $SYSADMIN"
  $echocmd "\n**** 警告 Enterprise Server の構成は完了していません。\n"
  $echocmd "Enterprise Server の構成を完了するには、このエラーを修正し"
  $echocmd "'cd $COBDIR; sh ./bin/casperm’と入力して実行してください。"
else
  $echocmd "\nEnterprise Server の構成を完了しました。\n"

# 2006/09/26 ck
# Moved before permission settings. Needed for "$COBDIR/bin/mfds -f $SYSADMIN" above also for the case that casperm gets cancelled first.
# for i in cas3270 cascnvim casrdtex imtkmake mfcs casfile casstart cobimtk mfdepinst casmq casrdtup eslm casdump casstop mfds casinfo cassi casdup
# do
# if [ -f "$COBDIR/bin/.$i" ]; then
# rm $COBDIR/bin/$i
# mv $COBDIR/bin/.$i $COBDIR/bin/$i
# fi
# done

fi
fi
