8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 22:03:03 +01:00
firebird-mirror/builds/install/misc/changeDBAPassword.sh.in
2005-03-13 16:04:59 +00:00

101 lines
2.0 KiB
Bash

#! /bin/sh
# This shell script changes both the SYSDBA user
# and /etc/init.d/firebird script
#------------------------------------------------------------------------
# Prompt for response, store result in Answer
Answer=""
AskQuestion() {
Test=$1
DefaultAns=$2
echo -n "${1}"
Answer="$DefaultAns"
read Answer
}
#------------------------------------------------------------------------
# changeInitPassword
changeInitPassword() {
NewPasswd=$1
DBAPasswordFile=$FBRootDir/SYSDBA.password
InitFile=/etc/rc.d/init.d/firebird
if [ ! -f $InitFile ]
then
InitFile=/etc/init.d/firebird
fi
if [ -f $InitFile ]
then
echo ""
echo Running ex to modify /etc/init.d/firebird
ex $InitFile <<EOF
/ISC_PASSWORD/s/ISC_PASSWORD=.*/ISC_PASSWORD=$NewPasswd/g
w
q
EOF
chmod u=rwx,g=rx,o= $InitFile
fi
}
#------------------------------------------------------------------------
# this routine is interactive and is only
# used in the install shell script not the rpm one.
askUserForNewDBAPassword() {
OrigPasswd=""
while [ -z "$OrigPasswd" ]
do
AskQuestion "Please enter current password for SYSDBA user: "
OrigPasswd=$Answer
done
NewPasswd=""
while [ -z "$NewPasswd" ]
do
AskQuestion "Please enter new password for SYSDBA user: "
NewPasswd=$Answer
if [ ! -z "$NewPasswd" ]
then
$FBBin/gsec -user sysdba -password $OrigPasswd <<EOF
modify sysdba -pw $NewPasswd
EOF
echo ""
changeInitPassword "$NewPasswd"
fi
done
}
#------------------------------------------------------------------------
# Change sysdba password - this routine is interactive and is only
# used in the install shell script not the rpm one.
#= Main Post ===============================================================
FBRootDir=@prefix@
FBBin=$FBRootDir/bin
askUserForNewDBAPassword