From 1d2990f7e855dd64cdc0a730cb17915406d060eb Mon Sep 17 00:00:00 2001 From: AlexPeshkoff Date: Thu, 15 Sep 2016 15:21:54 +0300 Subject: [PATCH] Implemented CORE-5204: create an option in the installer to install in different locations than /opt/firebird --- .../arch-specific/freebsd/install.sh.in | 2 + .../hpux/misc/createaliasDB.sh.in | 2 +- .../install/arch-specific/linux/Makefile.in | 9 +- .../linux/firebird.init.d.debian.in | 4 +- .../linux/firebird.init.d.generic.in | 2 + .../linux/firebird.init.d.gentoo.in | 2 + .../linux/firebird.init.d.mandrake.in | 2 + .../linux/firebird.init.d.slackware.in | 2 + .../linux/firebird.init.d.suse.in | 2 + .../arch-specific/linux/firebird.xinetd.in | 3 - .../arch-specific/linux/linuxLibrary.sh.in | 173 +++++------- .../linux/makeInstallImage.sh.in | 14 +- ...ninstall.sh.in => FirebirdUninstall.sh.in} | 39 ++- .../posix-common/changeServerMode.sh.in | 7 +- builds/install/posix-common/fb_config.in | 2 + .../{postinstall.sh.in => install.sh.in} | 45 +++- .../install/posix-common/posixLibrary.sh.in | 249 +++++++++++++----- .../install/posix-common/postuninstall.sh.in | 40 --- builds/install/posix-common/preinstall.sh.in | 37 --- .../install/posix-common/preuninstall.sh.in | 40 --- .../posix-common/registerDatabase.sh.in | 2 +- .../install/posix-common/tarMainInstall.sh.in | 59 ----- builds/install/posix-common/tarinstall.sh.in | 35 --- .../install/posix-common/taruninstall.sh.in | 33 --- configure.ac | 32 +-- 25 files changed, 369 insertions(+), 468 deletions(-) rename builds/install/posix-common/{tarMainUninstall.sh.in => FirebirdUninstall.sh.in} (63%) rename builds/install/posix-common/{postinstall.sh.in => install.sh.in} (63%) delete mode 100644 builds/install/posix-common/postuninstall.sh.in delete mode 100644 builds/install/posix-common/preinstall.sh.in delete mode 100644 builds/install/posix-common/preuninstall.sh.in delete mode 100644 builds/install/posix-common/tarMainInstall.sh.in delete mode 100644 builds/install/posix-common/tarinstall.sh.in delete mode 100644 builds/install/posix-common/taruninstall.sh.in diff --git a/builds/install/arch-specific/freebsd/install.sh.in b/builds/install/arch-specific/freebsd/install.sh.in index 5186c1c8a0..ee9e752215 100755 --- a/builds/install/arch-specific/freebsd/install.sh.in +++ b/builds/install/arch-specific/freebsd/install.sh.in @@ -23,6 +23,8 @@ # Alex Peshkoff # +fb_install_prefix=@prefix@ + # Script to copy install files from the build/transport area diff --git a/builds/install/arch-specific/hpux/misc/createaliasDB.sh.in b/builds/install/arch-specific/hpux/misc/createaliasDB.sh.in index cf56858dfa..485ca84b80 100644 --- a/builds/install/arch-specific/hpux/misc/createaliasDB.sh.in +++ b/builds/install/arch-specific/hpux/misc/createaliasDB.sh.in @@ -32,7 +32,7 @@ # # - +fb_install_prefix=@prefix@ #------------------------------------------------------------------------ # Prompt for response, store result in Answer diff --git a/builds/install/arch-specific/linux/Makefile.in b/builds/install/arch-specific/linux/Makefile.in index 8f9883737c..6f0be55e32 100644 --- a/builds/install/arch-specific/linux/Makefile.in +++ b/builds/install/arch-specific/linux/Makefile.in @@ -60,8 +60,8 @@ DebugFile=Firebird-debuginfo-$(Version).$(CpuType).tar.gz PkgSrcDir=$(InstallRoot)/$(ArchType) -ScriptDir=$(GEN_ROOT)/install/scripts/ -MiscDir=@FB_MISCDIR@ +fb_install_prefix=@prefix@ +MiscDir=$(shell echo @FB_MISCDIR@) DebugManifest=manifest_debug.txt @@ -112,9 +112,8 @@ buildImageDir: buildDebugInfo buildTarDir: buildImageDir mkdir -p $(GEN_ROOT)/$(TarDir) - cp -r $(GEN_ROOT)/install/scripts $(GEN_ROOT)/$(TarDir) - cp -r $(GEN_ROOT)/install/scripts/tarMainInstall.sh $(GEN_ROOT)/$(TarDir)/install.sh - chmod a+x $(GEN_ROOT)/$(TarDir)/install.sh $(GEN_ROOT)/$(TarDir)/scripts/*sh + cp -r $(GEN_ROOT)/install/install.sh $(GEN_ROOT)/$(TarDir) + chmod a+x $(GEN_ROOT)/$(TarDir)/*.sh (cd $(GEN_ROOT)/$(TarDir); tar -C ../buildroot -czf buildroot.tar.gz . ) (cd $(GEN_ROOT)/$(TarDir); tar -tzf buildroot.tar.gz > manifest.txt ) diff --git a/builds/install/arch-specific/linux/firebird.init.d.debian.in b/builds/install/arch-specific/linux/firebird.init.d.debian.in index a338f37ffa..de528f5ed5 100644 --- a/builds/install/arch-specific/linux/firebird.init.d.debian.in +++ b/builds/install/arch-specific/linux/firebird.init.d.debian.in @@ -20,9 +20,9 @@ # running ### END INIT INFO -# This init script contains functions specific for debian -# init scripts. +fb_install_prefix=@prefix@ +# This init script contains functions specific for debian. # Source LSB function library. . /lib/lsb/init-functions diff --git a/builds/install/arch-specific/linux/firebird.init.d.generic.in b/builds/install/arch-specific/linux/firebird.init.d.generic.in index 27b7f6278c..222ed697c3 100644 --- a/builds/install/arch-specific/linux/firebird.init.d.generic.in +++ b/builds/install/arch-specific/linux/firebird.init.d.generic.in @@ -2,6 +2,8 @@ # description: Start/Stop firebird database server +fb_install_prefix=@prefix@ + # To run more instances of firebird: # Copy @prefix@ somewhere # Copy this script under a new name diff --git a/builds/install/arch-specific/linux/firebird.init.d.gentoo.in b/builds/install/arch-specific/linux/firebird.init.d.gentoo.in index 2a7e44b280..4f36aa9fe0 100644 --- a/builds/install/arch-specific/linux/firebird.init.d.gentoo.in +++ b/builds/install/arch-specific/linux/firebird.init.d.gentoo.in @@ -6,6 +6,8 @@ # on system startup and shutdown to start the background # Firebird database server daemon +fb_install_prefix=@prefix@ + # To run more instances of firebird: # Copy @prefix@ somewhere # Copy this script under a new name diff --git a/builds/install/arch-specific/linux/firebird.init.d.mandrake.in b/builds/install/arch-specific/linux/firebird.init.d.mandrake.in index d5775ee329..45c011a37a 100644 --- a/builds/install/arch-specific/linux/firebird.init.d.mandrake.in +++ b/builds/install/arch-specific/linux/firebird.init.d.mandrake.in @@ -20,6 +20,8 @@ # functions actually used: checkpid killproc daemon . /etc/rc.d/init.d/functions +fb_install_prefix=@prefix@ + # To run more instances of firebird: # Copy @prefix@ somewhere # Copy this script under a new name diff --git a/builds/install/arch-specific/linux/firebird.init.d.slackware.in b/builds/install/arch-specific/linux/firebird.init.d.slackware.in index b7c0725c73..a75a431670 100644 --- a/builds/install/arch-specific/linux/firebird.init.d.slackware.in +++ b/builds/install/arch-specific/linux/firebird.init.d.slackware.in @@ -5,6 +5,8 @@ # Start/stop/restart the firebird super server. # +fb_install_prefix=@prefix@ + # To run more instances of firebird: # Copy @prefix@ somewhere # Copy this script under a new name diff --git a/builds/install/arch-specific/linux/firebird.init.d.suse.in b/builds/install/arch-specific/linux/firebird.init.d.suse.in index 5f3e33cd26..11eb6da47d 100644 --- a/builds/install/arch-specific/linux/firebird.init.d.suse.in +++ b/builds/install/arch-specific/linux/firebird.init.d.suse.in @@ -21,6 +21,8 @@ # Description: Start the Firebird database server. ### END INIT INFO +fb_install_prefix=@prefix@ + # Source SuSE config if [ -r /etc/rc.config ] then diff --git a/builds/install/arch-specific/linux/firebird.xinetd.in b/builds/install/arch-specific/linux/firebird.xinetd.in index 3f3c46819c..93555709d7 100644 --- a/builds/install/arch-specific/linux/firebird.xinetd.in +++ b/builds/install/arch-specific/linux/firebird.xinetd.in @@ -1,9 +1,6 @@ # default: on # description: FirebirdSQL server # -# Be careful when commenting out entries in this file. Active key entry should -# be the first as some scripts (CSchangeRunUser.sh in particular) use sed -# scripting to modify it. service @FB_SERVICE_NAME@ { diff --git a/builds/install/arch-specific/linux/linuxLibrary.sh.in b/builds/install/arch-specific/linux/linuxLibrary.sh.in index f1fe91e7d7..20ff51d8b5 100644 --- a/builds/install/arch-specific/linux/linuxLibrary.sh.in +++ b/builds/install/arch-specific/linux/linuxLibrary.sh.in @@ -47,11 +47,11 @@ export tarExt TryAddGroup() { AdditionalParameter=$1 - testStr=`grep firebird /etc/group` + testStr=`grep $RunGroup /etc/group` if [ -z "$testStr" ] then - groupadd $AdditionalParameter firebird + groupadd $AdditionalParameter $RunGroup fi } @@ -60,12 +60,12 @@ TryAddGroup() { TryAddUser() { AdditionalParameter=$1 - testStr=`grep firebird /etc/passwd` + testStr=`grep $RunUser /etc/passwd` if [ -z "$testStr" ] then useradd $AdditionalParameter -d @FB_CONFDIR@ -s /sbin/nologin \ - -c "Firebird Database Owner" -g firebird firebird + -c "Firebird Database Owner" -g $RunUser $RunGroup fi } @@ -90,61 +90,19 @@ addFirebirdUser() { } -#------------------------------------------------------------------------ -# Detect Distribution. -# AP: very beautiful, but unused. Let's keep alive for a while. (2005) - -detectDistro() { - - # it's not provided... - if [ -z "$linuxDistro" ] - then - if [ -e /etc/SuSE-release ] - then - # SuSE - linuxDistro="SuSE" - elif [ -e /etc/mandrake-release ] - then - # Mandrake - linuxDistro="MDK" - elif [ -e /etc/debian_version ] - then - # Debian - linuxDistro="Debian" - elif [ -e /etc/gentoo-release ] - then - # Gentoo - linuxDistro="Gentoo" - elif [ -e /etc/rc.d/init.d/functions ] - then - # very likely Red Hat - linuxDistro="RH" - elif [ -d /etc/rc.d/init.d ] - then - # generic Red Hat - linuxDistro="G-RH" - elif [ -d /etc/init.d ] - then - # generic SuSE - linuxDistro="G-SuSE" - fi - fi -} - - #------------------------------------------------------------------------ # print location of init script getInitScriptLocation() { - if [ -f /etc/rc.d/init.d/firebird ] + if [ -f /etc/rc.d/init.d/${fb_startup_name} ] then - printf %s /etc/rc.d/init.d/firebird - elif [ -f /etc/rc.d/rc.firebird ] + printf %s /etc/rc.d/init.d/${fb_startup_name} + elif [ -f /etc/rc.d/rc.${fb_startup_name} ] then - printf %s /etc/rc.d/rc.firebird - elif [ -f /etc/init.d/firebird ] + printf %s /etc/rc.d/rc.${fb_startup_name} + elif [ -f /etc/init.d/${fb_startup_name} ] then - printf %s /etc/init.d/firebird + printf %s /etc/init.d/${fb_startup_name} fi } @@ -153,8 +111,8 @@ getInitScriptLocation() { # register/start/stop server using systemd SYSTEMCTL=systemctl -CLASSIC_CTRL=firebird-classic.socket -SUPER_CTRL=firebird-superserver.service +CLASSIC_CTRL=${fb_startup_name}-classic.socket +SUPER_CTRL=${fb_startup_name}-superserver.service SYSTEMD_DIR=/usr/lib/systemd/system [ -d $SYSTEMD_DIR ] || SYSTEMD_DIR=/lib/systemd/system TMPFILE_CONF=/usr/lib/tmpfiles.d/firebird.conf @@ -181,17 +139,22 @@ installSystemdCtrlFiles() { echo Misconfigured - can not proceed with FB install. exit 1 fi - cp @FB_MISCDIR@/*.service @FB_MISCDIR@/*.socket ${SYSTEMD_DIR} - tempdir=/var/run/firebird - mkdir -p ${tempdir} - chown firebird:firebird ${tempdir} - chmod 0775 ${tempdir} - echo "d ${tempdir} 0775 firebird firebird -" >${TMPFILE_CONF} + + cp @FB_MISCDIR@/firebird-superserver.service ${SYSTEMD_DIR}/${fb_startup_name}-superserver.service + cp @FB_MISCDIR@/firebird-classic@.service ${SYSTEMD_DIR}/${fb_startup_name}-classic@.service + cp @FB_MISCDIR@/firebird-classic.socket ${SYSTEMD_DIR}/${fb_startup_name}-classic.socket + editFile ${fb_startup_name}-superserver.service ExecStart ExecStart=${fb_install_prefix}/bin/fbguard -pidfile $PidDir/${fb_startup_name}.pid -daemon -forever + editFile ${fb_startup_name}-classic@.service ExecStart ExecStart=${fb_install_prefix}/bin/firebird + + mkdir -p ${PidDir} + chown $RunUser:$RunGroup ${PidDir} + chmod 0775 ${PidDir} + echo "d ${PidDir} 0775 $RunUser $RunGroup -" >${TMPFILE_CONF} fi } osRemoveStartupFiles() { - rm -f ${SYSTEMD_DIR}/firebird-* + rm -f ${SYSTEMD_DIR}/${fb_startup_name}-* rm -f ${TMPFILE_CONF} } @@ -346,32 +309,32 @@ installInitdScript() { if [ -e /etc/rc.d/init.d/functions ] then srcScript=firebird.init.d.mandrake - initScript=/etc/rc.d/init.d/firebird + initScript=/etc/rc.d/init.d/${fb_startup_name} # SuSE specific elif [ -r /etc/SuSE-release ] then srcScript=firebird.init.d.suse - initScript=/etc/init.d/firebird - rm -f /usr/sbin/rcfirebird - ln -s ../../etc/init.d/firebird /usr/sbin/rcfirebird + initScript=/etc/init.d/${fb_startup_name} + rm -f /usr/sbin/rc${fb_startup_name} + ln -s ../../etc/init.d/${fb_startup_name} /usr/sbin/rc${fb_startup_name} # Debian specific elif [ -r /etc/debian_version ] then srcScript=firebird.init.d.debian - initScript=/etc/init.d/firebird - rm -f /usr/sbin/rcfirebird - ln -s ../../etc/init.d/firebird /usr/sbin/rcfirebird + initScript=/etc/init.d/${fb_startup_name} + rm -f /usr/sbin/rc${fb_startup_name} + ln -s ../../etc/init.d/${fb_startup_name} /usr/sbin/rc${fb_startup_name} # Slackware specific elif [ -r /etc/slackware-version ] then srcScript=firebird.init.d.slackware - initScript=/etc/rc.d/rc.firebird + initScript=/etc/rc.d/rc.${fb_startup_name} rclocal=/etc/rc.d/rc.local if ! grep -q "$initScript" $rclocal then @@ -387,14 +350,14 @@ EOF elif [ -r /etc/gentoo-release ] then srcScript=firebird.init.d.gentoo - initScript=/etc/init.d/firebird + initScript=/etc/init.d/${fb_startup_name} # Generic... elif [ -d /etc/rc.d/init.d ] then srcScript=firebird.init.d.generic - initScript=/etc/rc.d/init.d/firebird + initScript=/etc/rc.d/init.d/${fb_startup_name} fi @@ -405,39 +368,41 @@ EOF chown root:root $initScript chmod u=rwx,g=rx,o=r $initScript + if [ "${fb_install_prefix}" == "${default_prefix}" ] + then + # RedHat and Mandrake specific + if [ -x /sbin/chkconfig ] + then + /sbin/chkconfig --add ${fb_startup_name} - # RedHat and Mandrake specific - if [ -x /sbin/chkconfig ] - then - /sbin/chkconfig --add firebird + # Gentoo specific + elif [ -x /sbin/rc-update ] + then + /sbin/rc-update add ${fb_startup_name} default - # Gentoo specific - elif [ -x /sbin/rc-update ] - then - /sbin/rc-update add firebird default + # Suse specific + elif [ -x /sbin/insserv ] + then + /sbin/insserv /etc/init.d/${fb_startup_name} - # Suse specific - elif [ -x /sbin/insserv ] - then - /sbin/insserv /etc/init.d/firebird + # One more way to register service - used in Debian + elif [ -x /usr/sbin/update-rc.d ] + then + /usr/sbin/update-rc.d -f ${fb_startup_name} remove + /usr/sbin/update-rc.d -f ${fb_startup_name} defaults + fi - # One more way to register service - used in Debian - elif [ -x /usr/sbin/update-rc.d ] - then - /usr/sbin/update-rc.d -f firebird remove - /usr/sbin/update-rc.d -f firebird defaults - fi - - # More SuSE - rc.config fillup - if [ -f /etc/rc.config ] - then + # More SuSE - rc.config fillup + if [ -f /etc/rc.config ] + then if [ -x /bin/fillup ] - then - /bin/fillup -q -d = /etc/rc.config @FB_MISCDIR@/rc.config.firebird - fi - elif [ -d /etc/sysconfig ] - then - cp @FB_MISCDIR@/rc.config.firebird /etc/sysconfig/firebird + then + /bin/fillup -q -d = /etc/rc.config @FB_MISCDIR@/rc.config.firebird + fi + elif [ -d /etc/sysconfig ] + then + cp @FB_MISCDIR@/rc.config.firebird /etc/sysconfig/firebird + fi fi else @@ -491,6 +456,8 @@ startService() { removeServiceAutostart() { if standaloneServerInstalled then + # Must try to stop server cause it can be started manually when -path is used + # systemd case unregisterSuperServer && return 0 @@ -500,17 +467,17 @@ removeServiceAutostart() { fi if [ -x /sbin/chkconfig ]; then - /sbin/chkconfig --del firebird + /sbin/chkconfig --del ${fb_startup_name} fi if [ -x /sbin/rc-update ]; then - /sbin/rc-update del firebird + /sbin/rc-update del ${fb_startup_name} fi # Remove /usr/sbin/rcfirebird symlink - if [ -e /usr/sbin/rcfirebird ] + if [ -e /usr/sbin/rc${fb_startup_name} ] then - rm -f /usr/sbin/rcfirebird + rm -f /usr/sbin/rc${fb_startup_name} fi # Remove initd script diff --git a/builds/install/arch-specific/linux/makeInstallImage.sh.in b/builds/install/arch-specific/linux/makeInstallImage.sh.in index 45baa9689e..70b3f7af5d 100644 --- a/builds/install/arch-specific/linux/makeInstallImage.sh.in +++ b/builds/install/arch-specific/linux/makeInstallImage.sh.in @@ -22,6 +22,8 @@ # Alex Peshkoff # +fb_install_prefix=@prefix@ + # Script to copy install files from the build/transport area @@ -184,19 +186,13 @@ copyFiles() { addLibs $BuiltFBDir/bin changeServerMode.sh ${TargetDir}@FB_SBINDIR@ cp $BuiltFBDir/bin/registerDatabase.sh ${TargetDir}@FB_SBINDIR@ cp $BuiltFBDir/bin/fb_config ${TargetDir}@FB_SBINDIR@ + addLibs $BuiltFBDir/bin FirebirdUninstall.sh ${TargetDir}@FB_SBINDIR@ chmod 0755 ${TargetDir}@FB_SBINDIR@/* chmod 0700 ${TargetDir}@FB_SBINDIR@/*.sh - #install scripts - addLibs $BuiltFBDir/bin tarMainInstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuiltFBDir/bin tarinstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuiltFBDir/bin preinstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuiltFBDir/bin postinstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuiltFBDir/bin preuninstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuiltFBDir/bin postuninstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuiltFBDir/bin taruninstall.sh $BuildRootDir/gen/install/scripts - addLibs $BuiltFBDir/bin tarMainUninstall.sh $BuildRootDir/gen/install/scripts + #install script + addLibs $BuiltFBDir/bin install.sh $BuildRootDir/gen/install #examples - copy only if we have them exampleFiles=`find $BuiltFBDir/examples/README -type f -print` diff --git a/builds/install/posix-common/tarMainUninstall.sh.in b/builds/install/posix-common/FirebirdUninstall.sh.in similarity index 63% rename from builds/install/posix-common/tarMainUninstall.sh.in rename to builds/install/posix-common/FirebirdUninstall.sh.in index 7a83ac3b1f..98c3ce15ca 100644 --- a/builds/install/posix-common/tarMainUninstall.sh.in +++ b/builds/install/posix-common/FirebirdUninstall.sh.in @@ -50,20 +50,41 @@ fi # Here we are uninstalling from a install tar.gz file -scriptsDir=@FB_MISCDIR@/scripts +displayMessage "Uninstalling..." +checkIfServerRunning -if [ -e $scriptsDir ] - then - displayMessage "Extracting uninstall data" +if [ -f @FB_SECDBDIR@/$SecurityDatabase ]; then + cp @FB_SECDBDIR@/$SecurityDatabase /tmp + echo "Saved a copy of SecurityDatabase ($SecurityDatabase) in /tmp" + chown root:root /tmp/$SecurityDatabase + chmod 0600 /tmp/$SecurityDatabase +fi - runAndCheckExit "$scriptsDir/preuninstall.sh" - runAndCheckExit "$scriptsDir/postuninstall.sh" +for i in @FB_GUARDDIR@/fb_guard @FB_LOGDIR@/firebird.log @FB_CONFDIR@/SYSDBA.password; do + if [ -f $i ]; then + rm -f $i + fi +done - # This one is done last since it deletes the script files - # as well. - runAndCheckExit "$scriptsDir/taruninstall.sh" +removeLinksForBackCompatibility +removeServiceAutostart +removeInetdServiceEntry +if [ -d $PidDir ] +then + rm -rf $PidDir +fi + +reconfigDynamicLoader + +removeInstalledFiles # Remove installed files +removeUninstallFiles # Remove the 'uninstall' utility files +removeEmptyDirs # Remove empty directories + +if [ "$OS_Has_Specific_Classic_Startup" ] +then + osRemoveStartupFiles fi displayMessage "Uninstall completed" diff --git a/builds/install/posix-common/changeServerMode.sh.in b/builds/install/posix-common/changeServerMode.sh.in index 02840bc3d0..d9475ea08e 100644 --- a/builds/install/posix-common/changeServerMode.sh.in +++ b/builds/install/posix-common/changeServerMode.sh.in @@ -54,18 +54,19 @@ checkIfServerRunning removeInetdServiceEntry removeServiceAutostart -echo "Starting firebird in $multiAnswer server mode..." +sc=Starting +[ ${fb_install_prefix} = ${default_prefix} ] || sc=Configure +echo "$sc firebird in $multiAnswer server mode..." fbconf="@FB_CONFDIR@/firebird.conf" if [ $multiAnswer = classic ]; then replaceLineInFile $fbconf "ServerMode = Classic" "^ServerMode" updateInetdServiceEntry - resetInetdServer else replaceLineInFile $fbconf "ServerMode = Super" "^ServerMode" installInitdScript - startService fi +startFirebird echo "Done." diff --git a/builds/install/posix-common/fb_config.in b/builds/install/posix-common/fb_config.in index 8a9bf0105b..b4359e2d19 100644 --- a/builds/install/posix-common/fb_config.in +++ b/builds/install/posix-common/fb_config.in @@ -23,6 +23,8 @@ # stored configuration values +fb_install_prefix=@prefix@ + fb_bindir=@FB_BINDIR@ fb_libdir=@FB_LIBDIR@ fb_incdir=@FB_INCDIR@ diff --git a/builds/install/posix-common/postinstall.sh.in b/builds/install/posix-common/install.sh.in similarity index 63% rename from builds/install/posix-common/postinstall.sh.in rename to builds/install/posix-common/install.sh.in index cc918c5745..f1b84cf586 100644 --- a/builds/install/posix-common/postinstall.sh.in +++ b/builds/install/posix-common/install.sh.in @@ -22,15 +22,47 @@ # Alex Peshkoff # -# The post install script for Firebird Server +# Install script for FirebirdSQL database engine +# http://www.firebirdsql.org +parseArgs ${*} +checkInstallUser -# Detect which linux distro we are installing on -detectDistro +BuildVersion=@FIREBIRD_VERSION@.@FB_BUILD_NUM@ +PackageVersion=@FIREBIRD_PACKAGE_VERSION@ +CpuType=@CPU_TYPE@ +Version="$BuildVersion-$PackageVersion.$CpuType" + +if [ ! -z "$InteractiveInstall" ] +then + cat < ${FileName}.tmp cp ${FileName}.tmp $FileName && rm -f ${FileName}.tmp @@ -515,22 +531,37 @@ setDBAPassword() { #------------------------------------------------------------------------ # buildUninstallFile # This will work only for the .tar.gz install and it builds an -# uninstall shell script. The RPM system, if present, takes care of it's own. +# uninstall shell script. buildUninstallFile() { cd "$origDir" - if [ ! -f manifest.txt ] # Only exists if we are a .tar.gz install + if [ ! -f $Manifest ] # Only exists if we are a .tar.gz install then return fi - cp manifest.txt @FB_MISCDIR@ - MANIFEST_TXT=@FB_MISCDIR@/manifest.txt + MANIFEST_TXT=@FB_MISCDIR@/$Manifest + if [ "${fb_install_prefix}" = "${default_prefix}" ] + then + cp $Manifest $MANIFEST_TXT + else + rm -f $MANIFEST_TXT + oldPath=".${default_prefix}" + + for line in `grep "^${oldPath}" $Manifest | colrm 1 ${#oldPath}` + do + echo ".${fb_install_prefix}${line}" >>$MANIFEST_TXT + done + + newPath=`dirname "${fb_install_prefix}"` + while [ ${#newPath} -gt 1 ] + do + echo ".${newPath}" >>$MANIFEST_TXT + newPath=`dirname $newPath` + done + fi - cp -r scripts @FB_MISCDIR@ - [ -f scripts/tarMainUninstall.sh ] && cp scripts/tarMainUninstall.sh @FB_SBINDIR@/$UninstallScript - [ -f scripts/tarmainUninstall.sh ] && cp scripts/tarmainUninstall.sh @FB_SBINDIR@/$UninstallScript [ -f @FB_SBINDIR@/$UninstallScript ] && chmod u=rx,go= @FB_SBINDIR@/$UninstallScript } @@ -556,7 +587,7 @@ safeLink() { Target=$2 Manifest=$3 - if [ $Source != $Target ] + if [ $Source != $Target -a "${fb_install_prefix}" = "${default_prefix}" ] then removeIfOnlyAlink $Target if [ ! -e $Target ] @@ -807,8 +838,7 @@ removeInstalledFiles() { # If some files remain then removeUninstallFiles() { - # remove the uninstall scripts files. - rm -rf @FB_MISCDIR@/scripts + # remove the uninstall files rm -f @FB_MISCDIR@/manifest*.txt rm -f @FB_SBINDIR@/$UninstallScript } @@ -949,19 +979,6 @@ fixFilePermissions() { } -#------------------------------------------------------------------------ -# changeXinetdServiceUser -# Change the run user of the xinetd service - -changeXinetdServiceUser() { - InitFile=/etc/xinetd.d/firebird - if [ -f $InitFile ] - then - editFile $InitFile user "\tuser\t\t\t= $RunUser" - fi -} - - #------------------------------------------------------------------------ # Update inetd service entry # This just adds/replaces the service entry line @@ -976,8 +993,17 @@ updateInetdEntry() { # Update xinetd service entry updateXinetdEntry() { - cp @FB_MISCDIR@/firebird.xinetd /etc/xinetd.d/firebird - changeXinetdServiceUser + InitFile="${XINETD}${fb_startup_name}" + cp @FB_MISCDIR@/firebird.xinetd $InitFile + + if [ -f $InitFile ] + then + editFile $InitFile user "\tuser\t\t\t= $RunUser" + editFile $InitFile server "\tserver\t\t= ${fb_install_prefix}/bin/firebird" + yesno=yes + [ ${fb_install_prefix} = ${default_prefix} ] && yesno=no + editFile $InitFile disable "\tdisable\t\t= ${yesno}" + fi } @@ -992,7 +1018,6 @@ updateInetdServiceEntry() { if [ "$OS_Has_Specific_Classic_Startup" ] then osRegisterClassicServer - osStartClassicServer return fi @@ -1000,12 +1025,30 @@ updateInetdServiceEntry() { then updateXinetdEntry else - updateInetdEntry + if [ ${fb_install_prefix} = ${default_prefix} ] + then + updateInetdEntry + else + echo "Install of classic server in non-default path is not supported with inetd - xinetd needed" + exit 1 + fi fi fi } +fbUsage() { + pf="" + if [ "@HAS_CONF_DIR@" = "no" ] + then + pf=', -path ' + fi + + echo "$1 option: $2. Known option(s): -silent${pf}." + exit 1 +} + + #------------------------------------------------------------------------ # parseArgs # Parse passed arguments. @@ -1015,13 +1058,26 @@ parseArgs() { flSilent=0 while [ -n "$1" ]; do - case $1 in + case "$1" in -silent) flSilent=1 ;; + -path) + if [ "@HAS_CONF_DIR@" = "no" ] + then + { fb_install_prefix="$2"; } + if [ -z "${fb_install_prefix}" ] + then + fbUsage "Missing argument for" "$1" + fi + shift + startupName + else + fbUsage "Not supported" "$1" + fi + ;; *) - echo "Invalid option: $1. Known option is '-silent'." - exit 1 + fbUsage Invalid "$1" ;; esac shift @@ -1034,13 +1090,76 @@ parseArgs() { } +#--------------------------------------------------------------------------- +# set new prefix for fb installation + +setNewPrefix() { + binlist="@FB_BINDIR@/changeServerMode.sh @FB_BINDIR@/fb_config @FB_BINDIR@/registerDatabase.sh @FB_BINDIR@/FirebirdUninstall.sh" + filelist="$binlist @FB_MISCDIR@/firebird.init.d.*" + for file in $filelist + do + editFile $file fb_install_prefix "fb_install_prefix=${fb_install_prefix}" + done + for file in $binlist + do + chmod 0700 $file + done +} + + +#--------------------------------------------------------------------------- +# extract installation archive + +extractBuildroot() { + displayMessage "Extracting install data" + + if [ "${fb_install_prefix}" = "${default_prefix}" ] + then + # Extract archive in root directory + cd / + tar -xzof "$origDir/buildroot.tar.gz" + else + mkdir -p ${fb_install_prefix} + cd ${fb_install_prefix} + defDir=".${default_prefix}" + if [ -d $defDir ] + then + echo "${default_prefix} should not exist in ${fb_install_prefix}" + fi + + tar -xzof "$origDir/buildroot.tar.gz" ${defDir} + for p in ${defDir}/* + do + mv $p . + done + + while [ ${#defDir} -gt 2 ] + do + rm -rf ${defDir} + defDir=`dirname $defDir` + done + fi + + cd "$origDir" +} + + #--------------------------------------------------------------------------- # depending upon presence of startup script starts super or classic server startFirebird() { - if standaloneServerInstalled; then - startService - else - resetInetdServer + if [ "${fb_install_prefix}" == "${default_prefix}" ] + then + if standaloneServerInstalled; then + startService + else + if [ "$OS_Has_Specific_Classic_Startup" ] + then + osStartClassicServer + return + fi + + resetInetdServer + fi fi } diff --git a/builds/install/posix-common/postuninstall.sh.in b/builds/install/posix-common/postuninstall.sh.in deleted file mode 100644 index 2b3311e861..0000000000 --- a/builds/install/posix-common/postuninstall.sh.in +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# -# The contents of this file are subject to the Initial -# Developer's Public License Version 1.0 (the "License"); -# you may not use this file except in compliance with the -# License. You may obtain a copy of the License at -# http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl. -# -# Software distributed under the License is distributed AS IS, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. -# See the License for the specific language governing rights -# and limitations under the License. -# -# The Original Code was created by Mark O'Donohue -# for the Firebird Open Source RDBMS project. -# -# Copyright (c) Mark O'Donohue -# and all contributors signed below. -# -# All Rights Reserved. -# Contributor(s): ______________________________________. -# Alex Peshkoff -# - -# The post uninstall routine for Firebird Server. - - -if [ "$1"=0 ] -then - removeLinksForBackCompatibility - removeServiceAutostart - removeInetdServiceEntry -fi - -if [ -d $PidDir ] -then - rm -rf $PidDir -fi - -reconfigDynamicLoader diff --git a/builds/install/posix-common/preinstall.sh.in b/builds/install/posix-common/preinstall.sh.in deleted file mode 100644 index 19cda393ef..0000000000 --- a/builds/install/posix-common/preinstall.sh.in +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# -# The contents of this file are subject to the Initial -# Developer's Public License Version 1.0 (the "License"); -# you may not use this file except in compliance with the -# License. You may obtain a copy of the License at -# http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl. -# -# Software distributed under the License is distributed AS IS, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. -# See the License for the specific language governing rights -# and limitations under the License. -# -# The Original Code was created by Mark O'Donohue -# for the Firebird Open Source RDBMS project. -# -# Copyright (c) Mark O'Donohue -# and all contributors signed below. -# -# All Rights Reserved. -# Contributor(s): ______________________________________. -# Alex Peshkoff -# - - -# The pre install routine for Firebird Server - -#= Main PreInstall ========================================================= - -# It's good idea not to have running firebird/interbase instances -checkIfServerRunning - -# Make sure we have required libraries installed -checkLibraries - -# Archive any files we find -archivePriorInstallSystemFiles diff --git a/builds/install/posix-common/preuninstall.sh.in b/builds/install/posix-common/preuninstall.sh.in deleted file mode 100644 index 5b550e60b8..0000000000 --- a/builds/install/posix-common/preuninstall.sh.in +++ /dev/null @@ -1,40 +0,0 @@ -#! /bin/sh -# -# The contents of this file are subject to the Initial -# Developer's Public License Version 1.0 (the "License"); -# you may not use this file except in compliance with the -# License. You may obtain a copy of the License at -# http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl. -# -# Software distributed under the License is distributed AS IS, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. -# See the License for the specific language governing rights -# and limitations under the License. -# -# The Original Code was created by Mark O'Donohue -# for the Firebird Open Source RDBMS project. -# -# Copyright (c) Mark O'Donohue -# and all contributors signed below. -# -# All Rights Reserved. -# Contributor(s): ______________________________________. -# Alex Peshkoff -# - -# The pre uninstall routines for Firebird Server - -checkIfServerRunning - -if [ -f @FB_SECDBDIR@/$SecurityDatabase ]; then - cp @FB_SECDBDIR@/$SecurityDatabase /tmp - echo "Saved a copy of SecurityDatabase ($SecurityDatabase) in /tmp" - chown root:root /tmp/$SecurityDatabase - chmod 0600 /tmp/$SecurityDatabase -fi - -for i in @FB_GUARDDIR@/fb_guard @FB_LOGDIR@/firebird.log @FB_CONFDIR@/SYSDBA.password; do - if [ -f $i ]; then - rm -f $i - fi -done diff --git a/builds/install/posix-common/registerDatabase.sh.in b/builds/install/posix-common/registerDatabase.sh.in index 68478e21be..b15e4c5a38 100644 --- a/builds/install/posix-common/registerDatabase.sh.in +++ b/builds/install/posix-common/registerDatabase.sh.in @@ -32,7 +32,7 @@ # Alex Peshkoff # - +fb_install_prefix=@prefix@ #------------------------------------------------------------------------------ # appendDatabaseEntry diff --git a/builds/install/posix-common/tarMainInstall.sh.in b/builds/install/posix-common/tarMainInstall.sh.in deleted file mode 100644 index 681b932027..0000000000 --- a/builds/install/posix-common/tarMainInstall.sh.in +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh -# -# The contents of this file are subject to the Initial -# Developer's Public License Version 1.0 (the "License"); -# you may not use this file except in compliance with the -# License. You may obtain a copy of the License at -# http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl. -# -# Software distributed under the License is distributed AS IS, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. -# See the License for the specific language governing rights -# and limitations under the License. -# -# The Original Code was created by Mark O'Donohue -# for the Firebird Open Source RDBMS project. -# -# Copyright (c) Mark O'Donohue -# and all contributors signed below. -# -# All Rights Reserved. -# Contributor(s): ______________________________________. -# Alex Peshkoff -# - -# Install script for FirebirdSQL database engine -# http://www.firebirdsql.org - -parseArgs ${*} - -checkInstallUser - -BuildVersion=@FIREBIRD_VERSION@.@FB_BUILD_NUM@ -PackageVersion=@FIREBIRD_PACKAGE_VERSION@ -CpuType=@CPU_TYPE@ - -Version="$BuildVersion-$PackageVersion.$CpuType" - -if [ ! -z "$InteractiveInstall" ] -then - cat < -# and all contributors signed below. -# -# All Rights Reserved. -# Contributor(s): ______________________________________. -# Alex Peshkoff -# - -# The way this works is that the buildroot file is stored relative to the root -# directory and a tar -xzof at root directory will restore all the files in -# the position that we want them to be - -OrigDir=`pwd` - -cd / - -tar -xzof "$OrigDir/buildroot.tar.gz" - -cd "$OrigDir" diff --git a/builds/install/posix-common/taruninstall.sh.in b/builds/install/posix-common/taruninstall.sh.in deleted file mode 100644 index f3a1cf51f0..0000000000 --- a/builds/install/posix-common/taruninstall.sh.in +++ /dev/null @@ -1,33 +0,0 @@ -#! /bin/sh -# -# The contents of this file are subject to the Initial -# Developer's Public License Version 1.0 (the "License"); -# you may not use this file except in compliance with the -# License. You may obtain a copy of the License at -# http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl. -# -# Software distributed under the License is distributed AS IS, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. -# See the License for the specific language governing rights -# and limitations under the License. -# -# The Original Code was created by Mark O'Donohue -# for the Firebird Open Source RDBMS project. -# -# Copyright (c) Mark O'Donohue -# and all contributors signed below. -# -# All Rights Reserved. -# Contributor(s): ______________________________________. -# Alex Peshkoff -# - - -removeInstalledFiles # Remove installed files -removeUninstallFiles # Remove the 'uninstall' utility files -removeEmptyDirs # Remove empty directories - -if [ "$OS_Has_Specific_Classic_Startup" ] -then - osRemoveStartupFiles -fi diff --git a/configure.ac b/configure.ac index b870a80b55..58bb941863 100644 --- a/configure.ac +++ b/configure.ac @@ -21,13 +21,15 @@ define([XE_APPEND],[[$2]="$[$2] [$1]"]) dnl XE_PREPEND(value, varname) define([XE_PREPEND],[[$2]="[$1] $[$2]"]) +HAS_CONF_DIR=no dnl XE_CONF_DIR(param, help, variable, default) define([XE_CONF_DIR],[ -AC_ARG_WITH([$1], - [AS_HELP_STRING([--with-$1],[$2])], +AC_ARG_WITH([$1], + [AS_HELP_STRING([--with-$1],[$2])], [[$3]="$withval" - AC_DEFINE_UNQUOTED([$3], "$[$3]", [$2])], - [[$3]="[`if test ""x$prefix"" = ""xNONE"" ; then echo ""$ac_default_prefix""; else echo ""$prefix""; fi`][$4]" + HAS_CONF_DIR=yes + AC_DEFINE_UNQUOTED([$3], "$[$3]", [$2])], + [[$3]='${fb_install_prefix}[$4]' AC_DEFINE_UNQUOTED([$3], [""], [$2])] ) AC_SUBST([$3]) @@ -647,6 +649,7 @@ XE_CONF_DIR(fblog, [log files DIR (PREFIX)], FB_LOGDIR) XE_CONF_FILE(fblogfilename, [log file name within log dir (firebird.log)], FB_LOGFILENAME, firebird.log) XE_CONF_DIR(fbglock, [guardian lock DIR (PREFIX)], FB_GUARDDIR) XE_CONF_DIR(fbplugins, [plugins DIR (PREFIX)], FB_PLUGDIR, /plugins) +AC_SUBST(HAS_CONF_DIR) dnl gpre built-in language support (C/C++ are mandatory) GPRE_LANGUAGE_MODULES="" @@ -1218,14 +1221,8 @@ fi AC_CONFIG_FILES([ gen/Release/firebird/bin/fb_config:builds/install/posix-common/fb_config.in gen/Release/firebird/bin/posixLibrary.sh:builds/install/posix-common/posixLibrary.sh.in -gen/Release/firebird/bin/tarMainInstall.sh:builds/install/posix-common/tarMainInstall.sh.in -gen/Release/firebird/bin/tarinstall.sh:builds/install/posix-common/tarinstall.sh.in -gen/Release/firebird/bin/preinstall.sh:builds/install/posix-common/preinstall.sh.in -gen/Release/firebird/bin/postinstall.sh:builds/install/posix-common/postinstall.sh.in -gen/Release/firebird/bin/preuninstall.sh:builds/install/posix-common/preuninstall.sh.in -gen/Release/firebird/bin/postuninstall.sh:builds/install/posix-common/postuninstall.sh.in -gen/Release/firebird/bin/taruninstall.sh:builds/install/posix-common/taruninstall.sh.in -gen/Release/firebird/bin/tarMainUninstall.sh:builds/install/posix-common/tarMainUninstall.sh.in +gen/Release/firebird/bin/install.sh:builds/install/posix-common/install.sh.in +gen/Release/firebird/bin/FirebirdUninstall.sh:builds/install/posix-common/FirebirdUninstall.sh.in gen/Release/firebird/bin/changeServerMode.sh:builds/install/posix-common/changeServerMode.sh.in gen/Release/firebird/bin/registerDatabase.sh:builds/install/posix-common/registerDatabase.sh.in gen/vers.sh:builds/posix/vers.sh.in @@ -1236,7 +1233,6 @@ dnl: Platform Specific Files case "$PLATFORM" in LINUX|GENTOOFREEBSD) AC_CONFIG_COMMANDS(,,[ - mkdir -p gen/install/scripts mkdir -p gen/install/misc]) INSTALL_SRC_DIR=builds/install/arch-specific/linux @@ -1255,7 +1251,7 @@ case "$PLATFORM" in gen/install/misc/firebird-classic.socket:builds/install/arch-specific/linux/firebird-classic.socket.in gen/install/misc/firebird-superserver.service:builds/install/arch-specific/linux/firebird-superserver.service.in ], - [chmod a+x gen/install/scripts/*.sh gen/install/*sh 2>/dev/null]) + [chmod a+x gen/install/*sh 2>/dev/null]) ;; HPUX) @@ -1273,14 +1269,12 @@ case "$PLATFORM" in gen/install/misc/firebird.init.d.hpux:builds/install/arch-specific/hpux/misc/firebird.init.d.hpux.in gen/install/misc/rc.config.firebird.hpux:builds/install/arch-specific/hpux/misc/rc.config.firebird.hpux.in gen/Release/firebird/bin/hpuxLibrary.sh:builds/install/arch-specific/hpux/misc/hpuxLibrary.sh.in], - [chmod a+x gen/install/scripts/*.sh gen/install/*.sh 2>/dev/null]) + [chmod a+x gen/install/*.sh 2>/dev/null]) ;; AIX) AIX_INSTALL_SRC_DIR=builds/install/arch-specific/aix - AC_CONFIG_FILES([gen/install/scripts/rpmheader.aix.txt:${AIX_INSTALL_SRC_DIR}/rpmheader.txt.in - gen/install/scripts/rpmfiles.aix.txt:${AIX_INSTALL_SRC_DIR}/rpmfiles.txt.in - gen/install/makeInstallImage.aix.sh:${AIX_INSTALL_SRC_DIR}/makeInstallImage.sh.in + AC_CONFIG_FILES([gen/install/makeInstallImage.aix.sh:${AIX_INSTALL_SRC_DIR}/makeInstallImage.sh.in gen/firebird/bin/preinstall.aix.sh:builds/install/arch-specific/aix/misc/preinstall.sh.in gen/firebird/bin/tarinstall.aix.sh:builds/install/arch-specific/aix/misc/tarinstall.sh.in gen/firebird/bin/tarmaininstall.aix.sh:builds/install/arch-specific/aix/misc/tarmaininstall.sh.in @@ -1296,7 +1290,7 @@ case "$PLATFORM" in gen/firebird/bin/changegdslibrarycompatiblelink.aix.sh:builds/install/misc/changeGdsLibraryCompatibleLink.sh.in gen/firebird/bin/createaliasdb.aix.sh:builds/install/misc/createAliasDB.sh.in gen/firebird/bin/aixLibrary.sh:builds/install/arch-specific/aix/misc/aixLibrary.sh.in], - [chmod a+x gen/install/scripts/*.sh gen/install/*.sh 2>/dev/null]) + [chmod a+x gen/install/*.sh 2>/dev/null]) ;; FREEBSD) AC_CONFIG_FILES([gen/install/install.sh:builds/install/arch-specific/freebsd/install.sh.in