#!/bin/sh # # This library is part of the FirebirdSQL project # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # You may obtain a copy of the Licence at # http://www.gnu.org/licences/lgpl.html # # As a special exception this file can also be included in modules # with other source code as long as that source code has been # released under an Open Source Initiative certificed licence. # More information about OSI certification can be found at: # http://www.opensource.org # # This module is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public Licence for more details. # # This module was created by members of the firebird development # team. All individual contributions remain the Copyright (C) of # those individuals and all rights are reserved. Contributors to # this file are either listed below or can be obtained from a CVS # history command. # # Created by: Mark O'Donohue # # Contributor(s): # # # $Id: postinstall.sh.in,v 1.7 2004-01-29 06:32:06 skidder Exp $ # # The post install script for Firebird Classic #------------------------------------------------------------------------ # Prompt for response, store result in Answer Answer="" AskQuestion() { Test=$1 DefaultAns=$2 echo -n "${1}" Answer="$DefaultAns" read Answer } #------------------------------------------------------------------------ # add a service line in the (usually) /etc/services or /etc/inetd.conf file # Here there are three cases, not found => add service line, # found & different => ask user to check # found & same => do nothing # 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 } #------------------------------------------------------------------------ # Add new user and group addFirebirdUser() { testStr=`grep firebird /etc/group` if [ -z "$testStr" ] then groupadd firebird fi testStr=`grep firebird /etc/passwd` if [ -z "$testStr" ] then useradd -M -d $FBRootDir -s /bin/bash \ -c "Firebird Database Administrator" -g firebird firebird # >/dev/null 2>&1 fi } #------------------------------------------------------------------------ # Delete new user and group deleteFirebirdUser() { userdel firebird # groupdel firebird } #------------------------------------------------------------------------ # changeXinetdServiceUser # Change the run user of the xinetd service # ex is used in place of ed, since at least on one mandrake release ed # was not installed, but ex seems to always be installed MOD 7-Nov-2002 changeXinetdServiceUser() { InitFile=/etc/xinetd.d/firebird if [ -f $InitFile ] then ex -s $InitFile < $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/init.d/firebird)" >> $DBAPasswordFile echo "" >> $DBAPasswordFile echo "Your should password can be changed to a more suitable one using the" >> $DBAPasswordFile echo "@prefix@/bin/changeDBAPassword.sh script" >> $DBAPasswordFile echo "" >> $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=$FBRootDir/SYSDBA.password # openssl generates random data. if [ -f /usr/bin/openssl ] then NewPasswd=`openssl rand -base64 10 | cut -c1-8` fi # mkpasswd is a bit of a hassle, but check to see if it's there if [ -z "$NewPasswd" ] then if [ -f /usr/bin/mkpasswd ] then NewPasswd=`/usr/bin/mkpasswd -l 8` fi fi if [ -z "$NewPasswd" ] then keepOrigDBAPassword return fi 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 "@prefix@/bin/changeDBAPassword.sh script" >> $DBAPasswordFile echo "" >> $DBAPasswordFile chmod u=r,go= $DBAPasswordFile $FBBin/gsec -user sysdba -password masterkey < $DBAPasswordFile # chmod ga-rwx $DBAPasswordFile AskQuestion "Please enter new password for SYSDBA user: " NewPasswd=$Answer if [ ! -z "$NewPasswd" ] then $FBBin/gsec -user sysdba -password masterkey <> $FileName echo $newLine >> $FileName echo "" >> $FileName # replaceLineInFile "$FileName" "$newLine" "$oldLine" fi UpdateHostsDotEquivFile # add Firebird user if [ $RunUser = "firebird" ] then addFirebirdUser fi # Create Lock files cd $FBRootDir for i in isc_init1 isc_lock1 isc_event1 do FileName=$i.`hostname` touch $FileName done # Create log touch firebird.log # Update ownership and SUID bits for programs. chown -R $RunUser.$RunUser $FBRootDir if [ "$RunUser" = "root" ] then fixFilePermissionsRoot else fixFilePermissions fi createLinksForBackCompatibility buildUninstallFile # Update the /etc/inetd.conf or xinetd entry updateInetdServiceEntry # Get inetd to reread new init files. resetInetdServer cd $FBRootDir # Change sysdba password changeDBAPassword #keepOrigDBAPassword