📄 changedbapassword.sh
字号:
#! /bin/sh# This shell script changes both the SYSDBA user#------------------------------------------------------------------------# Prompt for response, store result in AnswerAnswer=""AskQuestion() { Test=$1 DefaultAns=$2 echo -n "${1}" Answer="$DefaultAns" read Answer}#------------------------------------------------------------------------# changeInitPasswordchangeInitPassword() { NewPasswd=$1 InitFile=/etc/rc.d/init.d/firebird if [ ! -f $InitFile ] then InitFile=/etc/init.d/firebird fi if [ -f $InitFile ] then ed $InitFile <<EOF/ISC_PASSWORD/s/ISC_PASSWORD=.*/ISC_PASSWORD=$NewPasswd/gwqEOF chmod u=rwx,g=rx,o= $InitFile fi}#------------------------------------------------------------------------# Generate new sysdba passwordgenerateNewDBAPassword() { DBAPasswordFile=$IBRootDir/SYSDBA.password NewPasswd=`mkpasswd -l 8` echo "Firebird generated password " > $DBAPasswordFile echo "for user SYSDBA is : $NewPasswd" >> $DBAPasswordFile echo "generated on `hostname` at time `date`" >> $DBAPasswordFile echo "" >> $DBAPasswordFile echo "(For superserver you will also want to check the password in the" >> $DBAPasswordFile echo "daemon init routine in the file /etc/rc.d/init.d/firebird)" >> $DBAPasswordFile echo "" >> $DBAPasswordFile echo "Your password can be changed to a more suitable one using the" >> $DBAPasswordFile echo "/opt/interbase/bin/gsec program as show below:" >> $DBAPasswordFile echo "" >> $DBAPasswordFile echo ">cd /opt/interbase" >> $DBAPasswordFile echo ">bin/gsec -user sysdba -password <password>" >> $DBAPasswordFile echo "GSEC>modify sysdba -pw <newpassword>" >> $DBAPasswordFile echo "GSEC>quit" >> $DBAPasswordFile chmod u=rw,go= $DBAPasswordFile $IBBin/gsec -user sysdba -password masterkey <<EOFmodify sysdba -pw $NewPasswdEOF changeInitPassword "$NewPasswd"}#------------------------------------------------------------------------# Change sysdba password - 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 $IBBin/gsec -user sysdba -password $OrigPasswd <<EOFmodify sysdba -pw $NewPasswdEOF 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.changeDBAPassword() { if [ -z "$InteractiveInstall" ] then generateNewDBAPassword else askUserForNewDBAPassword fi}#= Main Post =============================================================== IBRootDir=/opt/interbase IBBin=$IBRootDir/bin RunUser=root InteractiveInstall=true export InteractiveInstall changeDBAPassword
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -