📄 csrpmscript
字号:
replaceLineInFile() { FileName=$1 newLine=$2 oldLine=$3 if [ -z "$oldLine" ] then echo "$newLine" >> $FileName elif [ "$oldLine" != "$newLine" ] then echo "" echo "--- Warning ----------------------------------------------" echo "" echo " In file $FileName found line: " echo " $oldLine" echo " Which differs from the expected line:" echo " $newLine" echo ""# AskQuestion "Press return to update file or ^C to abort install" cat $FileName | grep -v "$oldLine" > ${FileName}.tmp mv ${FileName}.tmp $FileName echo "$newLine" >> $FileName echo "Updated." fi}#------------------------------------------------------------------------# Unable to generate the password for the rpm, so put out a message # insteadkeepOrigDBAPassword() { DBAPasswordFile=$IBRootDir/SYSDBA.password NewPasswd='masterkey' echo "Firebird initial install password " > $DBAPasswordFile echo "for user SYSDBA is : $NewPasswd" >> $DBAPasswordFile echo "for install on `hostname` at time `date`" >> $DBAPasswordFile echo "You should change this password at the earliest oportunity" >> $DBAPasswordFile echo "" 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 should 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=r,go= $DBAPasswordFile}#------------------------------------------------------------------------# Generate new sysdba password - this routine is used only in the # rpm file not in the install acript.generateNewDBAPassword() { DBAPasswordFile=$IBRootDir/SYSDBA.password NewPasswd=`/usr/bin/mkpasswd -l 8` echo "Firebird generated password " > $DBAPasswordFile echo "for user SYSDBA is : $NewPasswd" >> $DBAPasswordFile echo "generated on `hostname` at time `date`" >> $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=r,go= $DBAPasswordFile $IBBin/gsec -user sysdba -password masterkey <<EOFmodify sysdba -pw $NewPasswdEOF}#------------------------------------------------------------------------# Change sysdba password - this routine is interactive and is only # used in the install shell script not the rpm one.askUserForNewDBAPassword() { NewPasswd="" while [ -z "$NewPasswd" ] do# If using a generated password# DBAPasswordFile=$IBRootDir/SYSDBA.password# NewPasswd=`mkpasswd -l 8`# echo "Password for SYSDBA on `hostname` is : $NewPasswd" > $DBAPasswordFile# chmod ga-rwx $DBAPasswordFile AskQuestion "Please enter new password for SYSDBA user: " NewPasswd=$Answer if [ ! -z "$NewPasswd" ] then $IBBin/gsec -user sysdba -password masterkey <<EOFmodify sysdba -pw $NewPasswdEOF echo "" fi done}#------------------------------------------------------------------------# Change sysdba password - this routine is interactive and is only # used in the install shell script not the rpm one.# On some systems the mkpasswd program doesn't appear and on others# there is another mkpasswd which does a different operation. So if# the specific one isn't available then keep the original password.changeDBAPassword() { if [ -z "$InteractiveInstall" ] then if [ -f /usr/bin/mkpasswd ] then generateNewDBAPassword else keepOrigDBAPassword fi else askUserForNewDBAPassword fi}#= Main Post =============================================================== # Make sure the links are in place if [ ! -L /opt/interbase -a ! -d /opt/interbase ] then # Main link and... ln -s $RPM_INSTALL_PREFIX/interbase /opt/interbase fi IBRootDir=/opt/interbase IBBin=$IBRootDir/bin RunUser=root # Update /etc/services FileName=/etc/services newLine="gds_db 3050/tcp # InterBase Database Remote Protocol" oldLine=`grep "^gds_db" $FileName` replaceLineInFile "$FileName" "$newLine" "$oldLine" # Update the /etc/inetd.conf FileName=/etc/inetd.conf newLine="gds_db stream tcp nowait.30000 $RunUser $IBBin/gds_inet_server gds_inet_server # InterBase Database Remote Server" oldLine=`grep "^gds_db" $FileName` replaceLineInFile "$FileName" "$newLine" "$oldLine" # Update ownership and SUID bits for programs. chown -R $RunUser.$RunUser $IBRootDir cd $IBBin for i in gds_lock_mgr gds_drop gds_inet_server do chmod ug+s $i done # Get inetd to reread new init files. if [ -f /var/run/inetd.pid ] then kill -HUP `cat /var/run/inetd.pid` fi # Lock files # remember isc_guard1 in addition for super cd $IBRootDir for i in isc_init1 isc_lock1 isc_event1 do FileName=$i.`hostname` touch $FileName chmod uga+rw $FileName done touch interbase.log chmod uga+rw interbase.log # make examples writable by anyone chmod uga+rw examples/*.gdb # Change sysdba password changeDBAPassword%preun#! /bin/sh# The pre uninstall routines for Firebird Classic#------------------------------------------------------------------------# stop server if it is runningcheckIfServerRunning() {# Check is server is being actively used. checkString=`ps -ef| egrep "(gds_inet_server|gds_pipe)" |grep -v grep` if [ ! -z "$checkString" ] then echo "An instance of the Firebird/InterBase server seems to be running." echo "Please quit all interbase applications and then proceed." exit 1 fi# Stop lock manager if it is the only thing running. for i in `ps -ef | grep "gds_lock_mgr" | grep -v "grep" | cut -d' ' -f3` do kill $i done}#= Main PreUn ================================================================# This is a bit simple, but should work for now. # cron will remove files in /tmp after a while. IBRootDir=/opt/interbase IBBin=$IBRootDir/bin checkIfServerRunning cd $IBRootDir if [ -f isc4.gdb ] then cp isc4.gdb /tmp echo "Saved a copy of isc4.gdb in /tmp" fi for i in isc_init1* isc_event1* isc_lock1* interbase.log SYSDBA.password do if [ -f $i ] then rm -f $i fi done%postun#!/bin/sh# The post uninstall routine for Firebird Classic.#------------------------------------------------------------------------# remove line from config file if it exists in it.removeLineFromFile() { FileName=$1 oldLine=$2 if [ ! -z "$oldLine" ] then cat $FileName | grep -v "$oldLine" > ${FileName}.tmp mv ${FileName}.tmp $FileName echo "Updated." fi}#= Main PostUn ============================================================ if [ -L /usr/lib/libgds.so ] then rm /usr/lib/libgds.so fi if [ "$1"=0 ] then # Lose the gds_db line from /etc/services FileName=/etc/services oldLine=`grep "^gds_db" $FileName` removeLineFromFile "$FileName" "$oldLine" # Next, lose the gds_db line from /etc/inetd.conf FileName=/etc/inetd.conf oldLine=`grep "^gds_db" $FileName` removeLineFromFile "$FileName" "$oldLine" # Get inetd to reread new inetd.conf file if [ -f /var/run/inetd.pid ] then kill -HUP `cat /var/run/inetd.pid` fi fi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -